From 263915832993dd12beee10e204f9ebcc6c786ed2 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 30 Dec 2023 23:39:37 +0100 Subject: Meta: initial commit of WestCo optimized toolchain. Signed-off-by: Amlal El Mahrouss --- .../pure2-deducing-pointers-error.cpp2 | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 CompilerDriver/cc2/regression-tests/pure2-deducing-pointers-error.cpp2 (limited to 'CompilerDriver/cc2/regression-tests/pure2-deducing-pointers-error.cpp2') diff --git a/CompilerDriver/cc2/regression-tests/pure2-deducing-pointers-error.cpp2 b/CompilerDriver/cc2/regression-tests/pure2-deducing-pointers-error.cpp2 new file mode 100644 index 0000000..ee6e5ff --- /dev/null +++ b/CompilerDriver/cc2/regression-tests/pure2-deducing-pointers-error.cpp2 @@ -0,0 +1,47 @@ +fun: (inout i:int) -> *int = { + return i&; +} + +fun2: (inout i:int) -> (result : *int) = { + result = i&; +} + +main: () -> int = { + a: int = 2; + pa: *int = a&; + ppa: **int = pa&; + + pa = 0; // caught + + pa2:= ppa*; + pa2 = 0; // caught + + pa3 := a&; + pa3 = 0; // caught + pa3 += 2; // caught + + ppa2 := pa2&; + pa4 := ppa2*; + pa4 = 0; // caught + + pppa := ppa&; + pa5 := pppa**; + pa5 = 0; // caught + + // TODO: @filipsajdak please take a look + // The bugfix in get_declaration_of(t) to add `&& ri->position() <= t.position()` + // to the condition is correct; it fixes issue #669 by not looking past the first + // declaration of the name in t. However, that change made the following two + // "caught" cases no longer be caught. + fun(a)++; // caught + fp := fun(a); + fp = 0; // caught + + f := fun(a)*; + _ = f; + + fp2 := fun2(a).result; + fp2--; // not caught :( + + return a * pa* * ppa**; // 8 +} -- cgit v1.2.3