diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-14 16:35:20 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-14 16:35:20 +0200 |
| commit | 49e6a0518eb6b7b09938b562ef270028337508bf (patch) | |
| tree | 788a14c49ab5ebf3dc19c9455a5128593d5d7ad4 | |
| parent | 8cc075c6a736fdde56ca2da03a868821695765f4 (diff) | |
| download | elna-49e6a0518eb6b7b09938b562ef270028337508bf.tar.gz | |
Reject local extern variables
| -rw-r--r-- | boot/materialization.cc | 7 | ||||
| -rw-r--r-- | include/elna/boot/materialization.h | 1 | ||||
| -rw-r--r-- | testsuite/fail_compilation/local_var_extern.elna | 6 |
3 files changed, 14 insertions, 0 deletions
diff --git a/boot/materialization.cc b/boot/materialization.cc index 5b200d5..0ca81aa 100644 --- a/boot/materialization.cc +++ b/boot/materialization.cc @@ -35,6 +35,8 @@ namespace elna::boot return "Real literal overflows"; case local_export: return "Local symbols cannot be exported"; + case local_extern: + return "Local symbols cannot be extern"; case field_export: return "Record fields cannot be exported"; } @@ -64,6 +66,11 @@ namespace elna::boot materialization_error::kind::local_export); } } + if (!this->in_global_scope && declaration->is_extern) + { + add_error<materialization_error>(declaration->position(), + materialization_error::kind::local_extern); + } } void materialization_visitor::visit(record_type_expression *expression) diff --git a/include/elna/boot/materialization.h b/include/elna/boot/materialization.h index ef1b70b..63d6155 100644 --- a/include/elna/boot/materialization.h +++ b/include/elna/boot/materialization.h @@ -29,6 +29,7 @@ namespace elna::boot integer_overflow, real_overflow, local_export, + local_extern, field_export }; diff --git a/testsuite/fail_compilation/local_var_extern.elna b/testsuite/fail_compilation/local_var_extern.elna new file mode 100644 index 0000000..d0eb22f --- /dev/null +++ b/testsuite/fail_compilation/local_var_extern.elna @@ -0,0 +1,6 @@ +proc test_local_extern() +var + v : Int := extern (* @Error Local symbols cannot be extern *) +return + +end. |
