[cfe-commits] r107378 - in /cfe/trunk: lib/Sema/Sema.h lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp test/CodeGenCXX/destructors.cpp test/SemaCXX/destructor.cpp www/compatibility.html

Douglas Gregor dgregor at apple.com
Wed Jun 30 20:28:43 PDT 2010


Author: dgregor
Date: Wed Jun 30 22:28:42 2010
New Revision: 107378

URL: http://llvm.org/viewvc/llvm-project?rev=107378&view=rev
Log:
Revert r107374, which broke bootstrap.

Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/CodeGenCXX/destructors.cpp
    cfe/trunk/test/SemaCXX/destructor.cpp
    cfe/trunk/www/compatibility.html

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=107378&r1=107377&r2=107378&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Jun 30 22:28:42 2010
@@ -2672,7 +2672,7 @@
   QualType CheckConstructorDeclarator(Declarator &D, QualType R,
                                       FunctionDecl::StorageClass& SC);
   void CheckConstructor(CXXConstructorDecl *Constructor);
-  QualType CheckDestructorDeclarator(Declarator &D, QualType R,
+  QualType CheckDestructorDeclarator(Declarator &D,
                                      FunctionDecl::StorageClass& SC);
   bool CheckDestructor(CXXDestructorDecl *Destructor);
   void CheckConversionDeclarator(Declarator &D, QualType &R,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=107378&r1=107377&r2=107378&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jun 30 22:28:42 2010
@@ -3023,7 +3023,7 @@
   } else if (Name.getNameKind() == DeclarationName::CXXDestructorName) {
     // This is a C++ destructor declaration.
     if (DC->isRecord()) {
-      R = CheckDestructorDeclarator(D, R, SC);
+      R = CheckDestructorDeclarator(D, SC);
 
       NewFD = CXXDestructorDecl::Create(Context,
                                         cast<CXXRecordDecl>(DC),

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=107378&r1=107377&r2=107378&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jun 30 22:28:42 2010
@@ -2990,7 +2990,9 @@
 
   // Rebuild the function type "R" without any type qualifiers (in
   // case any of the errors above fired) and with "void" as the
-  // return type, since constructors don't have return types.
+  // return type, since constructors don't have return types. We
+  // *always* have to do this, because GetTypeForDeclarator will
+  // put in a result type of "int" when none was specified.
   const FunctionProtoType *Proto = R->getAs<FunctionProtoType>();
   return Context.getFunctionType(Context.VoidTy, Proto->arg_type_begin(),
                                  Proto->getNumArgs(),
@@ -3085,7 +3087,7 @@
 /// emit diagnostics and set the declarator to invalid.  Even if this happens,
 /// will be updated to reflect a well-formed type for the destructor and
 /// returned.
-QualType Sema::CheckDestructorDeclarator(Declarator &D, QualType R,
+QualType Sema::CheckDestructorDeclarator(Declarator &D,
                                          FunctionDecl::StorageClass& SC) {
   // C++ [class.dtor]p1:
   //   [...] A typedef-name that names a class is a class-name
@@ -3093,9 +3095,11 @@
   //   be used as the identifier in the declarator for a destructor
   //   declaration.
   QualType DeclaratorType = GetTypeFromParser(D.getName().DestructorName);
-  if (isa<TypedefType>(DeclaratorType))
+  if (isa<TypedefType>(DeclaratorType)) {
     Diag(D.getIdentifierLoc(), diag::err_destructor_typedef_name)
       << DeclaratorType;
+    D.setInvalidType();
+  }
 
   // C++ [class.dtor]p2:
   //   A destructor is used to destroy objects of its class type. A
@@ -3109,10 +3113,9 @@
     if (!D.isInvalidType())
       Diag(D.getIdentifierLoc(), diag::err_destructor_cannot_be)
         << "static" << SourceRange(D.getDeclSpec().getStorageClassSpecLoc())
-        << SourceRange(D.getIdentifierLoc())
-        << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
-    
+        << SourceRange(D.getIdentifierLoc());
     SC = FunctionDecl::None;
+    D.setInvalidType();
   }
   if (D.getDeclSpec().hasTypeSpecifier() && !D.isInvalidType()) {
     // Destructors don't have return types, but the parser will
@@ -3160,17 +3163,11 @@
   // Rebuild the function type "R" without any type qualifiers or
   // parameters (in case any of the errors above fired) and with
   // "void" as the return type, since destructors don't have return
-  // types. 
-  const FunctionProtoType *Proto = R->getAs<FunctionProtoType>();
-  if (!Proto)
-    return QualType();
-  
+  // types. We *always* have to do this, because GetTypeForDeclarator
+  // will put in a result type of "int" when none was specified.
+  // FIXME: Exceptions!
   return Context.getFunctionType(Context.VoidTy, 0, 0, false, 0,
-                                 Proto->hasExceptionSpec(),
-                                 Proto->hasAnyExceptionSpec(),
-                                 Proto->getNumExceptions(),
-                                 Proto->exception_begin(),
-                                 Proto->getExtInfo());
+                                 false, false, 0, 0, FunctionType::ExtInfo());
 }
 
 /// CheckConversionDeclarator - Called by ActOnDeclarator to check the

Modified: cfe/trunk/test/CodeGenCXX/destructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/destructors.cpp?rev=107378&r1=107377&r2=107378&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/destructors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/destructors.cpp Wed Jun 30 22:28:42 2010
@@ -32,17 +32,6 @@
 
 C::~C() { }
 
-namespace PR7526 {
-  extern void foo();
-  struct allocator {
-    ~allocator() throw();
-  };
-
-  // CHECK: define void @_ZN6PR75269allocatorD2Ev
-  // CHECK: call void @__cxa_call_unexpected
-  allocator::~allocator() throw() { foo(); }
-}
-
 // PR5084
 template<typename T>
 class A1 {

Modified: cfe/trunk/test/SemaCXX/destructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/destructor.cpp?rev=107378&r1=107377&r2=107378&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/destructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/destructor.cpp Wed Jun 30 22:28:42 2010
@@ -19,9 +19,7 @@
     // expected-error{{type qualifier is not allowed on this function}} \
     // expected-error{{destructor cannot be declared 'static'}}  \
     // expected-error{{destructor cannot have any parameters}}   \
-    // expected-error{{destructor cannot be variadic}} \
-    // expected-error{{destructor cannot have a return type}} \
-    // expected-error{{'const' qualifier is not allowed on a destructor}}
+    // expected-error{{destructor cannot be variadic}}
 };
 
 struct D2 {

Modified: cfe/trunk/www/compatibility.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/compatibility.html?rev=107378&r1=107377&r2=107378&view=diff
==============================================================================
--- cfe/trunk/www/compatibility.html (original)
+++ cfe/trunk/www/compatibility.html Wed Jun 30 22:28:42 2010
@@ -590,8 +590,9 @@
 downcast.mm:6:3: error: no matching function for call to 'f'
   f(base);
   ^
-downcast.mm:4:6: note: candidate function not viable: cannot convert from
-      superclass 'Base *' to subclass 'Derived *' for 1st argument
+downcast.mm:4:6: note: candidate function not viable: cannot convert from base
+      class pointer 'Base *' to derived class pointer 'Derived *' for 1st
+      argument
 void f(Derived *);
      ^
 </pre>





More information about the cfe-commits mailing list