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

    <tr>
        <th>Summary</th>
        <td>
            [clang] should not generate implicit declarations for dependent cases UNREACHABLE executed at /root/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:239!
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            crash-on-invalid,
            clang:frontend:fuzzer
      </td>
    </tr>

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

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

<pre>
    **This testcase is generated by a fuzzer.**

Compiler Explorer: [https://godbolt.org/z/5svjMfjvT](https://godbolt.org/z/5svjMfjvT)

This invalid code will crash on Clang Assertion Trunk:
```cpp
struct D { ~D() noexcept(A()); };
struct S {
  ~S(); 
  struct X {
 friend S::~S(); 
  };
  D t;
};
```

This seems to go back to clang-11.

Stack dump:
```
should not generate implicit declarations for dependent cases
UNREACHABLE executed at /root/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:239!
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 <source>
1.      <source>:8:2: current parser token ';'
2.      <source>:2:1: parsing struct/union/class body 'S'
 #0 0x0000000003bb4fc8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb4fc8)
 #1 0x0000000003bb2c8c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bb2c8c)
 #2 0x0000000003b00278 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f6e66242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f6e662969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x00007f6e66242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f6e662287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x0000000003b0bb4a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b0bb4a)
 #8 0x0000000006aba777 clang::Sema::ImplicitExceptionSpecification::CalledDecl(clang::SourceLocation, clang::CXXMethodDecl const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6aba777)
 #9 0x0000000006aba936 (anonymous namespace)::SpecialMemberExceptionSpecInfo::visitClassSubobject(clang::CXXRecordDecl*, llvm::PointerUnion<clang::CXXBaseSpecifier*, clang::FieldDecl*>, unsigned int) SemaDeclCXX.cpp:0:0
#10 0x0000000006b4e531 ComputeDefaultedSpecialMemberExceptionSpec(clang::Sema&, clang::SourceLocation, clang::CXXMethodDecl*, clang::CXXSpecialMemberKind, clang::Sema::InheritedConstructorInfo*) SemaDeclCXX.cpp:0:0
#11 0x0000000006b4ebfd clang::Sema::EvaluateImplicitExceptionSpec(clang::SourceLocation, clang::FunctionDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6b4ebfd)
#12 0x0000000006baebad clang::Sema::ResolveExceptionSpec(clang::SourceLocation, clang::FunctionProtoType const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6baebad)
#13 0x0000000006bb0456 clang::CheckEquivalentExceptionSpecImpl(clang::Sema&, clang::PartialDiagnostic const&, clang::PartialDiagnostic const&, clang::FunctionProtoType const*, clang::SourceLocation, clang::FunctionProtoType const*, clang::SourceLocation, bool*, bool*, bool, bool) SemaExceptionSpec.cpp:0:0
#14 0x0000000006bb4372 clang::Sema::CheckEquivalentExceptionSpec(clang::FunctionDecl*, clang::FunctionDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6bb4372)
#15 0x0000000006abbc03 clang::Sema::CheckDelayedMemberExceptionSpecs() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6abbc03)
#16 0x000000000668eabb clang::Parser::ParseLexedMemberInitializers(clang::Parser::ParsingClass&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x668eabb)
#17 0x00000000066df9cb clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66df9cb)
#18 0x00000000066e2003 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+++0x66e2003)
#19 0x00000000066b6800 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+++0x66b6800)
#20 0x0000000006674334 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6674334)
#21 0x0000000006674d9e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6674d9e)
#22 0x000000000667c533 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x667c533)
#23 0x000000000667d41d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x667d41d)
#24 0x000000000666f93a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x666f93a)
#25 0x0000000004529838 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4529838)
#26 0x00000000047e3f89 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47e3f89)
#27 0x0000000004762a7e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4762a7e)
#28 0x00000000048c972e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48c972e)
#29 0x0000000000cdd9cf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdd9cf)
#30 0x0000000000cd56da ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x000000000456d549 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
#32 0x0000000003b00724 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b00724)
#33 0x000000000456db3f 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
#34 0x000000000453343d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453343d)
#35 0x000000000453452d 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+++0x453452d)
#36 0x000000000453be55 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453be55)
#37 0x0000000000cda89f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcda89f)
#38 0x0000000000ba9b24 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xba9b24)
#39 0x00007f6e66229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#40 0x00007f6e66229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#41 0x0000000000cd518e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd518e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWsly47bWfhp6g5KKBCkOCy9kyU46f_cfV8u55Z0KBA8ltCmAAUC13Is8-y2A1ABqiJ1Yvbkpp02DwBm-MwIEUYotOMCtN7rzRtMb0uilkLev7BvhURqNbnJRvN56eOzh8dOSKaRBaUoUIKbQAjhIoqFA-SsiqGx-_AA5bCd7_tTzu38nYlWzCiS639SVkCC9cIy80d1S61p54djDDx5-WIgiF5UeCrnw8MMPDz-M1Prbl_Lb-skbTT2cvn06zg7ZW7kZX5OKFYiKAtB3VlWISqKWSHA0qQhfoLFSIDUTHD3Jhr8YPi2N2G9_aF23I0rLhmo0RV5yh_4yknk4Q1zAhkKtPZyO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