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

    <tr>
        <th>Summary</th>
        <td>
            Crash with `#pragma weak a = b` when `a` is defined
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Sample code:

```c
// #include "stdio.h"

int foo() { return 20; }
int bar();

// Also fails with `_Pragma("weak foo = bar")`
#pragma weak foo = bar

void test() {
 foo();
}
```

Output:

```text
Could not execute the program
Compiler returned: 254
Compiler stderr

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-trunk-20241006/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir /app/output.s- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name example.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-trunk-20241006/lib/clang/20 -internal-isystem /opt/compiler-explorer/clang-trunk-20241006/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-0bc861.o -x c <source>
1.      <source>:10:9: current parser token ')'
2.      <source>:9:13: parsing function body 'test'
3.      <source>:9:13: in compound statement ('{}')
 #0 0x000000000393ab48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x393ab48)
 #1 0x000000000393872c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007be4e3842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000000006c8f59c clang::Sema::AddOverloadCandidate(clang::FunctionDecl*, clang::DeclAccessPair, llvm::ArrayRef<clang::Expr*>, clang::OverloadCandidateSet&, bool, bool, bool, bool, clang::CallExpr::ADLCallKind, llvm::MutableArrayRef<clang::ImplicitConversionSequence>, clang::OverloadCandidateParamOrder, bool) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x6c8f59c)
 #4 0x00000000067c2717 clang::Sema::DiagnoseEmptyLookup(clang::Scope*, clang::CXXScopeSpec&, clang::LookupResult&, clang::CorrectionCandidateCallback&, clang::TemplateArgumentListInfo*, llvm::ArrayRef<clang::Expr*>, clang::DeclContext*, clang::TypoExpr**) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x67c2717)
 #5 0x0000000006caf208 FinishOverloadedCallExpr(clang::Sema&, clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, clang::OverloadCandidateSet*, clang::OverloadCandidate**, clang::OverloadingResult, bool) SemaOverload.cpp:0:0
 #6 0x0000000006cafd3c clang::Sema::BuildOverloadedCallExpr(clang::Scope*, clang::Expr*, clang::UnresolvedLookupExpr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x6cafd3c)
 #7 0x0000000006849dfa clang::Sema::BuildCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*, bool, bool) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x6849dfa)
 #8 0x000000000685009c clang::Sema::ActOnCallExpr(clang::Scope*, clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, clang::SourceLocation, clang::Expr*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x685009c)
 #9 0x00000000062ae847 clang::Parser::ParsePostfixExpressionSuffix(clang::ActionResult<clang::Expr*, true>) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x62ae847)
#10 0x00000000062a6601 clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, bool&, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x62a6601)
#11 0x00000000062a882a clang::Parser::ParseCastExpression(clang::Parser::CastParseKind, bool, clang::Parser::TypeCastState, bool, bool*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x62a882a)
#12 0x00000000062a89f9 clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x62a89f9)
#13 0x00000000062adc49 clang::Parser::ParseExpression(clang::Parser::TypeCastState) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x62adc49)
#14 0x0000000006339fb7 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x6339fb7)
#15 0x000000000632d767 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x632d767)
#16 0x000000000632e15d clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 32u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x632e15d)
#17 0x000000000632f471 clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x632f471)
#18 0x000000000633169a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x633169a)
#19 0x000000000622e176 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x622e176)
#20 0x00000000062773df clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x62773df)
#21 0x0000000006226727 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x6226727)
#22 0x0000000006227543 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x6227543)
#23 0x0000000006230e32 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x6230e32)
#24 0x00000000062326c8 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x62326c8)
#25 0x0000000006220d9a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x6220d9a)
#26 0x0000000004257705 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x4257705)
#27 0x000000000451df31 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x451df31)
#28 0x000000000449db7b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x449db7b)
#29 0x0000000004602493 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0x4602493)
#30 0x0000000000ce01ec cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0xce01ec)
#31 0x0000000000cd8c4d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#32 0x0000000000cdcdbf clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0xcdcdbf)
#33 0x0000000000bb04f4 main (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0xbb04f4)
#34 0x00007be4e3829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#35 0x00007be4e3829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#36 0x0000000000cd86ee _start (/opt/compiler-explorer/clang-trunk-20241006/bin/clang-20+0xcd86ee)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
```

I typed the parameters wrong, it is attempting to declare `foo` as a weak alias of `bar`, 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWl9z4ygS_zTKC4VLRrJsP-TBY493U5etSY1ze_uWQtBS2EigBeQk3_4KJP9BcZyZPc_d3k5lEps_za9_3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