Fixed STB_WEAK errors when using consts in macros in the stdlib #1871.

This commit is contained in:
Christoffer Lerno
2025-01-27 23:51:23 +01:00
parent d2a7dc4a9a
commit 55fba09b3b
3 changed files with 22 additions and 0 deletions

View File

@@ -31,6 +31,7 @@
- Issue where trailing body argument was allowed without type even though the definition specified it #1879.
- Fix issues with @jump on empty `default` or only `default` #1893 #1894
- Fixes miscompilation of nested `@jump` #1896.
- Fixed STB_WEAK errors when using consts in macros in the stdlib #1871.
### Stdlib changes
- Added '%h' and '%H' for printing out binary data in hexadecimal using the formatter.

View File

@@ -4049,6 +4049,8 @@ bool sema_analyse_var_decl(SemaContext *context, Decl *decl, bool local)
is_global = true;
break;
case VARDECL_CONST:
if (local) decl->var.is_static = true;
break;
default:
break;
}

View File

@@ -0,0 +1,19 @@
// #target: linux-x64
module scratch;
import std::test;
fn void main()
{
int x = test::abc();
}
module std::test;
macro abc()
{
const int A = 256;
return A;
}
/* #expect: scratch.ll
@main.A = internal local_unnamed_addr constant i32 256, align 4