]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
a68: fix handling of publicized declarations in victal pass
authorJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 29 Dec 2025 16:40:32 +0000 (17:40 +0100)
committerJose E. Marchesi <jose.marchesi@oracle.com>
Mon, 29 Dec 2025 16:42:22 +0000 (17:42 +0100)
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* a68-parser-victal.cc (victal_check_mode_dec): Mind publicized
declarations.
(victal_check_variable_dec): Likewise.
(victal_check_identity_dec): Likewise.

gcc/testsuite/ChangeLog

* algol68/compile/actual-bounds-expected-4.a68: New test.
* algol68/compile/formal-bounds-expected-1.a68: Likewise.

gcc/algol68/a68-parser-victal.cc
gcc/testsuite/algol68/compile/actual-bounds-expected-4.a68 [new file with mode: 0644]
gcc/testsuite/algol68/compile/formal-bounds-expected-1.a68 [new file with mode: 0644]

index b4162fc3982133368c2d7079bbd23ec297c26bc5..a810d3855554dc9c46501f5d10d3cea1b65fbf13 100644 (file)
@@ -90,6 +90,10 @@ victal_check_mode_dec (NODE_T *p)
          victal_check_mode_dec (SUB (p));
          victal_check_mode_dec (NEXT (p));
        }
+      else if (IS (p, PUBLIC_SYMBOL))
+       {
+         victal_check_mode_dec (NEXT (p));
+       }
       else if (a68_is_one_of (p, MODE_SYMBOL, DEFINING_INDICANT, STOP)
                || a68_is_one_of (p, EQUALS_SYMBOL, COMMA_SYMBOL, STOP))
        {
@@ -117,6 +121,9 @@ victal_check_variable_dec (NODE_T *p)
        }
       else
        {
+         if (IS (p, PUBLIC_SYMBOL))
+           FORWARD (p);
+
          if (IS (p, QUALIFIER))
            FORWARD (p);
 
@@ -147,7 +154,8 @@ victal_check_identity_dec (NODE_T * p)
          victal_check_identity_dec (SUB (p));
          victal_check_identity_dec (NEXT (p));
        }
-      else if (a68_is_one_of (p, DEFINING_IDENTIFIER, EQUALS_SYMBOL, COMMA_SYMBOL, STOP))
+      else if (a68_is_one_of (p, PUBLIC_SYMBOL, DEFINING_IDENTIFIER, EQUALS_SYMBOL, COMMA_SYMBOL,
+                             STOP))
        victal_check_identity_dec (NEXT (p));
       else if (IS (p, UNIT))
        a68_victal_checker (SUB (p));
diff --git a/gcc/testsuite/algol68/compile/actual-bounds-expected-4.a68 b/gcc/testsuite/algol68/compile/actual-bounds-expected-4.a68
new file mode 100644 (file)
index 0000000..9be3c9b
--- /dev/null
@@ -0,0 +1,15 @@
+{ Check that the victal pass handles publicized mode declarations
+  properly.  }
+
+module Foo =
+def pub mode M1 = ref[]int;
+    pub mode M2 = []int;             { dg-error "actual bounds expected" }
+    mode M3 = []real;                { dg-error "actual bounds expected" }
+    pub []int v1;                    { dg-error "actual bounds expected" }
+    []int v2;                        { dg-error "actual bounds expected" }
+    pub []int a1 = ([]int v; v);     { dg-error "actual bounds expected" }
+    []int a2 = ([]int v; v);         { dg-error "actual bounds expected" }
+    pub op - = ([3]int a) int: skip; { dg-error "formal bounds expected" }
+    op + = ([3]int a) int: skip;     { dg-error "formal bounds expected" }
+    skip
+fed
diff --git a/gcc/testsuite/algol68/compile/formal-bounds-expected-1.a68 b/gcc/testsuite/algol68/compile/formal-bounds-expected-1.a68
new file mode 100644 (file)
index 0000000..a645f54
--- /dev/null
@@ -0,0 +1,5 @@
+module Foo =
+def pub op - = ([3]int a) int: skip; { dg-error "formal bounds expected" }
+    op + = ([3]int a) int: skip;     { dg-error "formal bounds expected" }
+    skip
+fed