]> granicus.if.org Git - clang/commitdiff
C++11 attributes after 'constructor-name (' unambiguously signal that we have a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 6 Sep 2013 00:12:20 +0000 (00:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 6 Sep 2013 00:12:20 +0000 (00:12 +0000)
constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190111 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
test/Parser/cxx0x-attributes.cpp

index 48a30a15b1bc40511e11f5f302d303a502b4e1c3..6d7ab979b08adfe5a3c08f303cc43417d7a12ba2 100644 (file)
@@ -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))
index 5e4e388a264520a3a583c903b52b8754fb253434..d7ca187a5f4cfc4f99e0fd324baa52dba0f0ce52 100644 (file)
@@ -281,3 +281,8 @@ int v5()[[gnu::unused]]; // expected-warning {{attribute 'unused' ignored}}
 [[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) {}