[Bug c/37874] gcc sometimes accepts attribute in identifier list
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37874 Eric Gallager changed: What|Removed |Added Keywords||accepts-invalid --- Comment #6 from Eric Gallager --- (In reply to Eric Gallager from comment #5) > (In reply to Chris Lattner from comment #0) > > GCC rejects the former, but not the later. > > > > void f2(y, __attribute__(()) x); > > void f3(__attribute__(()) x, y); > > GCC can be made to reject f3() with -Werror: > > $ /usr/local/bin/gcc -c -Wall -Wextra -pedantic -Werror 37874.c > 37874.c:1:12: error: expected ‘)’ before ‘__attribute__’ > void f2(y, __attribute__(()) x); > ^ > 37874.c:2:1: error: parameter names (without types) in function declaration > [-Werror] > void f3(__attribute__(()) x, y); > ^~~~ > cc1: all warnings being treated as errors > > I see you fixed this for f4() at least for clang: > > $ /sw/opt/llvm-3.1/bin/clang-3.1 -c 37874.c > 37874.c:1:12: error: expected identifier > void f2(y, __attribute__(()) x); >^ > 37874.c:2:27: warning: type specifier missing, defaults to 'int' > [-Wimplicit-int] > void f3(__attribute__(()) x, y); > ~ ^ > 37874.c:2:30: warning: type specifier missing, defaults to 'int' > [-Wimplicit-int] > void f3(__attribute__(()) x, y); > ^ > 37874.c:3:9: error: expected parameter declarator > void f4(__attribute__(())); > ^ > 2 warnings and 2 errors generated. Since clang rejects this, I'm making this an accepts-invalid
[Bug c/37874] gcc sometimes accepts attribute in identifier list
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37874 Eric Gallager changed: What|Removed |Added CC||egallager at gcc dot gnu.org --- Comment #5 from Eric Gallager --- (In reply to Chris Lattner from comment #0) > GCC rejects the former, but not the later. > > void f2(y, __attribute__(()) x); > void f3(__attribute__(()) x, y); GCC can be made to reject f3() with -Werror: $ /usr/local/bin/gcc -c -Wall -Wextra -pedantic -Werror 37874.c 37874.c:1:12: error: expected ‘)’ before ‘__attribute__’ void f2(y, __attribute__(()) x); ^ 37874.c:2:1: error: parameter names (without types) in function declaration [-Werror] void f3(__attribute__(()) x, y); ^~~~ cc1: all warnings being treated as errors I see you fixed this for f4() at least for clang: $ /sw/opt/llvm-3.1/bin/clang-3.1 -c 37874.c 37874.c:1:12: error: expected identifier void f2(y, __attribute__(()) x); ^ 37874.c:2:27: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] void f3(__attribute__(()) x, y); ~ ^ 37874.c:2:30: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] void f3(__attribute__(()) x, y); ^ 37874.c:3:9: error: expected parameter declarator void f4(__attribute__(())); ^ 2 warnings and 2 errors generated.
[Bug c/37874] gcc sometimes accepts attribute in identifier list
-- jsm28 at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2009-11-22 19:46:14 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37874
[Bug c/37874] gcc sometimes accepts attribute in identifier list
--- Comment #4 from joseph at codesourcery dot com 2008-10-20 12:48 --- Subject: Re: gcc sometimes accepts attribute in identifier list On Mon, 20 Oct 2008, sabre at nondot dot org wrote: as it turns out, f3 could also be considered valid in c89... because it makes x and y be implicit int's, not an identifier list. All parameters need a nonempty list of declaration specifiers in a parameter type list, which y doesn't have in that case. Implicit int in C90 (removed in C99) means that list could just be const, for example, but not completely empty. That the first parameter in a parameter type list must have some *non-attribute* declaration specifier is documented in Attribute Syntax along with the ambiguity this resolves. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37874
[Bug c/37874] gcc sometimes accepts attribute in identifier list
--- Comment #1 from sabre at nondot dot org 2008-10-20 01:08 --- It also accepts this: void f4(__attribute__(())); -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37874
[Bug c/37874] gcc sometimes accepts attribute in identifier list
--- Comment #2 from joseph at codesourcery dot com 2008-10-20 01:51 --- Subject: Re: gcc sometimes accepts attribute in identifier list On Mon, 20 Oct 2008, sabre at nondot dot org wrote: It also accepts this: void f4(__attribute__(())); This is documented in Attribute Syntax. (The acceptance of empty attributes, and only empty attributes, at the start of an identifier list, is an implementation accident accurately carried over from the old parser without noticing it was there, but also a bug.) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37874
[Bug c/37874] gcc sometimes accepts attribute in identifier list
--- Comment #3 from sabre at nondot dot org 2008-10-20 02:10 --- as it turns out, f3 could also be considered valid in c89... because it makes x and y be implicit int's, not an identifier list. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37874