llvm-project/clang/test/Parser/cxx20-using-enum.cpp
Shafik Yaghmour aa7ce60536 [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
2022-08-27 15:18:36 -07:00

13 lines
414 B
C++

// RUN: %clang_cc1 -std=c++20 -verify %s
namespace GH57347 {
namespace A {}
void f() {
using enum A::+; // expected-error {{expected identifier}}
using enum; // expected-error {{expected identifier or '{'}}
using enum class; // expected-error {{expected identifier or '{'}}
using enum : blah; // expected-error {{unknown type name 'blah'}} expected-error {{unnamed enumeration must be a definition}}
}
}