[cfe-commits] r144159 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaCXX/pseudo-destructors.cpp

Douglas Gregor dgregor at apple.com
Tue Nov 8 18:19:47 PST 2011


Author: dgregor
Date: Tue Nov  8 20:19:47 2011
New Revision: 144159

URL: http://llvm.org/viewvc/llvm-project?rev=144159&view=rev
Log:
Don't crash when transforming an ill-formed pseudo-destructor
expression. Fixes PR11339.

Modified:
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/SemaCXX/pseudo-destructors.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=144159&r1=144158&r2=144159&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Nov  8 20:19:47 2011
@@ -7218,7 +7218,7 @@
     if (!DestroyedTypeInfo)
       return ExprError();
     Destroyed = DestroyedTypeInfo;
-  } else if (ObjectType->isDependentType()) {
+  } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
     // We aren't likely to be able to resolve the identifier down to a type
     // now anyway, so just retain the identifier.
     Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),

Modified: cfe/trunk/test/SemaCXX/pseudo-destructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/pseudo-destructors.cpp?rev=144159&r1=144158&r2=144159&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/pseudo-destructors.cpp (original)
+++ cfe/trunk/test/SemaCXX/pseudo-destructors.cpp Tue Nov  8 20:19:47 2011
@@ -68,3 +68,12 @@
   x0.~X0();
 }
 
+namespace PR11339 {
+  template<class T>
+  void destroy(T* p) {
+    p->~T(); // ok
+    p->~oops(); // expected-error{{expected the class name after '~' to name a destructor}}
+  }
+
+  template void destroy(int*); // expected-note{{in instantiation of function template specialization}}
+}





More information about the cfe-commits mailing list