r190111 - C++11 attributes after 'constructor-name (' unambiguously signal that we have a

Richard Smith richard-llvm at metafoo.co.uk
Thu Sep 5 17:12:20 PDT 2013


Author: rsmith
Date: Thu Sep  5 19:12:20 2013
New Revision: 190111

URL: http://llvm.org/viewvc/llvm-project?rev=190111&view=rev
Log:
C++11 attributes after 'constructor-name (' unambiguously signal that we have a
constructor.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/Parser/cxx0x-attributes.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=190111&r1=190110&r2=190111&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Sep  5 19:12:20 2013
@@ -4234,6 +4234,15 @@ bool Parser::isConstructorDeclarator() {
     return true;
   }
 
+  // A C++11 attribute here signals that we have a constructor, and is an
+  // attribute on the first constructor parameter.
+  if (getLangOpts().CPlusPlus11 &&
+      isCXX11AttributeSpecifier(/*Disambiguate*/ false,
+                                /*OuterMightBeMessageSend*/ true)) {
+    TPA.Revert();
+    return true;
+  }
+
   // If we need to, enter the specified scope.
   DeclaratorScopeObj DeclScopeObj(*this, SS);
   if (SS.isSet() && Actions.ShouldEnterDeclaratorScope(getCurScope(), SS))

Modified: cfe/trunk/test/Parser/cxx0x-attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx0x-attributes.cpp?rev=190111&r1=190110&r2=190111&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx0x-attributes.cpp (original)
+++ cfe/trunk/test/Parser/cxx0x-attributes.cpp Thu Sep  5 19:12:20 2013
@@ -281,3 +281,8 @@ int v5()[[gnu::unused]]; // expected-war
 [[attribute_declaration]]; // expected-warning {{unknown attribute 'attribute_declaration' ignored}}
 [[noreturn]]; // expected-error {{'noreturn' attribute only applies to functions and methods}}
 [[carries_dependency]]; // expected-error {{'carries_dependency' attribute only applies to functions, methods, and parameters}}
+
+class A {
+  A([[gnu::unused]] int a);
+};
+A::A([[gnu::unused]] int a) {}





More information about the cfe-commits mailing list