summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-06-20 19:49:13 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-06-20 19:49:13 +0000
commit07ed9cfc3e8db2d6acf2412bc138d61e88ccc5f5 (patch)
tree4c38e7c51bc560d6994f559fb0a15cd08130f26d /clang/lib/Sema/Sema.cpp
parent97dc622ab3f77d877ee302908dec20d9dbddfe2b (diff)
downloadbcm5719-llvm-07ed9cfc3e8db2d6acf2412bc138d61e88ccc5f5.tar.gz
bcm5719-llvm-07ed9cfc3e8db2d6acf2412bc138d61e88ccc5f5.zip
Fix crash and rejects-valid when a later template parameter or default
template argument contains a backreference to a dependently-typed earlier parameter. In a case like: template<typename T, T A, decltype(A) = A> struct X {}; template<typename U> auto Y = X<U, 0>(); we previously treated both references to `A` in the third parameter as being of type `int` when checking the template-id in `Y`. That`s wrong; the type of `A` in these contexts is the dependent type `U`. When we encounter a non-type template argument that we can't convert to the parameter type because of type-dependence, we now insert a dependent conversion node so that the SubstNonTypeTemplateParmExpr for the template argument will have the parameter's type rather than whatever type the argument had. llvm-svn: 363972
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index d7a05e731ea..3941643893a 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -491,6 +491,7 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
default:
llvm_unreachable("can't implicitly cast lvalue to rvalue with this cast "
"kind");
+ case CK_Dependent:
case CK_LValueToRValue:
case CK_ArrayToPointerDecay:
case CK_FunctionToPointerDecay:
@@ -499,7 +500,8 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty,
break;
}
}
- assert((VK == VK_RValue || !E->isRValue()) && "can't cast rvalue to lvalue");
+ assert((VK == VK_RValue || Kind == CK_Dependent || !E->isRValue()) &&
+ "can't cast rvalue to lvalue");
#endif
diagnoseNullableToNonnullConversion(Ty, E->getType(), E->getBeginLoc());
OpenPOWER on IntegriCloud