[PATCH] D132695: [Clang] Avoid crashes when parsing using enum declarations

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 25 12:01:44 PDT 2022


shafik created this revision.
shafik added reviewers: erichkeane, aaron.ballman.
Herald added a project: All.
shafik requested review of this revision.

In `Parser::ParseUsingDeclaration(...)` when we call `ParseEnumSpecifier(...)` it is not calling `SetTypeSpecError()` on `DS` when it detects an error. That means that `DS` is left set to `TST_unspecified`. When we then pass `DS` into `Sema::ActOnUsingEnumDeclaration(...)` we hit an `llvm_unreachable(...)` since it expects it to be one of three states `TST_error`, `TST_enum` or `TST_typename`.

This fixes https://github.com/llvm/llvm-project/issues/57347


https://reviews.llvm.org/D132695

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/Parser/cxx20-using-enum.cpp
  clang/test/Parser/recovery.cpp
  clang/test/Sema/enum.c
  clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
  clang/test/SemaCXX/enum-scoped.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132695.455674.patch
Type: text/x-patch
Size: 6415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220825/032bf430/attachment.bin>


More information about the cfe-commits mailing list