aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/c-common.c8
-rw-r--r--gcc/c-decl.c18
-rw-r--r--gcc/c-lex.c18
-rw-r--r--gcc/c-tree.h4
-rw-r--r--gcc/c-typeck.c7
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c17
-rw-r--r--gcc/cp/lex.c9
-rw-r--r--gcc/cp/typeck.c7
11 files changed, 108 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c3ef1de..bc5da17 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+Fri Jul 2 13:23:39 1999 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * c-decl.c (widest_integer_literal_type_node,
+ widest_unsigned_literal_type) : New.
+ (init_decl_processing): Handle/use the two new types.
+ * c-common.c (type_for_size,type_for_mode) : Same.
+ * c-lex.c (yylex) : Same.
+ * c-typeck.c (unsigned_type,signed_type,signed_or_unsigned_type) :
+ Same.
+ * c-tree.h (widest_integer_literal_type_node,
+ widest_unsigned_literal_type) : New.
+
Fri Jul 2 03:05:44 1999 Jeffrey A Law (law@cygnus.com)
* dwarfout.c (field_byte_offset): Correctly compute the object's
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 1ec3842..f1a61cd 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -2081,6 +2081,10 @@ type_for_size (bits, unsignedp)
return (unsignedp ? long_long_unsigned_type_node
: long_long_integer_type_node);
+ if (bits == TYPE_PRECISION (widest_integer_literal_type_node))
+ return (unsignedp ? widest_unsigned_literal_type_node
+ : widest_integer_literal_type_node);
+
if (bits <= TYPE_PRECISION (intQI_type_node))
return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
@@ -2120,6 +2124,10 @@ type_for_mode (mode, unsignedp)
if (mode == TYPE_MODE (long_long_integer_type_node))
return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
+ if (mode == TYPE_MODE (widest_integer_literal_type_node))
+ return unsignedp ? widest_unsigned_literal_type_node
+ : widest_integer_literal_type_node;
+
if (mode == TYPE_MODE (intQI_type_node))
return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index a232217..97db33f 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -123,6 +123,14 @@ tree unsigned_type_node;
tree long_unsigned_type_node;
tree long_long_unsigned_type_node;
+/* These are used for integer literals that are larger than
+ a long long. The largest integer literals we can handle
+ are the width of two HOST_WIDE_INTs. If two HOST_WIDE_INTs
+ are not larger than the target's long long, then these
+ will never be used. */
+tree widest_integer_literal_type_node;
+tree widest_unsigned_literal_type_node;
+
tree boolean_type_node;
tree boolean_false_node;
tree boolean_true_node;
@@ -3103,6 +3111,16 @@ init_decl_processing ()
pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned char"),
unsigned_char_type_node));
+ /* Create the widest literal types. */
+ widest_integer_literal_type_node = make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ widest_integer_literal_type_node));
+
+ widest_unsigned_literal_type_node = make_unsigned_type (HOST_BITS_PER_WIDE_INT * 2);
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ widest_unsigned_literal_type_node));
+
+ /* Now all the integer mode types. */
intQI_type_node = make_signed_type (GET_MODE_BITSIZE (QImode));
pushdecl (build_decl (TYPE_DECL, NULL_TREE, intQI_type_node));
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 214bcd1..ed825ee 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -1818,10 +1818,17 @@ yylex ()
else if (! spec_long_long)
traditional_type = (spec_unsigned ? long_unsigned_type_node
: long_integer_type_node);
- else
+ else if (int_fits_type_p (yylval.ttype,
+ spec_unsigned
+ ? long_long_unsigned_type_node
+ : long_long_integer_type_node))
traditional_type = (spec_unsigned
? long_long_unsigned_type_node
: long_long_integer_type_node);
+ else
+ traditional_type = (spec_unsigned
+ ? widest_unsigned_literal_type_node
+ : widest_integer_literal_type_node);
}
if (warn_traditional || ! flag_traditional)
{
@@ -1843,8 +1850,15 @@ yylex ()
&& int_fits_type_p (yylval.ttype,
long_long_integer_type_node))
ansi_type = long_long_integer_type_node;
- else
+ else if (int_fits_type_p (yylval.ttype,
+ long_long_unsigned_type_node))
ansi_type = long_long_unsigned_type_node;
+ else if (! spec_unsigned
+ && int_fits_type_p (yylval.ttype,
+ widest_integer_literal_type_node))
+ ansi_type = widest_integer_literal_type_node;
+ else
+ ansi_type = widest_unsigned_literal_type_node;
}
type = flag_traditional ? traditional_type : ansi_type;
diff --git a/gcc/c-tree.h b/gcc/c-tree.h
index bcf325b..7e01356 100644
--- a/gcc/c-tree.h
+++ b/gcc/c-tree.h
@@ -246,9 +246,11 @@ extern tree integer_type_node;
extern tree long_double_type_node;
extern tree long_ftype_long;
extern tree long_integer_type_node;
+extern tree long_unsigned_type_node;
extern tree long_long_integer_type_node;
extern tree long_long_unsigned_type_node;
-extern tree long_unsigned_type_node;
+extern tree widest_integer_literal_type_node;
+extern tree widest_unsigned_literal_type_node;
extern tree complex_integer_type_node;
extern tree complex_float_type_node;
extern tree complex_double_type_node;
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 95d417e..ca98655 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -739,6 +739,8 @@ unsigned_type (type)
return long_unsigned_type_node;
if (type1 == long_long_integer_type_node)
return long_long_unsigned_type_node;
+ if (type1 == widest_integer_literal_type_node)
+ return widest_unsigned_literal_type_node;
if (type1 == intDI_type_node)
return unsigned_intDI_type_node;
if (type1 == intSI_type_node)
@@ -768,6 +770,8 @@ signed_type (type)
return long_integer_type_node;
if (type1 == long_long_unsigned_type_node)
return long_long_integer_type_node;
+ if (type1 == widest_unsigned_literal_type_node)
+ return widest_integer_literal_type_node;
if (type1 == unsigned_intDI_type_node)
return intDI_type_node;
if (type1 == unsigned_intSI_type_node)
@@ -802,6 +806,9 @@ signed_or_unsigned_type (unsignedp, type)
if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node))
return (unsignedp ? long_long_unsigned_type_node
: long_long_integer_type_node);
+ if (TYPE_PRECISION (type) == TYPE_PRECISION (widest_integer_literal_type_node))
+ return (unsignedp ? widest_unsigned_literal_type_node
+ : widest_integer_literal_type_node);
return type;
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e3ea60d..40d5aac 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,14 @@
+1999-07-02 Gavin Romig-Koch <gavin@cygnus.com>
+
+ * cp-tree.h (widest_integer_literal_type_node,
+ widest_unsigned_literal_type) : New.
+ * decl.c (widest_integer_literal_type_node,
+ widest_unsigned_literal_type) : New.
+ (init_decl_processing): Handle/use the two new types.
+ * lex.c (real_yylex): Same.
+ * typeck.c (unsigned_type,signed_type,signed_or_unsigned_type) :
+ Same.
+
1999-07-01 Mark Mitchell <mark@codesourcery.com>
* decl.c (grokdeclarator): Don't give names "for linkage purposes"
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4d243b4..28c7e3f 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -336,6 +336,7 @@ extern tree ptrdiff_type_node;
extern tree short_integer_type_node, short_unsigned_type_node;
extern tree long_integer_type_node, long_unsigned_type_node;
extern tree long_long_integer_type_node, long_long_unsigned_type_node;
+extern tree widest_integer_literal_type_node, widest_unsigned_literal_type_node;
extern tree unsigned_type_node;
extern tree string_type_node, char_array_type_node, int_array_type_node;
extern tree wchar_array_type_node;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b7a36de..1b6b268 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -220,6 +220,14 @@ tree unsigned_type_node;
tree long_unsigned_type_node;
tree long_long_unsigned_type_node;
+/* These are used for integer literals that are larger than
+ a long long. The largest integer literals we can handle
+ are the width of two HOST_WIDE_INTs. If two HOST_WIDE_INTs
+ are not larger than the target's long long, then these
+ will never be used. */
+tree widest_integer_literal_type_node;
+tree widest_unsigned_literal_type_node;
+
tree ptrdiff_type_node;
tree unsigned_char_type_node;
@@ -6356,6 +6364,15 @@ init_decl_processing ()
unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
record_builtin_type (RID_MAX, "unsigned char", unsigned_char_type_node);
+ /* Create the widest literal types. */
+ widest_integer_literal_type_node = make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ widest_integer_literal_type_node));
+
+ widest_unsigned_literal_type_node = make_unsigned_type (HOST_BITS_PER_WIDE_INT * 2);
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ widest_unsigned_literal_type_node));
+
/* These are types that type_for_size and type_for_mode use. */
intQI_type_node = make_signed_type (GET_MODE_BITSIZE (QImode));
pushdecl (build_decl (TYPE_DECL, NULL_TREE, intQI_type_node));
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 5448990..303306a 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -3937,8 +3937,15 @@ real_yylex ()
&& int_fits_type_p (yylval.ttype,
long_long_integer_type_node))
type = long_long_integer_type_node;
- else
+ else if (int_fits_type_p (yylval.ttype,
+ long_long_unsigned_type_node))
type = long_long_unsigned_type_node;
+ else if (! spec_unsigned
+ && int_fits_type_p (yylval.ttype,
+ widest_integer_literal_type_node))
+ type = widest_integer_literal_type_node;
+ else
+ type = widest_unsigned_literal_type_node;
if (!int_fits_type_p (yylval.ttype, type) && !warn)
pedwarn ("integer constant is larger than the maximum value for its type");
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9e41af3..81fa2963 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1475,6 +1475,8 @@ unsigned_type (type)
return long_unsigned_type_node;
if (type1 == long_long_integer_type_node)
return long_long_unsigned_type_node;
+ if (type1 == widest_integer_literal_type_node)
+ return widest_unsigned_literal_type_node;
#if HOST_BITS_PER_WIDE_INT >= 64
if (type1 == intTI_type_node)
return unsigned_intTI_type_node;
@@ -1508,6 +1510,8 @@ signed_type (type)
return long_integer_type_node;
if (type1 == long_long_unsigned_type_node)
return long_long_integer_type_node;
+ if (type1 == widest_unsigned_literal_type_node)
+ return widest_integer_literal_type_node;
#if HOST_BITS_PER_WIDE_INT >= 64
if (type1 == unsigned_intTI_type_node)
return intTI_type_node;
@@ -1547,6 +1551,9 @@ signed_or_unsigned_type (unsignedp, type)
if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node))
return (unsignedp ? long_long_unsigned_type_node
: long_long_integer_type_node);
+ if (TYPE_PRECISION (type) == TYPE_PRECISION (widest_integer_literal_type_node))
+ return (unsignedp ? widest_unsigned_literal_type_node
+ : widest_integer_literal_type_node);
return type;
}