]> granicus.if.org Git - clang/commitdiff
In ActOnCXXTypeConstructExpr, check that the type is complete and non-abstract before...
authorAnders Carlsson <andersca@mac.com>
Thu, 27 Aug 2009 03:53:50 +0000 (03:53 +0000)
committerAnders Carlsson <andersca@mac.com>
Thu, 27 Aug 2009 03:53:50 +0000 (03:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80200 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
lib/Sema/SemaExprCXX.cpp

index d09d054c08211c30f1ecb2329699c7249eb79156..abcb9634bacd7dc1e025c6a94712d59f2146fd10 100644 (file)
@@ -513,7 +513,10 @@ public:
   /// hasUserDeclaredConstructor - Whether this class has any
   /// user-declared constructors. When true, a default constructor
   /// will not be implicitly declared.
-  bool hasUserDeclaredConstructor() const { return UserDeclaredConstructor; }
+  bool hasUserDeclaredConstructor() const { 
+    assert(isDefinition() && "Incomplete record decl!");
+    return UserDeclaredConstructor;
+  }
 
   /// hasUserDeclaredCopyConstructor - Whether this class has a
   /// user-declared copy constructor. When false, a copy constructor
index 22d01ec0c805c627bc98ae091d725c431daf7a39..a4c3b0dd59459281e8bf1fd1019cb4d36e72133f 100644 (file)
@@ -203,7 +203,20 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
                                                     RParenLoc));
   }
 
-
+  if (Ty->isArrayType())
+    return ExprError(Diag(TyBeginLoc,
+                          diag::err_value_init_for_array_type) << FullRange);
+  if (!Ty->isVoidType() &&
+      RequireCompleteType(TyBeginLoc, Ty,
+                          PDiag(diag::err_invalid_incomplete_type_use)
+                            << FullRange))
+    return ExprError();
+  
+  if (RequireNonAbstractType(TyBeginLoc, Ty,
+                             diag::err_allocation_of_abstract_type))
+    return ExprError();
+  
+  
   // C++ [expr.type.conv]p1:
   // If the expression list is a single expression, the type conversion
   // expression is equivalent (in definedness, and if defined in meaning) to the
@@ -267,19 +280,6 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
   // complete object type or the (possibly cv-qualified) void type, creates an
   // rvalue of the specified type, which is value-initialized.
   //
-  if (Ty->isArrayType())
-    return ExprError(Diag(TyBeginLoc,
-                          diag::err_value_init_for_array_type) << FullRange);
-  if (!Ty->isDependentType() && !Ty->isVoidType() &&
-      RequireCompleteType(TyBeginLoc, Ty,
-                          PDiag(diag::err_invalid_incomplete_type_use)
-                            << FullRange))
-    return ExprError();
-
-  if (RequireNonAbstractType(TyBeginLoc, Ty,
-                             diag::err_allocation_of_abstract_type))
-    return ExprError();
-  
   exprs.release();
   return Owned(new (Context) CXXZeroInitValueExpr(Ty, TyBeginLoc, RParenLoc));
 }