<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113465>113465</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Assertion `Access == AS_private || Access == AS_protected' failed.
</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/sEWPGr146](https://godbolt.org/z/sEWPGr146)
This invalid code will crash on Clang Assertion Trunk:
```cpp
struct bar {};
enum T : int { bar = 1, };
struct R {
void set(bar
#pragma message "Any Message"*);
};
void R::set(bar *val) {}
```
It seems that this goes back to clang-6.
Stack dump:
```
clang++: /root/llvm-project/clang/lib/Sema/SemaAccess.cpp:758: AccessResult HasAccess(clang::Sema&, const {anonymous}::EffectiveContext&, const clang::CXXRecordDecl*, clang::AccessSpecifier, const {anonymous}::AccessTarget&): Assertion `Access == AS_private || Access == AS_protected' 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>:7:23: current parser token '{'
#0 0x0000000003bcced8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bcced8)
#1 0x0000000003bcab9c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bcab9c)
#2 0x0000000003b18248 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007e5c96042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007e5c960969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007e5c96042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007e5c960287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007e5c9602871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007e5c96039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x000000000687f998 HasAccess(clang::Sema&, (anonymous namespace)::EffectiveContext const&, clang::CXXRecordDecl const*, clang::AccessSpecifier, (anonymous namespace)::AccessTarget const&) SemaAccess.cpp:0:0
#10 0x00000000068800de IsAccessible(clang::Sema&, (anonymous namespace)::EffectiveContext const&, (anonymous namespace)::AccessTarget&) SemaAccess.cpp:0:0
#11 0x000000000688066e CheckEffectiveAccess(clang::Sema&, (anonymous namespace)::EffectiveContext const&, clang::SourceLocation, (anonymous namespace)::AccessTarget&) SemaAccess.cpp:0:0
#12 0x0000000006881d1a clang::Sema::HandleDelayedAccessCheck(clang::sema::DelayedDiagnostic&, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6881d1a)
#13 0x0000000006ab0bc1 clang::Sema::PopParsingDeclaration(clang::Sema::DelayedDiagnosticsState, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ab0bc1)
#14 0x00000000066a9de3 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a9de3)
#15 0x00000000066de84d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66de84d)
#16 0x000000000669dede clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x669dede)
#17 0x000000000669e69e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x669e69e)
#18 0x00000000066a5e33 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a5e33)
#19 0x00000000066a6d1d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a6d1d)
#20 0x000000000669923a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x669923a)
#21 0x0000000004542c48 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4542c48)
#22 0x00000000047fe239 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47fe239)
#23 0x000000000477cbde clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x477cbde)
#24 0x00000000048e3a0e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48e3a0e)
#25 0x0000000000ce1c8f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce1c8f)
#26 0x0000000000cd998a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x0000000004586969 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
#28 0x0000000003b186f4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b186f4)
#29 0x0000000004586f5f 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
#30 0x000000000454c85d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x454c85d)
#31 0x000000000454d94d 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+++0x454d94d)
#32 0x0000000004555275 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4555275)
#33 0x0000000000cdeb4f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdeb4f)
#34 0x0000000000badae4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbadae4)
#35 0x00007e5c96029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007e5c96029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000cd943e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd943e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
</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