-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using enum declaration with anonymous enum crashes clang frontend #86790
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
confirmed
Verified by a second party
crash
Prefer [crash-on-valid] or [crash-on-invalid]
Comments
github-actions
bot
added
the
clang
Clang issues not falling into any other category
label
Mar 27, 2024
EugeneZelenko
added
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
crash
Prefer [crash-on-valid] or [crash-on-invalid]
and removed
clang
Clang issues not falling into any other category
labels
Mar 27, 2024
@llvm/issue-subscribers-clang-frontend Author: None (svetli97)
Minimal example:
```
enum {A, S, D, F}; // the enum is in an outer scope to avoid name collisions. This seems unrelated to the bug.
// enum Asdf {A, S, D, F}; // naming the enum prevents the crash
int main()
{
using asdf = decltype(A);
using enum asdf; // this line causes the crash
return 0;
}
```
Needs additional clang command line argument "-std=c++20" (or later) to support using-enum-declarations.
The gcc compiler compiles this code without any problems.
Downloaded compilers from https://winlibs.com/
exact file download link: https://github.com/brechtsanders/winlibs_mingw/releases/download/13.1.0-16.0.5-11.0.0-ucrt-r5/winlibs-x86_64-posix-seh-gcc-13.1.0-llvm-16.0.5-mingw-w64ucrt-11.0.0-r5.zip
OS: Windows
Expected behavior: the code should compile. Observed behavior: clang frontend crashes with the following error message:
The files mentioned in the error message:
C:/Users/SVETLI~1.TOT/AppData/Local/Temp/test-0047ff.sh:
|
Confirmed: https://godbolt.org/z/xjb96Edxr Assertion clang++: /root/llvm-project/clang/include/clang/AST/DeclarationName.h:503:
void* clang::DeclarationName::getFETokenInfo() const:
Assertion `getPtr() && "getFETokenInfo on an empty DeclarationName!"' failed. Backtrace: 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c++20 <source>
1. <source>:6:20: current parser token ';'
2. <source>:4:1: parsing function body 'main'
3. <source>:4:1: in compound statement ('{}')
#0 0x0000000003920cd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3920cd8)
#1 0x000000000391e9bc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x391e9bc)
#2 0x0000000003865258 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007f938b842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f938b8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x00007f938b842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007f938b8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007f938b82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x00007f938b839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000062f2087 clang::IdentifierResolver::begin(clang::DeclarationName) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62f2087)
#10 0x00000000064fd446 clang::Sema::PushOnScopeChains(clang::NamedDecl*, clang::Scope*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x64fd446)
#11 0x00000000065fef54 clang::Sema::ActOnUsingEnumDeclaration(clang::Scope*, clang::AccessSpecifier, clang::SourceLocation, clang::SourceLocation, clang::SourceLocation, clang::IdentifierInfo&, clang::CXXScopeSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x65fef54)
#12 0x00000000062224ef clang::Parser::ParseUsingDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62224ef)
#13 0x00000000062228a5 clang::Parser::ParseUsingDirectiveOrDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62228a5)
#14 0x00000000062094ea clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62094ea)
#15 0x00000000062aaf8c 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+++0x62aaf8c)
#16 0x00000000062ac247 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62ac247)
#17 0x00000000062ad151 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62ad151)
#18 0x00000000062aea6a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x62aea6a)
#19 0x00000000061c9b41 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61c9b41)
#20 0x00000000062011bc 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+++0x62011bc)
#21 0x00000000061bdade clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61bdade)
#22 0x00000000061be2d3 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61be2d3)
#23 0x00000000061c5746 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61c5746)
#24 0x00000000061c65ed clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61c65ed)
#25 0x00000000061b92ca clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x61b92ca)
#26 0x00000000041bd968 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41bd968)
#27 0x000000000443cfe9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x443cfe9)
#28 0x00000000043c66de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43c66de)
#29 0x000000000452009e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x452009e)
#30 0x0000000000c29b5c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc29b5c)
#31 0x0000000000c22dea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#32 0x00000000042008e9 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
#33 0x0000000003865704 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3865704)
#34 0x0000000004200edf 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
#35 0x00000000041c7275 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41c7275)
#36 0x00000000041c7cdd 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+++0x41c7cdd)
#37 0x00000000041cfa45 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41cfa45)
#38 0x0000000000c26ff5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc26ff5)
#39 0x0000000000b1d474 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb1d474)
#40 0x00007f938b829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#41 0x00007f938b829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#42 0x0000000000c228de _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc228de)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134 |
jcsxky
added a commit
that referenced
this issue
Apr 5, 2024
…87144) Try to fix #86790 `getFETokenInfo` requires `DeclarationName` shouldn't be empty and this will produce crash when checking name conflict of an anonymous `NamedDecl` in `Sema::PushOnScopeChains` and whether it's a reserved identifier or not. These wouldn't happen when it's a anonymous enum and we can skip the checking and just add the declaration to current scope. Co-authored-by: huqizhi <836744285@qq.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
confirmed
Verified by a second party
crash
Prefer [crash-on-valid] or [crash-on-invalid]
Minimal example:
Needs additional clang command line argument "-std=c++20" (or later) to support using-enum-declarations.
The gcc compiler compiles this code without any problems.
Downloaded compilers from https://winlibs.com/
exact file download link: https://github.com/brechtsanders/winlibs_mingw/releases/download/13.1.0-16.0.5-11.0.0-ucrt-r5/winlibs-x86_64-posix-seh-gcc-13.1.0-llvm-16.0.5-mingw-w64ucrt-11.0.0-r5.zip
OS: Windows
Expected behavior: the code should compile.
Observed behavior: clang frontend crashes with the following error message:
The files mentioned in the error message:
C:/Users/SVETLI~1.TOT/AppData/Local/Temp/test-0047ff.cpp:
C:/Users/SVETLI~1.TOT/AppData/Local/Temp/test-0047ff.sh:
The text was updated successfully, but these errors were encountered: