https://gcc.gnu.org/g:9eb44775b91cd5d3f7a20c00e4abf139312e898e
commit r17-6475-g9eb44775b91cd5d3f7a20c00e4abf139312e898e Author: Jose E. Marchesi <[email protected]> Date: Thu Nov 19 22:45:54 2026 +0100 a68: fix check for number of operator arguments [PR algol68/128797] Signed-off-by: Jose E. Marchesi <[email protected]> gcc/algol68/ChangeLog PR algol68/128797 * a68-parser-taxes.cc (check_operator_dec): Fix check for proper number of operator arguments. gcc/testsuite/ChangeLog PR algol68/128797 * algol68/compile/error-op-numargs-1.a68: New test. * algol68/compile/error-op-numargs-3.a68: Likewise. * algol68/compile/error-op-numargs-2.a68: Likewise. Diff: --- gcc/algol68/a68-parser-taxes.cc | 11 ++++++----- gcc/testsuite/algol68/compile/error-op-numargs-1.a68 | 4 ++++ gcc/testsuite/algol68/compile/error-op-numargs-2.a68 | 4 ++++ gcc/testsuite/algol68/compile/error-op-numargs-3.a68 | 8 ++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/gcc/algol68/a68-parser-taxes.cc b/gcc/algol68/a68-parser-taxes.cc index 41fe98896e83..5659920ed1f6 100644 --- a/gcc/algol68/a68-parser-taxes.cc +++ b/gcc/algol68/a68-parser-taxes.cc @@ -1099,11 +1099,12 @@ check_operator_dec (NODE_T *p, MOID_T *u) if (u == NO_MOID) { - NODE_T *pack = SUB_SUB (NEXT_NEXT (p)); /* Where the parameter pack - is. */ - if (ATTRIBUTE (NEXT_NEXT (p)) != ROUTINE_TEXT) - pack = SUB (pack); - k = 1 + a68_count_operands (pack); + if (IS (NEXT_NEXT (p), ROUTINE_TEXT) + && IS (SUB (NEXT_NEXT (p)), PARAMETER_PACK)) + { + NODE_T *pack = SUB_SUB (NEXT_NEXT (p)); + k = 1 + a68_count_operands (pack); + } } else k = a68_count_pack_members (PACK (u)); diff --git a/gcc/testsuite/algol68/compile/error-op-numargs-1.a68 b/gcc/testsuite/algol68/compile/error-op-numargs-1.a68 new file mode 100644 index 000000000000..a2ddf2148e1a --- /dev/null +++ b/gcc/testsuite/algol68/compile/error-op-numargs-1.a68 @@ -0,0 +1,4 @@ +begin + op BAZ = (int a,b,c) int: 10; { dg-error "number of operands" } + skip +end diff --git a/gcc/testsuite/algol68/compile/error-op-numargs-2.a68 b/gcc/testsuite/algol68/compile/error-op-numargs-2.a68 new file mode 100644 index 000000000000..144a6d2a9a86 --- /dev/null +++ b/gcc/testsuite/algol68/compile/error-op-numargs-2.a68 @@ -0,0 +1,4 @@ +begin + op BAZ = int: 10; { dg-error "number of operands" } + skip +end diff --git a/gcc/testsuite/algol68/compile/error-op-numargs-3.a68 b/gcc/testsuite/algol68/compile/error-op-numargs-3.a68 new file mode 100644 index 000000000000..8e6213e1d9fc --- /dev/null +++ b/gcc/testsuite/algol68/compile/error-op-numargs-3.a68 @@ -0,0 +1,8 @@ +begin + op FOO = (real x) real: 1.11; { dg-error "number of operands" } + op BAR = real: 2.22; { dg-error "number of operands" } + + real y := FOO(0.0); + real z := BAR(0.0); + skip +end
