Skip to content

Commit 94bc88e

Browse files
committed
Fix crash when checking a dependently-typed reference that is
initialized from a non-value-dependent initializer. llvm-svn: 363622
1 parent 689509e commit 94bc88e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,7 @@ bool VarDecl::isUsableInConstantExpressions(ASTContext &Context) const {
22822282
// declaration is encountered...
22832283
const VarDecl *DefVD = nullptr;
22842284
const Expr *Init = getAnyInitializer(DefVD);
2285-
if (!Init || Init->isValueDependent())
2285+
if (!Init || Init->isValueDependent() || getType()->isDependentType())
22862286
return false;
22872287
// ... if it is a constexpr variable, or it is of reference type or of
22882288
// const-qualified integral or enumeration type, ...

clang/test/SemaTemplate/dependent-expr.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ namespace test5 {
6363
};
6464
}
6565

66+
namespace test6 {
67+
template<typename T> T f() {
68+
const T &v(0);
69+
return v;
70+
}
71+
int use = f<int>();
72+
}
73+
6674
namespace PR8795 {
6775
template <class _CharT> int test(_CharT t)
6876
{

0 commit comments

Comments
 (0)