r193582 - Treat [[gnu::__const]] the same as [[gnu::const]]. GCC's tokenizer can't tell

Nick Lewycky nicholas at mxc.ca
Mon Oct 28 20:33:58 PDT 2013


Author: nicholas
Date: Mon Oct 28 22:33:57 2013
New Revision: 193582

URL: http://llvm.org/viewvc/llvm-project?rev=193582&view=rev
Log:
Treat [[gnu::__const]] the same as [[gnu::const]]. GCC's tokenizer can't tell
the difference.

Modified:
    cfe/trunk/include/clang/Basic/Attr.td
    cfe/trunk/test/Parser/cxx0x-attributes.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=193582&r1=193581&r2=193582&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Oct 28 22:33:57 2013
@@ -314,7 +314,8 @@ def Common : InheritableAttr {
 }
 
 def Const : InheritableAttr {
-  let Spellings = [GNU<"const">, GNU<"__const">, CXX11<"gnu", "const">];
+  let Spellings = [GNU<"const">, GNU<"__const">,
+                   CXX11<"gnu", "const">, CXX11<"gnu", "__const">];
 }
 
 def Constructor : InheritableAttr {

Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=193582&r1=193581&r2=193582&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Mon Oct 28 22:33:57 2013
@@ -304,3 +304,11 @@ class A {
   A([[gnu::unused]] int a);
 };
 A::A([[gnu::unused]] int a) {}
+
+namespace GccConst {
+  // GCC's tokenizer treats const and __const as the same token.
+  [[gnu::const]] int *f1();
+  [[gnu::__const]] int *f2();
+  void f(const int *);
+  void g() { f(f1()); f(f2()); }
+}





More information about the cfe-commits mailing list