Wrong parsing of record decls in parameters' lists
| Bugzilla Link | 6298 |
| Resolution | FIXED |
| Resolved on | Feb 28, 2012 12:38 |
| Version | trunk |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @jmolloy,@rjmccall |
Extended Description
The following testcase shows that clang erroneously "believes" that the scope of record declarations in parameters' lists extends beyond the block scope and not inside the block, as the standard mandates.
$ cat bug.c
struct s { int x; };
void f(struct s { int y; }* v) { }
void g(struct t { int x; } v) { struct t { int y; }; } $ clang bug.c bug.c:4:15: error: redefinition of 's' void f(struct s { int y; } v) { ^ bug.c:2:8: note: previous definition is here struct s { int x; }; ^ bug.c:7:15: warning: declaration of 'struct t' will not be visible outside of this function void g(struct t { int x; } *v) { ^ 3 diagnostics generated. $ gcc -c -w bug.c bug.c: In function 'g': bug.c:8: error: redefinition of 'struct t' $
Fixed in r151638.
Still repos in ToT
This bug is still present in SVN HEAD.
This bug is still present in SVN HEAD.
Ok, just thought we were rejecting something poorly. That definitely does look like a bug.
I am not sure I understand why the keyword "quality-of-implementation" was added. Perhaps because I supplied a testcase that was illegal both for GCC and for clang (I did that only to show that clang seems to have the logic backwards).
Here is a legal testcase, accepted by GCC, the Intel C compiler, and Comeau C, but rejected by clang:
struct s { int x; };
void f(struct s { int y; }* v) { struct s a; a.y = 2; }