[all-commits] [llvm/llvm-project] aa7ce6: [Clang] Avoid crashes when parsing using enum decl...

Shafik Yaghmour via All-commits all-commits at lists.llvm.org
Sat Aug 27 15:42:33 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: aa7ce60536a642e825d26d89b4a4347a36b63360
  Author: Shafik Yaghmour <shafik.yaghmour at intel.com>
  Date:   2022-08-27 (Sat, 27 Aug 2022)

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

  Log Message:
  [Clang] Avoid crashes when parsing using enum declarations

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

Differential Revision: https://reviews.llvm.org/D132695

More information about the All-commits mailing list