sammccall created this revision. sammccall added reviewers: hokein, guopeilin. sammccall requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Fixes https://bugs.llvm.org/show_bug.cgi?id=51554 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D108451 Files: clang/lib/Sema/SemaDecl.cpp clang/test/Sema/enum.cpp Index: clang/test/Sema/enum.cpp =================================================================== --- /dev/null +++ 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}} Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ 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
Index: clang/test/Sema/enum.cpp =================================================================== --- /dev/null +++ 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}} Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits