[cfe-commits] r95367 - in /cfe/trunk: lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp test/SemaCXX/overloaded-operator-decl.cpp

Douglas Gregor dgregor at apple.com
Thu Feb 4 22:12:43 PST 2010


Author: dgregor
Date: Fri Feb  5 00:12:42 2010
New Revision: 95367

URL: http://llvm.org/viewvc/llvm-project?rev=95367&view=rev
Log:
A function declarator with a non-identifier name in an anonymous class
is a constructor for that class, right? Fixes PR6238. 

Modified:
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/overloaded-operator-decl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=95367&r1=95366&r2=95367&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb  5 00:12:42 2010
@@ -2737,7 +2737,8 @@
     // (The parser checks for a return type and makes the declarator a
     // constructor if it has no return type).
     // must have an invalid constructor that has a return type
-    if (Name.getAsIdentifierInfo() == cast<CXXRecordDecl>(DC)->getIdentifier()){
+    if (Name.getAsIdentifierInfo() &&
+        Name.getAsIdentifierInfo() == cast<CXXRecordDecl>(DC)->getIdentifier()){
       Diag(D.getIdentifierLoc(), diag::err_constructor_return_type)
         << SourceRange(D.getDeclSpec().getTypeSpecTypeLoc())
         << SourceRange(D.getIdentifierLoc());

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=95367&r1=95366&r2=95367&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb  5 00:12:42 2010
@@ -433,7 +433,7 @@
   } else
     CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
 
-  if (CurDecl)
+  if (CurDecl && CurDecl->getIdentifier())
     return &II == CurDecl->getIdentifier();
   else
     return false;

Modified: cfe/trunk/test/SemaCXX/overloaded-operator-decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-operator-decl.cpp?rev=95367&r1=95366&r2=95367&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/overloaded-operator-decl.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-operator-decl.cpp Fri Feb  5 00:12:42 2010
@@ -37,3 +37,9 @@
 X operator++(X&, FLOAT); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'FLOAT' (aka 'float'))}}
 
 int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}}
+
+namespace PR6238 {
+  static struct {
+    void operator()();
+  } plus;
+}





More information about the cfe-commits mailing list