* 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.
For gcc/cp:
	* 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.

From-SVN: r27923
This commit is contained in:
Gavin Romig-Koch 1999-07-02 10:30:01 +00:00 committed by Gavin Romig-Koch
parent e75a9d7719
commit 835f9b4dad
11 changed files with 108 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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));

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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"

View File

@ -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;

View File

@ -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));

View File

@ -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");

View File

@ -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;
}