LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 3310 - declaration of vars with undefined structured type is rejected
Summary: declaration of vars with undefined structured type is rejected
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: unspecified
Hardware: PC All
: P normal
Assignee: Douglas Gregor
URL: http://www.coresystems.de/~patrick/sc...
Keywords:
: 3349 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-01-09 17:27 PST by Stefan Reinauer
Modified: 2010-03-12 00:57 PST (History)
6 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Reinauer 2009-01-09 17:27:25 PST
We scanned our firmware coreboot (See http://www.coreboot.org/) and it finds 11 analyzer failures. Complete logs are at http://www.coresystems.de/~patrick/scan-build-2009-01-09-1/

Please let me know if you need more information
Comment 1 Nuno Lopes 2009-01-13 14:01:17 PST
the parser rejects are all reduced to this simple test case:

struct foo bar;

'gcc -fsyntax-only' accepts this with *no warning* (weird..), while clang rejects it.
Comment 2 Daniel Dunbar 2009-01-14 21:07:53 PST
This is invalid code per C99 6.7p7. 

Note that, for example,
--
extern struct foo bar;
void *p = &bar;
--
is legal and clang accepts this.

Doug, you made a comment indicating you thought this was legal. It is true that if this was a legal declaration this would be a tentative definition, however my reading is that this isn't a legal declaration.

Do you agree?
Comment 3 Daniel Dunbar 2009-01-18 14:35:15 PST
*** Bug 3349 has been marked as a duplicate of this bug. ***
Comment 4 Eli Friedman 2009-01-18 15:36:46 PST
(In reply to comment #1)
> the parser rejects are all reduced to this simple test case:
> 
> struct foo bar;
> 
> 'gcc -fsyntax-only' accepts this with *no warning* (weird..), while clang
> rejects it.

I think you reduced that a bit too much... that's actually a bug in gcc's "-fsyntax-only".  Try "gcc -S -o /dev/null" instead.
Comment 5 Eli Friedman 2009-01-18 15:49:12 PST
Proper reduced testcase:

struct a x;
struct a {int x;};

And as far as I can tell, this is actually legal; 6.7p7 doesn't apply here because x has linkage.
Comment 6 Douglas Gregor 2009-03-10 18:44:57 PDT
Should be fixed by:

  http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20090309/013735.html