diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-12-11 21:02:31 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-12-11 21:08:39 +0900 |
| commit | 000f1d7f7412440619112b09f64ff653d960ed25 (patch) | |
| tree | 020c60c6a2464db430ecf5abb39594ecec78761c /tests | |
| parent | 47d43f5a583dc2d474e553afe0cb682d878231b1 (diff) | |
| download | ducc-000f1d7f7412440619112b09f64ff653d960ed25.tar.gz ducc-000f1d7f7412440619112b09f64ff653d960ed25.tar.zst ducc-000f1d7f7412440619112b09f64ff653d960ed25.zip | |
fix: static function returning pointer type being marked as global
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/static_linkage.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/static_linkage.sh b/tests/static_linkage.sh new file mode 100644 index 0000000..de6120f --- /dev/null +++ b/tests/static_linkage.sh @@ -0,0 +1,48 @@ +cat > main.c <<'EOF' +int f1() { return 0; } +int* f2() { return 0; } +int** f3() { return 0; } + +static int f4() { return 0; } +static int* f5() { return 0; } +static int** f6() { return 0; } + +char* f7() { return 0; } +static char* f8() { return 0; } + +void** f9() { return 0; } +static void** f10() { return 0; } + +int main() { } +EOF + +"$ducc" -o main.s main.c + +function assert_global() { + local func=$1 + if ! grep -q "\.globl $func\$" main.s; then + echo "expected .globl for non-static function: $func" >&2 + exit 1 + fi +} + +function assert_local() { + local func=$1 + if grep -q "\.globl $func\$" main.s; then + echo "unexpected .globl for static function: $func" >&2 + exit 1 + fi +} + +assert_global f1 +assert_global f2 +assert_global f3 +assert_global f7 +assert_global f9 +assert_global main + +assert_local f4 +assert_local f5 +assert_local f6 +assert_local f8 +assert_local f10 |
