<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115308>115308</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Assertion `DD && "queried property of class with no definition"' failed. Crash at HasAccess(clang::Sema&, (anonymous namespace)::EffectiveContext const&, clang::CXXRecordDecl const*, clang::AccessSpecifier, (anonymous namespace)::AccessTarget const&)
</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/a4o6eoPb6](https://godbolt.org/z/a4o6eoPb6)
This invalid code will crash on both Clang Trunk and Clang Assertion Trunk.
```cpp
template<typename T>
class S {
protected:
F();
class bar;
class G : public bar {
bool foo() {
F();
}
};
};
```
It seems that this goes back to clang-3(or earlier).
Stack dump:
```
clang++: /root/llvm-project/clang/include/clang/AST/DeclCXX.h:465: clang::CXXRecordDecl::DefinitionData& clang::CXXRecordDecl::data() const: Assertion `DD && "queried property of class with no definition"' failed.
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:9: at annotation token
2. <source>:2:1: parsing struct/union/class body 'S'
3. <source>:7:18: parsing function body 'S::G::foo'
4. <source>:7:18: in compound statement ('{}')
#0 0x0000000003bf66c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bf66c8)
#1 0x0000000003bf43cc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bf43cc)
#2 0x0000000003b419c8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000079e466c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000079e466c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000079e466c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000079e466c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000079e466c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000079e466c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000068fdd9a (anonymous namespace)::ProtectedFriendContext::findFriendship(clang::CXXRecordDecl const*, unsigned int) SemaAccess.cpp:0:0
#10 0x00000000068fda2d (anonymous namespace)::ProtectedFriendContext::findFriendship(clang::CXXRecordDecl const*, unsigned int) SemaAccess.cpp:0:0
#11 0x00000000068ffdd5 HasAccess(clang::Sema&, (anonymous namespace)::EffectiveContext const&, clang::CXXRecordDecl const*, clang::AccessSpecifier, (anonymous namespace)::AccessTarget const&) SemaAccess.cpp:0:0
#12 0x00000000069006f4 IsAccessible(clang::Sema&, (anonymous namespace)::EffectiveContext const&, (anonymous namespace)::AccessTarget&) SemaAccess.cpp:0:0
#13 0x0000000006900c4e CheckEffectiveAccess(clang::Sema&, (anonymous namespace)::EffectiveContext const&, clang::SourceLocation, (anonymous namespace)::AccessTarget&) SemaAccess.cpp:0:0
#14 0x000000000690261c CheckAccess(clang::Sema&, clang::SourceLocation, (anonymous namespace)::AccessTarget&) SemaAccess.cpp:0:0
#15 0x0000000006906596 clang::Sema::CheckLookupAccess(clang::LookupResult const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6906596)
#16 0x000000000691c912 clang::LookupResult::~LookupResult() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x691c912)
#17 0x0000000006a7def4 clang::Sema::ActOnNameClassifiedAsOverloadSet(clang::Scope*, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6a7def4)
#18 0x0000000006794957 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6794957)
#19 0x0000000006794df7 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6794df7)
#20 0x0000000006794e89 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6794e89)
#21 0x00000000067998a9 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67998a9)
#22 0x000000000681c2e9 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x681c2e9)
#23 0x00000000068125ce clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68125ce)
#24 0x0000000006813520 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6813520)
#25 0x00000000068143e4 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x68143e4)
#26 0x0000000006815b9a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6815b9a)
#27 0x00000000067377c0 clang::Parser::ParseLexedMethodDef(clang::Parser::LexedMethod&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67377c0)
#28 0x000000000673716d clang::Parser::LateParsedClass::ParseLexedMethodDefs() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x673716d)
#29 0x00000000067374ad clang::Parser::ParseLexedMethodDefs(clang::Parser::ParsingClass&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67374ad)
#30 0x0000000006788c8e clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6788c8e)
#31 0x000000000678b2b3 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+++0x678b2b3)
#32 0x000000000675fab0 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+++0x675fab0)
#33 0x000000000682753a clang::Parser::ParseDeclarationAfterTemplate(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject&, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x682753a)
#34 0x0000000006834e5c clang::Parser::ParseTemplateDeclarationOrSpecialization(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (.part.0) ParseTemplate.cpp:0:0
#35 0x000000000683517a clang::Parser::ParseDeclarationStartingWithTemplate(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x683517a)
#36 0x00000000067667a3 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67667a3)
#37 0x00000000067257c7 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x67257c7)
#38 0x000000000672666d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x672666d)
#39 0x0000000006726b10 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6726b10)
#40 0x0000000006718b52 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6718b52)
#41 0x00000000045725c8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45725c8)
#42 0x000000000482d559 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x482d559)
#43 0x00000000047ac7ce clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47ac7ce)
#44 0x000000000491335e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x491335e)
#45 0x0000000000ce9aff cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce9aff)
#46 0x0000000000ce17ba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#47 0x00000000045b57c9 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
#48 0x0000000003b41e74 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b41e74)
#49 0x00000000045b5dbf 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
#50 0x000000000457c0ad clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x457c0ad)
#51 0x000000000457d19d 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+++0x457d19d)
#52 0x0000000004584555 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4584555)
#53 0x0000000000ce6999 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce6999)
#54 0x0000000000bb3494 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbb3494)
#55 0x000079e466c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#56 0x000079e466c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#57 0x0000000000ce126e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce126e)
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/eJzkW11z2yq3_jXKDWOPhb4vcuHacXf2yT7t1JlzepdBCNnsyKANKHV6cX77GUBKhPyRpBNlOvvNpI2NYPGsZy0WCwRISrphhFx60ScvWl6gRm25uHykfyMWpmF0kfPi8dKDcw_Ob7dUAkWkwkgSQCXYEEYEUqQA-SNAoGx-_iRiait7s6U3a_9f8F1NKyLA1b6uuCDCC-bAiz5tlaqlF8w9uPLgasOLnFdqysXGg6ufHlyhkMeEf81jL1p6MH19dZj1uze4KXtAFS0A5gUBP2hVASyQ3ALOQM7VFiwqxDbgVjTsHiBWtN_nUhKhKGf2ybQVG8_sL65rW6LIrq6QIl6wUI81YWhHwK0XXNmnuEJSgjXwkk-2oBZcEaxIobUxJWDlwVTjDtoqANhWORIHZZ-BJrBu8opiXeFZMDA_OecVKDm3IntPDzvRP16y7L7qj91D53OncZ_XawUkITsJ1BYpoDTLG040ZHwPFNdg2WYSeDDlAhAkKkqEB7NpX8Za6cpFs6ufqBj0ZaR48JP-1W4DV4Jz5cFVVT3sJrXgfxOsv7b1VpThqilIr2S-vvXgaklwtfj-fbr1gnkYR1qWrRDMvWC--P79G8FcFLqaLVqSkjKqjb9ECnkwfqF-YWoZxjFnUukenv3Hi2fLJfBgrAV5EP7TEEFJAWrBayLUI-Bla90fVG0B46B46t-D0IMJKBGtSNHS9_Xmar6-ArLJd1QBBPJmAwSpuVCa-sFQoWrb5FPMdy1th-xRKRsiPbgyzt9yCNSWtMNE21QJhIkHF6AWpBYcEylJASRvhC3WLZGUHFMTE0TDgMSC1mp60tazqTfLvgq-EWgHkNg0O8KUbO3Ma2PXNnhMSBc8WstOUEeunCg9Oj24yil7Nrx2GTDZFD-QKCchmGzAhGu5qK619EbVjZpKMNlpLsBksk_jCZK7iXxkCu29YEmZIhWYlIxPHojIuST6OZiswWSywXiiOK_wFlHmBcuzeHVlyVAtt1yBSYl5xcWkoGjDuFQU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