= SemaRef.SubstExpr(D->getInit(), TemplateArgs);
if (Init.isInvalid())
Var->setInvalidDecl();
+ else if (!D->getType()->isDependentType() &&
+ !D->getInit()->isTypeDependent() &&
+ !D->getInit()->isValueDependent()) {
+ // If neither the declaration's type nor its initializer are dependent,
+ // we don't want to redo all the checking, especially since the
+ // initializer might have been wrapped by a CXXConstructExpr since we did
+ // it the first time.
+ Var->setInit(SemaRef.Context, Init.takeAs<Expr>());
+ }
else if (ParenListExpr *PLE = dyn_cast<ParenListExpr>((Expr *)Init.get())) {
// FIXME: We're faking all of the comma locations, which is suboptimal.
// Do we even need these comma locations?
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// PR5426 - the non-dependent obj would be fully processed and wrapped in a
+// CXXConstructExpr at definition time, which would lead to a failure at
+// instantiation time.
+struct arg {
+ arg();
+};
+
+struct oldstylemove {
+ oldstylemove(oldstylemove&);
+ oldstylemove(const arg&);
+};
+
+template <typename T>
+void fn(T t, const arg& arg) {
+ oldstylemove obj(arg);
+}
+
+void test() {
+ fn(1, arg());
+}