]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR modula2/109586 cc1gm2 ICE when compiling large source files.
authorGaius Mulley <gaiusmod2@gmail.com>
Fri, 21 Apr 2023 12:19:54 +0000 (13:19 +0100)
committerGaius Mulley <gaiusmod2@gmail.com>
Fri, 21 Apr 2023 12:19:54 +0000 (13:19 +0100)
The function m2block_RememberConstant calls m2tree_IsAConstant.
However IsAConstant does not recognise TREE_CODE(t) ==
CONSTRUCTOR as a constant.  Without this patch CONSTRUCTOR
contants are garbage collected (and not preserved) resulting in
a corrupt tree and crash.

gcc/m2/ChangeLog:

PR modula2/109586
* gm2-gcc/m2tree.cc (m2tree_IsAConstant): Add (TREE_CODE
(t) == CONSTRUCTOR) to expression.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
gcc/m2/gm2-gcc/m2tree.cc

index 33dc57d5df76d58d6a3ad1168ac36aa087686585..0fc2fe57b6322b5a217fad8b5ca24b704340ba98 100644 (file)
@@ -120,8 +120,8 @@ bool
 m2tree_IsAConstant (tree t)
 {
   return (TREE_CODE (t) == INTEGER_CST) || (TREE_CODE (t) == REAL_CST)
-         || (TREE_CODE (t) == REAL_CST) || (TREE_CODE (t) == COMPLEX_CST)
-         || (TREE_CODE (t) == STRING_CST);
+    || (TREE_CODE (t) == REAL_CST) || (TREE_CODE (t) == COMPLEX_CST)
+    || (TREE_CODE (t) == STRING_CST) || (TREE_CODE (t) == CONSTRUCTOR);
 }