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,11 @@ }; // 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}} +template +class ABC {}; +class T { + ABC abc; +}; +static_assert(sizeof(T) == 1, "No valid members");