aboutsummaryrefslogtreecommitdiff
path: root/gcc/m2/gm2-gcc
diff options
context:
space:
mode:
authorGaius Mulley <gaiusmod2@gmail.com>2023-04-13 17:02:48 +0100
committerGaius Mulley <gaiusmod2@gmail.com>2023-04-13 17:02:48 +0100
commita1afdc6e2aa77d0a990e1a82aceeffc837b7e50c (patch)
tree914badeca002aff6b9ecf223c05cb749804e7f4d /gcc/m2/gm2-gcc
parent66946624b96b762985de56444d726a0ebd4e0df5 (diff)
downloadgcc-a1afdc6e2aa77d0a990e1a82aceeffc837b7e50c.zip
gcc-a1afdc6e2aa77d0a990e1a82aceeffc837b7e50c.tar.gz
gcc-a1afdc6e2aa77d0a990e1a82aceeffc837b7e50c.tar.bz2
PR modula2/109496 Fix constant char parameter passing to an array of char
This patch fixes PR modula2/109496 and PR modula2/109497. The fix for PR modula2/109496 promotes a char constant to a string. The PR modula2/109497 allows for constant chars to be added to form a string. The fixes for both PR's occur in M2GenGCC.mod and M2GCCDeclare.mod after the resolving of constant declarations. gcc/m2/ChangeLog: * gm2-compiler/M2ALU.def (PopChar): New procedure function. * gm2-compiler/M2ALU.mod (PopChar): New procedure function. * gm2-compiler/M2GCCDeclare.mod (PromoteToString): Detect a single constant char and build a C string. * gm2-compiler/M2GenGCC.mod (IsConstStr): New procedure function. (GetStr): New procedure function. (FoldAdd): Use IsConstStr. * gm2-compiler/M2Quads.mod: Formatting changes. * gm2-gcc/m2expr.cc (m2expr_GetCstInteger): New function. * gm2-gcc/m2expr.def (GetCstInteger): New procedure function. * gm2-gcc/m2expr.h (m2expr_GetCstInteger): New prototype. gcc/testsuite/ChangeLog: PR modula2/109497 * gm2/pim/run/pass/addcharconst.mod: New test. PR modula2/109496 * gm2/pim/run/pass/singlechar.mod: New test. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
Diffstat (limited to 'gcc/m2/gm2-gcc')
-rw-r--r--gcc/m2/gm2-gcc/m2expr.cc10
-rw-r--r--gcc/m2/gm2-gcc/m2expr.def7
-rw-r--r--gcc/m2/gm2-gcc/m2expr.h1
3 files changed, 18 insertions, 0 deletions
diff --git a/gcc/m2/gm2-gcc/m2expr.cc b/gcc/m2/gm2-gcc/m2expr.cc
index ef8368a..a319960 100644
--- a/gcc/m2/gm2-gcc/m2expr.cc
+++ b/gcc/m2/gm2-gcc/m2expr.cc
@@ -4283,6 +4283,16 @@ build_set_full_complement (location_t location)
return value;
}
+
+/* GetCstInteger return the integer value of the cst tree. */
+
+int
+m2expr_GetCstInteger (tree cst)
+{
+ return TREE_INT_CST_LOW (cst);
+}
+
+
/* init initialise this module. */
void
diff --git a/gcc/m2/gm2-gcc/m2expr.def b/gcc/m2/gm2-gcc/m2expr.def
index c43f020..cc80ded 100644
--- a/gcc/m2/gm2-gcc/m2expr.def
+++ b/gcc/m2/gm2-gcc/m2expr.def
@@ -584,6 +584,13 @@ PROCEDURE IsFalse (t: Tree) : BOOLEAN ;
(*
+ GetCstInteger - return the integer value of the cst tree.
+*)
+
+PROCEDURE GetCstInteger (cst: Tree) : INTEGER ;
+
+
+(*
AreConstantsEqual - maps onto tree.c (tree_int_cst_equal). It returns
TRUE if the value of e1 is the same as e2.
*)
diff --git a/gcc/m2/gm2-gcc/m2expr.h b/gcc/m2/gm2-gcc/m2expr.h
index 3701bcd..86e3bab 100644
--- a/gcc/m2/gm2-gcc/m2expr.h
+++ b/gcc/m2/gm2-gcc/m2expr.h
@@ -234,6 +234,7 @@ EXTERN void m2expr_ConstantExpressionWarning (tree value);
EXTERN tree m2expr_BuildAddAddress (location_t location, tree op1, tree op2);
EXTERN tree m2expr_BuildRDiv (location_t location, tree op1, tree op2,
bool needconvert);
+EXTERN int m2expr_GetCstInteger (tree cst);
EXTERN void m2expr_init (location_t location);