[cfe-commits] r84365 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/SemaTemplate/fun-template-def.cpp test/SemaTemplate/instantiate-expr-2.cpp

Douglas Gregor dgregor at apple.com
Sat Oct 17 14:40:42 PDT 2009


Author: dgregor
Date: Sat Oct 17 16:40:42 2009
New Revision: 84365

URL: http://llvm.org/viewvc/llvm-project?rev=84365&view=rev
Log:
When type-checking a C++ "new" expression, don't type-check the actual 
initialization if any of the constructor/initialization arguments are
type-dependent. Fixes PR5224.

Modified:
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/test/SemaTemplate/fun-template-def.cpp
    cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Sat Oct 17 16:40:42 2009
@@ -418,6 +418,7 @@
   FunctionDecl *OperatorDelete = 0;
   Expr **PlaceArgs = (Expr**)PlacementArgs.get();
   unsigned NumPlaceArgs = PlacementArgs.size();
+    
   if (!AllocType->isDependentType() &&
       !Expr::hasAnyTypeDependentArguments(PlaceArgs, NumPlaceArgs) &&
       FindAllocationFunctions(StartLoc,
@@ -448,7 +449,9 @@
   Expr **ConsArgs = (Expr**)ConstructorArgs.get();
   const RecordType *RT;
   unsigned NumConsArgs = ConstructorArgs.size();
-  if (AllocType->isDependentType()) {
+  
+  if (AllocType->isDependentType() || 
+      Expr::hasAnyTypeDependentArguments(ConsArgs, NumConsArgs)) {
     // Skip all the checks.
   } else if ((RT = AllocType->getAs<RecordType>()) &&
              !AllocType->isAggregateType()) {
@@ -491,7 +494,7 @@
   }
 
   // FIXME: Also check that the destructor is accessible. (C++ 5.3.4p16)
-
+  
   PlacementArgs.release();
   ConstructorArgs.release();
   ArraySizeE.release();

Modified: cfe/trunk/test/SemaTemplate/fun-template-def.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/fun-template-def.cpp?rev=84365&r1=84364&r2=84365&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/fun-template-def.cpp (original)
+++ cfe/trunk/test/SemaTemplate/fun-template-def.cpp Sat Oct 17 16:40:42 2009
@@ -35,7 +35,7 @@
     dynamic_cast<U>(const_cast<T>(i1)))));
 
   new U(i1, t1);
-  new int(t1, u1); // expected-error {{initializer of a builtin type can only take one argument}}
+  new int(t1, u1);
   new (t1, u1) int;
   delete t1;
 

Modified: cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp?rev=84365&r1=84364&r2=84365&view=diff

==============================================================================
--- cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiate-expr-2.cpp Sat Oct 17 16:40:42 2009
@@ -178,3 +178,18 @@
   
   template class A<int>;
 }
+
+namespace N12 {
+  // PR5224
+  template<typename T>
+  struct A { typedef int t0; };
+  
+  struct C  {
+    C(int);
+    
+    template<typename T>
+    static C *f0(T a0) {return new C((typename A<T>::t0) 1);   }
+  };
+
+  void f0(int **a) { C::f0(a); }
+}





More information about the cfe-commits mailing list