diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 4e542ee91a8b3..b99dd441db255 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -589,6 +589,7 @@ Bug Fixes to C++ Support - Fixed an assertion failure in range calculations for conditional throw expressions. (#GH111854) - Clang now correctly ignores previous partial specializations of member templates explicitly specialized for an implicitly instantiated class template specialization. (#GH51051) +- Fixed an assertion failure caused by invalid enum forward declarations. (#GH112208) Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c56883a80c1c5..0cdace25aa792 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -17955,6 +17955,8 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, << Name; Invalid = true; } + if (TUK == TagUseKind::Declaration) + Invalid = true; } else if (!PrevDecl) { Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New); } diff --git a/clang/test/SemaCXX/enum.cpp b/clang/test/SemaCXX/enum.cpp index 9c398cc8da886..44042d8bf5cfc 100644 --- a/clang/test/SemaCXX/enum.cpp +++ b/clang/test/SemaCXX/enum.cpp @@ -143,3 +143,11 @@ struct PR28903 { }) }; }; + +namespace GH112208 { +class C { + enum E { e = 0 }; + void f(int, enum E;); // expected-error {{ISO C++ forbids forward references to 'enum' types}} \ + // expected-error {{unexpected ';' before ')'}} +}; +}