<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/118061>118061</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang-20 Crash: Invalid access specifier! UNREACHABLE executed at /root/llvm-project/clang/lib/AST/DeclCXX.cpp:3621!
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          iamanonymouscs
      </td>
    </tr>
</table>

<pre>
    ### Description
I encountered a crash in Clang-20 when compiling the following code snippet:

```cpp
struct {
    enum b {
        c = (struct d
};

struct d {
    // No content provided
};
```

```sh
$  clang++ -v
Ubuntu clang version 20.0.0 (++20241128033836+45b567be8d0d-1~exp1~20241128153857.2079)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-20/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64
```

###  Command

The compilation command used was:
```sh
clang++  -fno-rtlib-add-rpath  -fno-ident -O3 -ffast-math -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address test.cpp
```

### Error Message
```sh
<source>:3:22: error: expected ';' after struct
    3 |         c = (struct d
      |                      ^
 |                      ;
<source>:4:1: error: expected ')'
    4 | };
      | ^
<source>:3:13: note: to match this '('
    3 |         c = (struct d
      |             ^
<source>:4:1: error: expected expression
 4 | };
      | ^
<source>:6:8: error: 'd' redeclared with 'public' access
    6 | struct d {
      |        ^
Invalid access specifier!
UNREACHABLE executed at /root/llvm-project/clang/lib/AST/DeclCXX.cpp:3621!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fno-rtlib-add-rpath -fno-ident -O3 -ffast-math -Wall -Wextra -fno-strict-aliasing -fwrapv -g -fsanitize=address <source>
1.      <source>:6:10: current parser token '{'
2.      <source>:1:1: parsing struct/union/class body '(unnamed struct at <source>:1:1)'
 #0 0x0000000003c02b58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c02b58)
 #1 0x0000000003c0085c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c0085c)
 #2 0x0000000003b4df48 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007a2f65a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007a2f65a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007a2f65a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007a2f65a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000000003b5986a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b5986a)
 #8 0x000000000757bec9 clang::operator<<(clang::StreamingDiagnostic const&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x757bec9)
 #9 0x000000000671bece clang::Sema::SetMemberAccessSpecifier(clang::NamedDecl*, clang::NamedDecl*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x671bece)
#10 0x00000000068bf065 clang::Sema::ActOnTag(clang::Scope*, unsigned int, clang::TagUseKind, clang::SourceLocation, clang::CXXScopeSpec&, clang::IdentifierInfo*, clang::SourceLocation, clang::ParsedAttributesView const&, clang::AccessSpecifier, clang::SourceLocation, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&, bool&, clang::SourceLocation, bool, clang::ActionResult<clang::OpaquePtr<clang::QualType>, false>, bool, bool, clang::Sema::OffsetOfKind, clang::SkipBodyInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68bf065)
#11 0x00000000065a6040 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65a6040)
#12 0x000000000657b2f0 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x657b2f0)
#13 0x00000000065a048d clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65a048d)
#14 0x00000000065a2a41 clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&, clang::ParsedAttributes&, clang::TypeSpecifierType, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65a2a41)
#15 0x00000000065a4587 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65a4587)
#16 0x00000000065a6d33 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65a6d33)
#17 0x000000000657b2f0 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x657b2f0)
#18 0x0000000006538d04 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6538d04)
#19 0x000000000653976e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x653976e)
#20 0x0000000006540f03 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6540f03)
#21 0x0000000006541ded clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6541ded)
#22 0x0000000006542290 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6542290)
#23 0x00000000065342d2 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65342d2)
#24 0x00000000045898b8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45898b8)
#25 0x0000000004843f99 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4843f99)
#26 0x00000000047c3eae clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47c3eae)
#27 0x000000000492efae clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x492efae)
#28 0x0000000000caec91 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcaec91)
#29 0x0000000000ca681a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x00000000045ccac9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#31 0x0000000003b4e3f4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b4e3f4)
#32 0x00000000045cd0bf clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#33 0x000000000459339d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x459339d)
#34 0x000000000459448d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x459448d)
#35 0x000000000459b845 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x459b845)
#36 0x0000000000cabac3 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcabac3)
#37 0x0000000000b7f544 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb7f544)
#38 0x00007a2f65a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#39 0x00007a2f65a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#40 0x0000000000ca62ce _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xca62ce)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

The issue can also be reproduced on Compiler Explorer:https://godbolt.org/z/x1aEjGo5T
Please let me know if you need any more details.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW91X4ziW_2vMi45zbNlxnAceTICe6q1u2IKerjeOLF8nGmzJK8kQ5mH-9j2SnPiDEIoe0rNnZzgU5ejj6t7f_ZSlEKXYmgOce_MLb355Rlq9EfKckZpwwV9q0SqqznJRvJx7OHK_6BIUlazRTHAvyL4g4FS0XIOEAhFEJVEbxDhaVYSvfRyg5w1wREXdsIrxNdIbQKWoKvFsPlFRAFKcNQ1oL8q8wP4mgfulTeMFmdKypRp5iwsvyBBCCHhbo3zQYH4o8qJL5OG0G14YQotLL7pwRHfNg2kevvbwNfpVICq4Bq5RI8UTK2A8d8fNhDm1MZ9wjBA1onr4wsMXyH_yguy3vOW6de3oCaRigiMczIJZYDh0Q3GA4zDEaRBFaZR4-CKe5_NkkUNaBIUf_gO2TfiP3aBwHqXzxQwHi6WHl16Q3RO5tpChbZo8JLHfUL9ivN36a96a_o0EUqBaFFCZUY1QbGv0xZUmVQXFJZOm3cPXrZIevq5Ybv5WT7WPAw9f58yo91q0vECU8IIVRAP6abVCzJEg1gJek1hT6uHrjqueJXwdhp9NMPKC7A4qoBqKf57Sas9U3VaamSlRhmbGCuKgTuLhYm-OmFrL3m3QStQ14YVrv99A5xOWV_NsOlGroEDPRHW-MLK1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