r215814 - Uniformed parsing of GNU attributes at line beginnning and added GNU attributes parsing FIXMEs.

Abramo Bagnara abramo.bagnara at bugseng.com
Sat Aug 16 01:29:28 PDT 2014


Author: abramo
Date: Sat Aug 16 03:29:27 2014
New Revision: 215814

URL: http://llvm.org/viewvc/llvm-project?rev=215814&view=rev
Log:
Uniformed parsing of GNU attributes at line beginnning and added GNU attributes parsing FIXMEs.

Added:
    cfe/trunk/test/Sema/gnu-attributes.c
Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/Parser/attributes.c

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=215814&r1=215813&r2=215814&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sat Aug 16 03:29:27 2014
@@ -1068,6 +1068,9 @@ bool Parser::isValidAfterTypeSpecifier(b
   case tok::kw___declspec:      // struct foo {...} __declspec(...)
   case tok::l_square:           // void f(struct f  [         3])
   case tok::ellipsis:           // void f(struct f  ...       [Ns])
+  // FIXME: we should emit semantic diagnostic when declaration
+  // attribute is in type attribute position.
+  case tok::kw___attribute:     // struct foo __attribute__((used)) x;
     return true;
   case tok::colon:
     return CouldBeBitfield;     // enum E { ... }   :         2;

Modified: cfe/trunk/test/Parser/attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/attributes.c?rev=215814&r1=215813&r2=215814&view=diff
==============================================================================
--- cfe/trunk/test/Parser/attributes.c (original)
+++ cfe/trunk/test/Parser/attributes.c Sat Aug 16 03:29:27 2014
@@ -95,3 +95,13 @@ void testFundef5() __attribute__(()) { }
 __attribute__((pure)) int testFundef6(int a) { return a; }
 
 void deprecatedTestFun(void) __attribute__((deprecated()));
+
+struct s {
+  int a;
+};
+
+// This test ensure compatibility with parsing GNU-style attributes
+// where the attribute is on a separate line from the elaborated type
+// specifier.
+struct s
+__attribute__((used)) bar;

Added: cfe/trunk/test/Sema/gnu-attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/gnu-attributes.c?rev=215814&view=auto
==============================================================================
--- cfe/trunk/test/Sema/gnu-attributes.c (added)
+++ cfe/trunk/test/Sema/gnu-attributes.c Sat Aug 16 03:29:27 2014
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct s {};
+
+// FIXME: should warn that declaration attribute in type position is
+// being applied to the declaration instead?
+struct s __attribute__((used)) foo;
+
+// FIXME: Should warn that type attribute in declaration position is
+// being applied to the type instead?
+struct s  *bar __attribute__((address_space(1)));
+
+// Should not warn because type attribute is in type position.
+struct s *__attribute__((address_space(1))) baz;
+
+// Should not warn because declaration attribute is in declaration position.
+struct s *quux __attribute__((used));





More information about the cfe-commits mailing list