Commit ceeedfc1 by Neil Booth Committed by Neil Booth

c-common.c (c_common_init): Override cpplib's default warn_long_long setting.

	* c-common.c (c_common_init): Override cpplib's default
	warn_long_long setting.
	* c-lex.c (lex_number): Replace with interpret_integer,
	interpret_float, narrowest_unsigned_type and
	narrowest_signed_type, taking advantage of the new
	cpplib functionality.
	* cpperror.c (_cpp_begin_message): If a warning is turned
	into an error, avoid printing "warning:".
	* cppexp.c (cpp_num_sign_extend): New.
	* cppinit.c: Update comment.
	* cpplib.h (cpp_num_sign_extend): New.
	* tree.h: Update comment.
testsuite:
	* gcc.dg/wtr-int-type-1.c, gcc.dg/wtr-suffix-1.c,
	gcc.dg/cpp/paste4.c, gcc.dg/cpp/sysmac2.c:
	Update for mofified diagnostics.
	* gcc.dg/c99-intconst-1.c: No longer fail.

From-SVN: r54180
parent 27e511e0
2002-06-02 Neil Booth <neil@daikokuya.demon.co.uk>
* c-common.c (c_common_init): Override cpplib's default
warn_long_long setting.
* c-lex.c (lex_number): Replace with interpret_integer,
interpret_float, narrowest_unsigned_type and
narrowest_signed_type, taking advantage of the new
cpplib functionality.
* cpperror.c (_cpp_begin_message): If a warning is turned
into an error, avoid printing "warning:".
* cppexp.c (cpp_num_sign_extend): New.
* cppinit.c: Update comment.
* cpplib.h (cpp_num_sign_extend): New.
* tree.h: Update comment.
2002-06-02 Gabriel Dos Reis <gdr@codesourcery.com>
* diagnostic.h (struct diagnostic_context): Add new member
......
......@@ -4510,6 +4510,10 @@ c_common_init (filename)
options->warn_multichar = warn_multichar;
options->stdc_0_in_system_headers = STDC_0_IN_SYSTEM_HEADERS;
/* We want -Wno-long-long to override -pedantic -std=non-c99
whatever the ordering. */
options->warn_long_long = warn_long_long && !flag_isoc99 && pedantic;
/* Register preprocessor built-ins before calls to
cpp_main_file. */
cpp_get_callbacks (parse_in)->register_builtins = cb_register_builtins;
......
......@@ -92,6 +92,7 @@ _cpp_begin_message (pfile, code, line, column)
{
if (CPP_OPTION (pfile, inhibit_errors))
return 0;
level = DL_ERROR;
pfile->errors++;
}
else if (CPP_OPTION (pfile, inhibit_warnings))
......
......@@ -995,6 +995,33 @@ num_positive (num, precision)
return (num.low & (cpp_num_part) 1 << (precision - 1)) == 0;
}
/* Sign extend a number, with PRECISION significant bits and all
others assumed clear, to fill out a cpp_num structure. */
cpp_num
cpp_num_sign_extend (num, precision)
cpp_num num;
size_t precision;
{
if (!num.unsignedp)
{
if (precision > PART_PRECISION)
{
precision -= PART_PRECISION;
if (precision < PART_PRECISION
&& (num.high & (cpp_num_part) 1 << (precision - 1)))
num.high |= ~(~(cpp_num_part) 0 >> (PART_PRECISION - precision));
}
else if (num.low & (cpp_num_part) 1 << (precision - 1))
{
if (precision < PART_PRECISION)
num.low |= ~(~(cpp_num_part) 0 >> (PART_PRECISION - precision));
num.high = ~(cpp_num_part) 0;
}
}
return num;
}
/* Returns the negative of NUM. */
static cpp_num
num_negate (num, precision)
......
......@@ -1770,6 +1770,8 @@ cpp_post_options (pfile)
if (CPP_OPTION (pfile, cplusplus))
CPP_OPTION (pfile, warn_traditional) = 0;
/* The compiler front ends override this, but I think this is the
appropriate setting for the library. */
CPP_OPTION (pfile, warn_long_long) = (CPP_OPTION (pfile, pedantic)
&& !CPP_OPTION (pfile, c99));
......
......@@ -625,6 +625,10 @@ extern unsigned cpp_classify_number PARAMS ((cpp_reader *, const cpp_token *));
extern cpp_num cpp_interpret_integer PARAMS ((cpp_reader *, const cpp_token *,
unsigned int type));
/* Sign extend a number, with PRECISION significant bits and all
others assumed clear, to fill out a cpp_num structure. */
cpp_num cpp_num_sign_extend PARAMS ((cpp_num, size_t));
/* Diagnostic levels. To get a dianostic without associating a
position in the translation unit with it, use cpp_error_with_line
with a line number of zero. */
......
2002-06-02 Neil Booth <neil@daikokuya.demon.co.uk>
* gcc.dg/wtr-int-type-1.c, gcc.dg/wtr-suffix-1.c,
gcc.dg/cpp/paste4.c, gcc.dg/cpp/sysmac2.c:
Update for mofified diagnostics.
* gcc.dg/c99-intconst-1.c: No longer fail.
2002-06-02 Richard Henderson <rth@redhat.com>
* gcc.dg/uninit-A.c: Remove xfail markers.
......
......@@ -4,11 +4,6 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
/* C99 type selection didn't make it into 3.1, so this test
will fail on one or two entries; which ones depends on the
platform.
{ dg-excess-errors "c99 not yet" } */
#include <limits.h>
/* Assertion that constant C is of type T. */
......
......@@ -11,6 +11,6 @@
int main ()
{
double d = glue (1.0e, +1); /* { dg-error "floating const|parse error" } */
double d = glue (1.0e, +1); /* { dg-error "exponent|parse error" } */
return 0;
}
/* Copyright (C) 2001 Free Software Foundation, Inc. */
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -pedantic -Wtraditional" } */
/* { dg-options "-std=gnu99 -pedantic -Wtraditional -fno-show-column" } */
/* Tests diagnostics are suppressed for some macros defined in system
headers. */
......
......@@ -2,7 +2,7 @@
Note, gcc should omit these warnings in system header files.
By Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 8/22/2000. */
/* { dg-do compile } */
/* { dg-options "-Wtraditional" } */
/* { dg-options "-std=c99 -Wtraditional" } */
void
testfunc (void)
......@@ -18,12 +18,14 @@ testfunc (void)
i = 0xFFFFFFFFFFFFFFFF;
i = 01777777777777777777777;
/* We expect to get either a "width of integer constant changes with
-traditional" warning or an "integer constant is unsigned in ISO
C, signed with -traditional" warning depending on whether we are
testing on a 32 or 64 bit platform. Either warning means the
test passes and both matched by checking for "integer constant". */
i = 18446744073709551615; /* { dg-warning "integer constant" "integer constant" } */
/* Nor should values outside the range of (32-bit) unsigned long but
inside the range of long long. [since -traditional has no long long,
we can pretend it worked the way it does in C99.] */
i = 9223372036854775807;
/* But this one should, since it doesn't fit in long (long), but
does fit in unsigned long (long). */
i = 18446744073709551615; /* { dg-warning "decimal constant|unsigned" "decimal constant" } */
# 29 "sys-header.h" 3
/* We are in system headers now, no -Wtraditional warnings should issue. */
......@@ -39,6 +41,3 @@ testfunc (void)
i = 9223372036854775807;
i = 18446744073709551615;
}
/* Ignore "decimal constant is so large that it is unsigned" warnings. */
/* { dg-warning "decimal constant" "decimal constant" { target *-*-* } 26 } */
......@@ -12,13 +12,13 @@ testfunc (void)
i = 1L;
i = 1l;
i = 1U; /* { dg-warning "traditional C rejects the 'u' suffix" "numeric constant suffix" } */
i = 1u; /* { dg-warning "traditional C rejects the 'u' suffix" "numeric constant suffix" } */
i = 1U; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */
i = 1u; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */
f = 1.0;
f = 1.0F; /* { dg-warning "traditional C rejects the 'f' suffix" "numeric constant suffix" } */
f = 1.0f; /* { dg-warning "traditional C rejects the 'f' suffix" "numeric constant suffix" } */
f = 1.0L; /* { dg-warning "traditional C rejects the 'l' suffix" "numeric constant suffix" } */
f = 1.0l; /* { dg-warning "traditional C rejects the 'l' suffix" "numeric constant suffix" } */
f = 1.0F; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */
f = 1.0f; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */
f = 1.0L; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */
f = 1.0l; /* { dg-warning "traditional C rejects" "numeric constant suffix" } */
# 24 "sys-header.h" 3
/* We are in system headers now, no -Wtraditional warnings should issue. */
......
......@@ -2027,7 +2027,9 @@ extern tree global_trees[TI_MAX];
#define V16SF_type_node global_trees[TI_V16SF_TYPE]
/* An enumeration of the standard C integer types. These must be
ordered so that shorter types appear before longer ones. */
ordered so that shorter types appear before longer ones, and so
that signed types appear before unsigned ones, for the correct
functioning of interpret_integer() in c-lex.c. */
enum integer_type_kind
{
itk_char,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment