]> granicus.if.org Git - clang/commitdiff
Switch compound literals over to InitializationSequence.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 22 Dec 2009 02:35:53 +0000 (02:35 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 22 Dec 2009 02:35:53 +0000 (02:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91882 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
lib/Sema/SemaInit.cpp

index d45179e94c84620a8df0e78c61dddbd2658e24f2..181d6d1c8f8a24a4a8581f1d87a6a221e2b09bad 100644 (file)
@@ -3478,15 +3478,22 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, TypeTy *Ty,
   InitializationKind Kind
     = InitializationKind::CreateCast(SourceRange(LParenLoc, RParenLoc), 
                                      /*IsCStyleCast=*/true);
-  if (CheckInitializerTypes(literalExpr, literalType, Entity, Kind))
+  InitializationSequence InitSeq(*this, Entity, Kind, &literalExpr, 1);
+  OwningExprResult Result = InitSeq.Perform(*this, Entity, Kind,
+                                   MultiExprArg(*this, (void**)&literalExpr, 1),
+                                            &literalType);
+  if (Result.isInvalid())
     return ExprError();
+  InitExpr.release();
+  literalExpr = static_cast<Expr*>(Result.get());
 
   bool isFileScope = getCurFunctionOrMethodDecl() == 0;
   if (isFileScope) { // 6.5.2.5p3
     if (CheckForConstantInitializer(literalExpr, literalType))
       return ExprError();
   }
-  InitExpr.release();
+
+  Result.release();
   
   // FIXME: Store the TInfo to preserve type information better.
   return Owned(new (Context) CompoundLiteralExpr(LParenLoc, literalType,
index c7a2769c448655ea9352fbd93ac31ff88078c1d0..cc22e7458a43428beda824ec98d0878d14a23166 100644 (file)
@@ -3186,7 +3186,7 @@ InitializationSequence::Perform(Sema &S,
       }
     }
 
-    if (Kind.getKind() == InitializationKind::IK_Copy)
+    if (Kind.getKind() == InitializationKind::IK_Copy || Kind.isExplicitCast())
       return Sema::OwningExprResult(S, Args.release()[0]);
 
     unsigned NumArgs = Args.size();