]> granicus.if.org Git - clang/commitdiff
PR12688: ParseCXXClassMemberDeclaration's sometimes-null ThisDecl takes another
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 29 Apr 2012 07:31:09 +0000 (07:31 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 29 Apr 2012 07:31:09 +0000 (07:31 +0000)
victim. Don't crash if we have a delay-parsed exception specification for a
class member which is invalid in a way which precludes building a FunctionDecl.

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

lib/Parse/ParseDeclCXX.cpp
test/CXX/class/class.mem/p2.cpp

index 771388fd606ab1b56d55ab75e191d269123be800..27fed393d4f1d385ed62e8ed1e196fa8850de5b5 100644 (file)
@@ -2065,7 +2065,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
       DeclsInGroup.push_back(ThisDecl);
     }
     
-    if (DeclaratorInfo.isFunctionDeclarator() &&
+    if (ThisDecl && DeclaratorInfo.isFunctionDeclarator() &&
         DeclaratorInfo.getDeclSpec().getStorageClassSpec()
           != DeclSpec::SCS_typedef) {
       HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
index bf7b3d49c95e3fa346aa622d473f934c79c7977c..02ef9d7bbc33386765e6c0d576bffd4651265f4e 100644 (file)
@@ -73,3 +73,16 @@ namespace PR12629 {
   static_assert(!noexcept(S().h()), "");
   static_assert(noexcept(S::i()), "");
 }
+
+namespace PR12688 {
+  struct S {
+    // FIXME: Producing one error saying this can't have the same name
+    //        as the class because it's not a constructor, then producing
+    //        another error saying this can't have a return type because
+    //        it is a constructor, is redundant and inconsistent.
+    nonsense S() throw (more_nonsense); // \
+    // expected-error {{'nonsense'}} \
+    // expected-error {{has the same name as its class}} \
+    // expected-error {{constructor cannot have a return type}}
+  };
+}