From: Richard Smith Date: Fri, 11 Aug 2017 02:04:19 +0000 (+0000) Subject: PR33489: A function-style cast to a deduced class template specialization type is... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b411aeb89996d2eca4b300c5ceabb8b180ef7e67;p=clang PR33489: A function-style cast to a deduced class template specialization type is type-dependent if it can't be resolved due to a type-dependent argument. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310691 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 6713fca045..fe45b5e47f 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -1052,7 +1052,9 @@ CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type, :Type->getType()->isRValueReferenceType()? VK_XValue :VK_RValue), OK_Ordinary, - Type->getType()->isDependentType(), true, true, + Type->getType()->isDependentType() || + Type->getType()->getContainedDeducedType(), + true, true, Type->getType()->containsUnexpandedParameterPack()), Type(Type), LParenLoc(LParenLoc), diff --git a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp index 668c242802..9232a8b6eb 100644 --- a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp @@ -286,6 +286,29 @@ namespace tuple_tests { } } +namespace dependent { + template struct X { + X(T); + }; + template int Var(T t) { + X x(t); + return X(x) + 1; // expected-error {{invalid operands}} + } + template int Cast(T t) { + return X(X(t)) + 1; // expected-error {{invalid operands}} + } + template int New(T t) { + return X(new X(t)) + 1; // expected-error {{invalid operands}} + }; + template int Var(float); // expected-note {{instantiation of}} + template int Cast(float); // expected-note {{instantiation of}} + template int New(float); // expected-note {{instantiation of}} + template int operator+(X, int); + template int Var(int); + template int Cast(int); + template int New(int); +} + #else // expected-no-diagnostics