From c93e9e16fb2f98cf147efa3710c7d41fceecff54 Mon Sep 17 00:00:00 2001
From: "James A. Morrison" <phython@gcc.gnu.org>
Date: Sat, 26 Feb 2005 14:01:03 +0000
Subject: [PATCH] parse.y: Do comparisons as the type of the first expression.

2005-02-26  James A. Morrison  <phython@gcc.gnu.org>

        * parse.y: Do comparisons as the type of the first expression.
        * treetree.c (tree_code_get_integer_value): Build integer constants
        with the proper type.

From-SVN: r95578
---
 gcc/treelang/ChangeLog  | 6 ++++++
 gcc/treelang/parse.y    | 5 ++++-
 gcc/treelang/treetree.c | 3 ++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/treelang/ChangeLog b/gcc/treelang/ChangeLog
index ec9c1c3006a8..c1a2da611900 100644
--- a/gcc/treelang/ChangeLog
+++ b/gcc/treelang/ChangeLog
@@ -1,3 +1,9 @@
+2005-02-26  James A. Morrison  <phython@gcc.gnu.org>
+
+	* parse.y: Do comparisons as the type of the first expression.
+	* treetree.c (tree_code_get_integer_value): Build integer constants
+	with the proper type.
+
 2005-02-26  James A. Morrison  <phython@gcc.gnu.org>
 
 	* Make-lang.in: Remove commented out code.
diff --git a/gcc/treelang/parse.y b/gcc/treelang/parse.y
index 7ee71ec5a9c7..abf2bcbf795f 100644
--- a/gcc/treelang/parse.y
+++ b/gcc/treelang/parse.y
@@ -591,8 +591,11 @@ INTEGER {
   struct prod_token_parm_item *tok = $2;
   struct prod_token_parm_item *op1 = $1;
   struct prod_token_parm_item *op2 = $3;
+  int type_code = NUMERIC_TYPE (op1);
+  if (!type_code)
+    YYERROR;
   $$ = make_plus_expression
-     (tok, op1, op2, SIGNED_INT, EXP_EQUALS);
+     (tok, op1, op2, type_code, EXP_EQUALS);
 }
 |variable_ref ASSIGN expression {
   struct prod_token_parm_item *tok = $2;
diff --git a/gcc/treelang/treetree.c b/gcc/treelang/treetree.c
index eef293bb2f76..dcb7cd351a05 100644
--- a/gcc/treelang/treetree.c
+++ b/gcc/treelang/treetree.c
@@ -650,7 +650,8 @@ tree_code_get_integer_value (unsigned char* chars, unsigned int length)
   for (ix = start; ix < length; ix++)
     val = val * 10 + chars[ix] - (unsigned char)'0';
   val = val*negative;
-  return build_int_cst_wide (NULL_TREE,
+  return build_int_cst_wide (start == 1 ?
+				integer_type_node : unsigned_type_node,
 			     val & 0xffffffff, (val >> 32) & 0xffffffff);
 }
 
-- 
GitLab