Fix crash when checking a dependently-typed reference that is

initialized from a non-value-dependent initializer.

llvm-svn: 363622
This commit is contained in:
Richard Smith 2019-06-17 21:46:17 +00:00
parent 689509edab
commit 94bc88ebf4
2 changed files with 9 additions and 1 deletions

View File

@ -2282,7 +2282,7 @@ bool VarDecl::isUsableInConstantExpressions(ASTContext &Context) const {
// declaration is encountered...
const VarDecl *DefVD = nullptr;
const Expr *Init = getAnyInitializer(DefVD);
if (!Init || Init->isValueDependent())
if (!Init || Init->isValueDependent() || getType()->isDependentType())
return false;
// ... if it is a constexpr variable, or it is of reference type or of
// const-qualified integral or enumeration type, ...

View File

@ -63,6 +63,14 @@ namespace test5 {
};
}
namespace test6 {
template<typename T> T f() {
const T &v(0);
return v;
}
int use = f<int>();
}
namespace PR8795 {
template <class _CharT> int test(_CharT t)
{