diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -17748,7 +17748,8 @@ Val = DefaultLvalueConversion(Val).get(); if (Val) { - if (Enum->isDependentType() || Val->isTypeDependent()) + if (Enum->isDependentType() || Val->isTypeDependent() || + Val->containsErrors()) EltTy = Context.DependentTy; else { // FIXME: We don't allow folding in C++11 mode for an enum with a fixed diff --git a/clang/test/Sema/enum.cpp b/clang/test/Sema/enum.cpp new file mode 100644 --- /dev/null +++ b/clang/test/Sema/enum.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +enum Circular { // expected-note 2 {{not complete until the closing '}'}} + Circular_A = Circular(1), // expected-error {{'Circular' is an incomplete type}} + Circular_B = Circular(1) // expected-error {{'Circular' is an incomplete type}} +}; +// When initializers contain errors, enumerators are non-type-dependent zeros. +static_assert(Circular_A != 0, ""); // expected-error {{static_assert failed}} +static_assert(Circular_B != 0, ""); // expected-error {{static_assert failed}}