diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 15:22:23 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 15:22:23 +0000 |
| commit | f7f5df01c416a10e3eb9508a7a7150c792a8b4ca (patch) | |
| tree | 9d1fc624c74c129b24fe8b8a6f921f50b799e09a /tests/iii | |
| parent | 09498bb7aab9182ba172aae1045ca895d4f422d4 (diff) | |
feat(codegen): allow identical EXTERN redeclarations across files
Repeated EXTERN declarations with the same signature share one C symbol,
as C declarations do; conflicting signatures are errors.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/iii')
| -rw-r--r-- | tests/iii/multifile-extern-conflict/case.json | 13 | ||||
| -rw-r--r-- | tests/iii/multifile-extern-conflict/lib.cps | 3 | ||||
| -rw-r--r-- | tests/iii/multifile-extern-conflict/notes.md | 5 | ||||
| -rw-r--r-- | tests/iii/multifile-extern-conflict/program.cps | 4 |
4 files changed, 25 insertions, 0 deletions
diff --git a/tests/iii/multifile-extern-conflict/case.json b/tests/iii/multifile-extern-conflict/case.json new file mode 100644 index 0000000..1eb3f1d --- /dev/null +++ b/tests/iii/multifile-extern-conflict/case.json @@ -0,0 +1,13 @@ +{ + "sources": [ + "program.cps", + "lib.cps" + ], + "errors": [ + { + "reason": "Conflicting EXTERN declarations of abs", + "line": 3, + "file": "lib.cps" + } + ] +} diff --git a/tests/iii/multifile-extern-conflict/lib.cps b/tests/iii/multifile-extern-conflict/lib.cps new file mode 100644 index 0000000..2c15253 --- /dev/null +++ b/tests/iii/multifile-extern-conflict/lib.cps @@ -0,0 +1,3 @@ +// The result type differs from program.cps. +INCLUDE_OBJ "__libc" +EXTERN "C" EXTERN_FUNCTION abs(C_INT) RETURNS C_DOUBLE diff --git a/tests/iii/multifile-extern-conflict/notes.md b/tests/iii/multifile-extern-conflict/notes.md new file mode 100644 index 0000000..6ac25b7 --- /dev/null +++ b/tests/iii/multifile-extern-conflict/notes.md @@ -0,0 +1,5 @@ +# multifile-extern-conflict + +Compiler extension: repeated EXTERN declarations must have identical signatures; lib.cps changes the result type. + +Require exit 1 and the cause on the second declaration. diff --git a/tests/iii/multifile-extern-conflict/program.cps b/tests/iii/multifile-extern-conflict/program.cps new file mode 100644 index 0000000..058cd5e --- /dev/null +++ b/tests/iii/multifile-extern-conflict/program.cps @@ -0,0 +1,4 @@ +INCLUDE "lib.cps" +INCLUDE_OBJ "__libc" +EXTERN "C" EXTERN_FUNCTION abs(C_INT) RETURNS C_INT +OUTPUT abs((C_INT)-3) |
