When pulling apart an initializer that involves a CXXConstructExpr, do
not pick apart a CXXTemporaryObjectExpr because such an object
construction was explicitly written in the source code. Fixes PR6657.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99427 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 15a7946..7b0e88d 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -286,17 +286,19 @@
   }
 
   if (CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init)) {
-    if (InstantiateInitializationArguments(S,
-                                           Construct->getArgs(),
-                                           Construct->getNumArgs(),
-                                           TemplateArgs,
-                                           CommaLocs, NewArgs))
-      return true;
+    if (!isa<CXXTemporaryObjectExpr>(Construct)) {
+      if (InstantiateInitializationArguments(S,
+                                             Construct->getArgs(),
+                                             Construct->getNumArgs(),
+                                             TemplateArgs,
+                                             CommaLocs, NewArgs))
+        return true;
 
-    // FIXME: Fake locations!
-    LParenLoc = S.PP.getLocForEndOfToken(Init->getLocStart());
-    RParenLoc = CommaLocs.empty()? LParenLoc : CommaLocs.back();
-    return false;
+      // FIXME: Fake locations!
+      LParenLoc = S.PP.getLocForEndOfToken(Init->getLocStart());
+      RParenLoc = CommaLocs.empty()? LParenLoc : CommaLocs.back();
+      return false;
+    }
   }
  
   Sema::OwningExprResult Result = S.SubstExpr(Init, TemplateArgs);