[cfe-commits] r155788 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/CXX/class/class.mem/p2.cpp

Richard Smith richard-llvm at metafoo.co.uk
Sun Apr 29 00:31:09 PDT 2012


Author: rsmith
Date: Sun Apr 29 02:31:09 2012
New Revision: 155788

URL: http://llvm.org/viewvc/llvm-project?rev=155788&view=rev
Log:
PR12688: ParseCXXClassMemberDeclaration's sometimes-null ThisDecl takes another
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.

Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/CXX/class/class.mem/p2.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=155788&r1=155787&r2=155788&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Sun Apr 29 02:31:09 2012
@@ -2065,7 +2065,7 @@
       DeclsInGroup.push_back(ThisDecl);
     }
     
-    if (DeclaratorInfo.isFunctionDeclarator() &&
+    if (ThisDecl && DeclaratorInfo.isFunctionDeclarator() &&
         DeclaratorInfo.getDeclSpec().getStorageClassSpec()
           != DeclSpec::SCS_typedef) {
       HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);

Modified: cfe/trunk/test/CXX/class/class.mem/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.mem/p2.cpp?rev=155788&r1=155787&r2=155788&view=diff
==============================================================================
--- cfe/trunk/test/CXX/class/class.mem/p2.cpp (original)
+++ cfe/trunk/test/CXX/class/class.mem/p2.cpp Sun Apr 29 02:31:09 2012
@@ -73,3 +73,16 @@
   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}}
+  };
+}





More information about the cfe-commits mailing list