Skip to content

Commit

Permalink
Fixed STB_WEAK errors when using consts in macros in the stdlib c3lan…
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Jan 27, 2025
1 parent d2a7dc4 commit 55fba09
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/sema_decls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
19 changes: 19 additions & 0 deletions test/test_suite/variables/const_in_func.c3t
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 55fba09

Please sign in to comment.