Closed llvmbot closed 1 year ago
Sorry, I made a mistake of attaching the output of 12.0, instead of trunk. Following is the one of trunk.
test.c:3:41: warning: implicit declaration of function 'a' is invalid in C99 [-Wimplicit-function-declaration] int x attribute((aligned(({ a(); })))); ^ clang: /home/xxx/data/git/llvm-project/clang/lib/AST/Decl.cpp:2077: bool isDeclExternC(const T &) [T = clang::FunctionDecl]: Assertion `D.getASTContext().getLangOpts().CPlusPlus' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump:
clang-13: error: clang frontend command failed with exit code 134 (use -v to see invocation) clang version 13.0.0 (https://github.com/llvm/llvm-project.git b006902b2dfac792e8ade73798ca1b216654faf7) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /data/xxx/git/llvm-project/build_trunk/bin clang-13: note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-13: note: diagnostic msg: /tmp/test-0b4587.c clang-13: note: diagnostic msg: /tmp/test-0b4587.sh clang-13: note: diagnostic msg:
Assertion fails on trunk as well.
poc.c:3:41: warning: implicit declaration of function 'a' is invalid in C99 [-Wimplicit-function-declaration] int x attribute((aligned(({ a(); })))); ^ clang: /data/xxx/git/llvm-project/clang/lib/AST/Decl.cpp:2077: bool isDeclExternC(const T &) [T = clang::FunctionDecl]: Assertion `D.getASTContext().getLangOpts().CPlusPlus' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump:
clang-12: error: clang frontend command failed with exit code 134 (use -v to see invocation) clang version 12.0.0 (https://github.com/llvm/llvm-project.git b46924ee5afe234526220c29a497794bf65f8f7f) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /data/xxx/git/llvm-project/build_12/bin clang-12: note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-12: note: diagnostic msg: /tmp/poc-edc185.c clang-12: note: diagnostic msg: /tmp/poc-edc185.sh clang-12: note: diagnostic msg:
Also affects trunk.
@llvm/issue-subscribers-clang-frontend
@llvm/issue-subscribers-c
The issue is still present as of Clang 16.0.0. It only occurs for C builds and it requires assertions to be enabled: https://gcc.godbolt.org/z/5sqPdoznb
Extended Description
It may be duplicated with llvm/llvm-project#44103 .
$ cat test.c int main() { struct { int x attribute((aligned(({ a(); })))); } x; }
$ ./clang -c test.c test.c:3:41: warning: implicit declaration of function 'a' is invalid in C99 [-Wimplicit-function-declaration] int x attribute((aligned(({ a(); })))); ^ clang: /home/xxx/data/git/llvm-project/clang/lib/AST/Decl.cpp:2052: bool isDeclExternC(const T &) [T = clang::FunctionDecl]: Assertion `D.getASTContext().getLangOpts().CPlusPlus' failed. PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump:
0 0x0000000006e97306 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:560:7
1 0x0000000006e9266e llvm::sys::RunSignalHandlers() /home/xxx/data/git/llvm-project/llvm/lib/Support/Signals.cpp:69:18
2 0x0000000006e95560 llvm::sys::CleanupOnSignal(unsigned long) /home/xxx/data/git/llvm-project/llvm/lib/Support/Unix/Signals.inc:361:3
3 0x0000000006c878a5 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) /home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:77:5
4 0x0000000006c87d20 CrashRecoverySignalHandler(int) /home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:383:1
5 0x00007f9ac4c598a0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x128a0)
6 0x00007f9ac391ff47 gsignal /build/glibc-2ORdQG/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
7 0x00007f9ac39218b1 abort /build/glibc-2ORdQG/glibc-2.27/stdlib/abort.c:81:0
8 0x00007f9ac391142a __assert_fail_base /build/glibc-2ORdQG/glibc-2.27/assert/assert.c:89:0
9 0x00007f9ac39114a2 (/lib/x86_64-linux-gnu/libc.so.6+0x304a2)
10 0x000000000f31cab6 /home/xxx/data/git/llvm-project/clang/lib/AST/Decl.cpp:2052:5
11 0x000000000cee82c2 bool isIncompleteDeclExternC(clang::Sema&, clang::FunctionDecl const*) /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaDecl.cpp:6602:13
12 0x000000000cebca55 clang::Sema::ActOnFunctionDeclarator(clang::Scope, clang::Declarator&, clang::DeclContext, clang::TypeSourceInfo, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList>, bool&) /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaDecl.cpp:9700:7
13 0x000000000ceaca94 clang::Sema::HandleDeclarator(clang::Scope, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList>) /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaDecl.cpp:5868:11
14 0x000000000ceaa141 clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaDecl.cpp:5544:15
15 0x000000000ce69606 clang::Sema::ImplicitlyDefineFunction(clang::SourceLocation, clang::IdentifierInfo&, clang::Scope*) /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaDecl.cpp:14661:41
16 0x000000000ce64a09 clang::Sema::ClassifyName(clang::Scope, clang::CXXScopeSpec&, clang::IdentifierInfo&, clang::SourceLocation, clang::Token const&, clang::CorrectionCandidateCallback*) /home/xxx/data/git/llvm-project/clang/lib/Sema/SemaDecl.cpp:929:26
17 0x000000000c8369ed clang::Parser::TryAnnotateName(clang::CorrectionCandidateCallback*) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:1627:53
18 0x000000000ca0874b clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:191:11
19 0x000000000ca081a6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:106:20
20 0x000000000ca1c77e clang::Parser::ParseCompoundStatementBody(bool) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:1089:11
21 0x000000000ca1a464 clang::Parser::ParseScope::~ParseScope() /home/xxx/data/git/llvm-project/clang/include/clang/Parse/Parser.h:0:0
22 0x000000000ca1a464 clang::Parser::ParseCompoundStatement(bool, unsigned int) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:904:0
23 0x000000000c91556d clang::Parser::ParseParenExpression(clang::Parser::ParenParseOption&, bool, bool, clang::OpaquePtr&, clang::SourceLocation&) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:2872:16
24 0x000000000c90fc2e clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:957:11
25 0x000000000c902c60 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:681:20
26 0x000000000c8fe5ef clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseExpr.cpp:176:10
27 0x000000000c8627aa _ZN4llvm12function_refIFN5clang12ActionResultIPNS1_4ExprELb1EEES4_EEC2IZNS1_4Sema25CorrectDelayedTyposInExprES5_PNS1_7VarDeclEbS7_Ed_UlS4_E_EEOT_PNSt9enable_ifIXntsr3std7is_sameINSt9remove_cvINSt16remove_referenceISD_E4typeEE4typeES7_EE5valueEvE4typeE /home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:0:0
28 0x000000000c8627aa clang::Parser::ParseAttributeArgsCommon(clang::IdentifierInfo, clang::SourceLocation, clang::ParsedAttributes&, clang::SourceLocation, clang::IdentifierInfo*, clang::SourceLocation, clang::AttributeCommonInfo::Syntax) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:397:0
29 0x000000000c86049b clang::Parser::ParseGNUAttributeArgs(clang::IdentifierInfo, clang::SourceLocation, clang::ParsedAttributes&, clang::SourceLocation, clang::IdentifierInfo, clang::SourceLocation, clang::AttributeCommonInfo::Syntax, clang::Declarator) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:480:3
30 0x000000000c85ed4a clang::Parser::ParseGNUAttributes(clang::ParsedAttributes&, clang::SourceLocation, clang::Parser::LateParsedAttrList, clang::Declarator*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:189:9
31 0x000000000c84163e clang::Parser::MaybeParseGNUAttributes(clang::Declarator&, clang::Parser::LateParsedAttrList*) /home/xxx/data/git/llvm-project/clang/include/clang/Parse/Parser.h:2650:31
32 0x000000000c89229a llvm::function_ref<void (clang::ParsingFieldDeclarator&)>::operator()(clang::ParsingFieldDeclarator&) const /home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:0:0
33 0x000000000c89229a clang::Parser::ParseStructDeclaration(clang::ParsingDeclSpec&, llvm::function_ref<void (clang::ParsingFieldDeclarator&)>) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:4088:0
34 0x000000000c89354a clang::ParsingDeclSpec::~ParsingDeclSpec() /home/xxx/data/git/llvm-project/clang/include/clang/Parse/RAIIObjectsForParser.h:0:0
35 0x000000000c89354a clang::Parser::ParseStructUnionBody(clang::SourceLocation, clang::TypeSpecifierType, clang::RecordDecl*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:4179:0
36 0x000000000c8d1a67 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::Parser::ParsedAttributesWithRange&) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDeclCXX.cpp:1969:20
37 0x000000000c8744f9 clang::ParsedAttributesView::empty() const /home/xxx/data/git/llvm-project/clang/include/clang/Sema/ParsedAttr.h:0:0
38 0x000000000c8744f9 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo const&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:3839:0
39 0x000000000c8735e7 clang::Parser::ParseSimpleDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, bool, clang::Parser::ForRangeInit, clang::SourceLocation) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:1675:10
40 0x000000000c873179 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::Parser::ParsedAttributesWithRange&, clang::SourceLocation*) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:0:12
41 0x000000000ca08d41 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation, clang::Parser::ParsedAttributesWithRange&) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:0:13
42 0x000000000ca081a6 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:106:20
43 0x000000000ca1c77e clang::Parser::ParseCompoundStatementBody(bool) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:1089:11
44 0x000000000ca1f748 clang::ActionResult<clang::Stmt*, true>::isInvalid() const /home/xxx/data/git/llvm-project/clang/include/clang/Sema/Ownership.h:0:0
45 0x000000000ca1f748 clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseStmt.cpp:2240:0
46 0x000000000c833117 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:1339:10
47 0x000000000c88224e clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::SourceLocation, clang::Parser::ForRangeInit) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseDecl.cpp:1926:18
48 0x000000000c83020d clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec&, clang::AccessSpecifier) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:0:10
49 0x000000000c82e939 clang::Parser::ObjCDeclContextSwitch::~ObjCDeclContextSwitch() /home/xxx/data/git/llvm-project/clang/include/clang/Parse/Parser.h:0:0
50 0x000000000c82e939 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*, clang::AccessSpecifier) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:1116:0
51 0x000000000c82c6a1 clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&, clang::ParsingDeclSpec*) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:935:12
52 0x000000000c827ecc clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, bool) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:683:10
53 0x000000000c826ccc clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr&) /home/xxx/data/git/llvm-project/clang/lib/Parse/Parser.cpp:555:26
54 0x000000000c81cf4a clang::ParseAST(clang::Sema&, bool, bool) /home/xxx/data/git/llvm-project/clang/lib/Parse/ParseAST.cpp:157:15
55 0x000000000861c2a2 clang::ASTFrontendAction::ExecuteAction() /home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1059:1
56 0x00000000099decd8 clang::CodeGenAction::ExecuteAction() /home/xxx/data/git/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1184:28
57 0x000000000861a51a clang::FrontendAction::Execute() /home/xxx/data/git/llvm-project/clang/lib/Frontend/FrontendAction.cpp:954:10
58 0x000000000854eaa7 llvm::Error::operator bool() /home/xxx/data/git/llvm-project/llvm/include/llvm/Support/Error.h:0:0
59 0x000000000854eaa7 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/xxx/data/git/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:984:0
60 0x00000000088f183f clang::CompilerInstance::getFrontendOpts() /home/xxx/data/git/llvm-project/clang/include/clang/Frontend/CompilerInstance.h:0:0
61 0x00000000088f183f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /home/xxx/data/git/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:279:0
62 0x0000000000b094cc llvm::TimeTraceScope::~TimeTraceScope() /home/xxx/data/git/llvm-project/llvm/include/llvm/Support/TimeProfiler.h:0:0
63 0x0000000000b094cc cc1_main(llvm::ArrayRef<char const>, char const, void*) /home/xxx/data/git/llvm-project/clang/tools/driver/cc1_main.cpp:241:0
64 0x0000000000afaf3b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:330:12
65 0x00000000082c1350 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::$_1::operator()() const /home/xxx/data/git/llvm-project/clang/lib/Driver/Job.cpp:400:30
66 0x00000000082c1350 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const::$_1>(long) /home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/STLExtras.h:185:0
67 0x0000000006c8767d llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) /home/xxx/data/git/llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:420:1
68 0x00000000082bfbe7 clang::driver::CC1Command::Execute(llvm::ArrayRef<llvm::Optional >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, bool) const /home/xxx/data/git/llvm-project/clang/lib/Driver/Job.cpp:400:12
69 0x000000000822acca std::__cxx11::basic_string<char, std::char_traits, std::allocator >::empty() const /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/basic_string.h:0:0
70 0x000000000822acca clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&) const /home/xxx/data/git/llvm-project/clang/lib/Driver/Compilation.cpp:196:0
71 0x000000000822b754 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) const /home/xxx/data/git/llvm-project/clang/lib/Driver/Compilation.cpp:246:19
72 0x0000000008266f77 llvm::SmallVectorBase::empty() const /home/xxx/data/git/llvm-project/llvm/include/llvm/ADT/SmallVector.h:0:0
73 0x0000000008266f77 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) /home/xxx/data/git/llvm-project/clang/lib/Driver/Driver.cpp:1509:0
74 0x0000000000af95ae main /home/xxx/data/git/llvm-project/clang/tools/driver/driver.cpp:502:21
75 0x00007f9ac3902b97 __libc_start_main /build/glibc-2ORdQG/glibc-2.27/csu/../csu/libc-start.c:344:0
76 0x0000000000af38ea _start (/data/xxx/git/llvm-project/build/bin/clang+0xaf38ea)
clang-11: error: clang frontend command failed due to signal (use -v to see invocation) clang version 11.1.0 (https://github.com/llvm/llvm-project.git 1fdec59bffc11ae37eb51a1b9869f0696bfd5312) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /data/xxx/git/llvm-project/build/bin clang-11: note: diagnostic msg:
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-11: note: diagnostic msg: /tmp/test-397fa0.c clang-11: note: diagnostic msg: /tmp/test-397fa0.sh clang-11: note: diagnostic msg: