diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -466,10 +466,12 @@ : Var->getType()->isIntegralOrEnumerationType()) && (Var->getType().isConstQualified() || Var->getType()->isReferenceType())) { - if (const Expr *Init = Var->getAnyInitializer()) - if (Init->isValueDependent()) { + if (const Expr *Init = Var->getAnyInitializer()) { + if (Init->isValueDependent()) Deps |= ExprDependence::ValueInstantiation; - } + if (Init->containsErrors()) + Deps |= ExprDependence::Error; + } } // (VD) - FIXME: Missing from the standard: diff --git a/clang/test/Sema/invalid-member.cpp b/clang/test/Sema/invalid-member.cpp --- a/clang/test/Sema/invalid-member.cpp +++ b/clang/test/Sema/invalid-member.cpp @@ -19,3 +19,10 @@ }; // Should be able to evaluate sizeof without crashing. static_assert(sizeof(Z) == 1, "No valid members"); + +constexpr int N = undef; // expected-error {{use of undeclared identifier}} + +class T { + decltype(N) member; +}; +static_assert(sizeof(T) == 1, "No valid members"); diff --git a/clang/test/SemaCXX/invalid-template-base-specifier.cpp b/clang/test/SemaCXX/invalid-template-base-specifier.cpp --- a/clang/test/SemaCXX/invalid-template-base-specifier.cpp +++ b/clang/test/SemaCXX/invalid-template-base-specifier.cpp @@ -26,3 +26,10 @@ }; void test3() { Crash3(); } // expected-note {{in instantiation of template class}} + +constexpr int N = undef; // expected-error {{use of undeclared identifier}} + +class Crash4 : decltype(N) { +}; + +static_assert(sizeof(Crash4) == 1, "");