Commit cd7ab83f by Neil Booth Committed by Neil Booth

cppexp.c (cpp_num): Move to cpplib.h.

2002-05-29  Neil Booth  <neil@daikokuya.demon.co.uk>
	    Zack Weinberg <zack@codesourcery.com>

	* cppexp.c (cpp_num): Move to cpplib.h.
	(CPP_ERROR): Remove.
	(interpret_float_suffix, interpret_int_suffix): New.
	(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
	(cpp_classify_number, cpp_interpret_integer): New.
	(interpret_number): Remove.
	(eval_token): Update to use new routines.
	* cpphash.h (cpp_num_part): Move to cpplib.h.
	* cppinit.c (cpp_post_options): Set warn_long_long.
	* cpplib.h (struct cpp_options): Add warn_long_long.
	(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
	CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
	CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
	CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
	cpp_interpret_integer): New.
testsuite:
	* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
	gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
	gcc.dg/cpp/if-1.c: Update for modified diagnostics.

Co-Authored-By: Zack Weinberg <zack@codesourcery.com>

From-SVN: r54007
parent 61a8515c
2002-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
Zack Weinberg <zack@codesourcery.com>
* cppexp.c (cpp_num): Move to cpplib.h.
(CPP_ERROR): Remove.
(interpret_float_suffix, interpret_int_suffix): New.
(struct suffix, vsuf_1, vsuf_2, vsuf_3): Remove.
(cpp_classify_number, cpp_interpret_integer): New.
(interpret_number): Remove.
(eval_token): Update to use new routines.
* cpphash.h (cpp_num_part): Move to cpplib.h.
* cppinit.c (cpp_post_options): Set warn_long_long.
* cpplib.h (struct cpp_options): Add warn_long_long.
(cpp_num, cpp_num_part, CPP_N_CATEGORY, CPP_N_INVALID,
CPP_N_INTEGER, CPP_N_FLOATING, CPP_N_WIDTH, CPP_N_SMALL,
CPP_N_MEDIUM, CPP_N_LARGE, CPP_N_RADIX, CPP_N_DEC, CPP_N_HEX,
CPP_N_OCTAL, CPP_N_UNSIGNED, CPP_N_IMAGINARY, cpp_classify_number,
cpp_interpret_integer): New.
2002-05-29 Joel Sherrill <joel@OARcorp.com>
* config/rs6000/rs6000.h (ASM_CPU_SPEC): Use -m403 and -m405.
......
......@@ -29,7 +29,6 @@ struct directive; /* Deliberately incomplete. */
struct pending_option;
struct op;
typedef unsigned HOST_WIDE_INT cpp_num_part;
typedef unsigned char uchar;
#define U (const uchar *) /* Intended use: U"string" */
......
......@@ -1774,6 +1774,9 @@ cpp_post_options (pfile)
if (CPP_OPTION (pfile, cplusplus))
CPP_OPTION (pfile, warn_traditional) = 0;
CPP_OPTION (pfile, warn_long_long) = (CPP_OPTION (pfile, pedantic)
&& !CPP_OPTION (pfile, c99));
/* Permanently disable macro expansion if we are rescanning
preprocessed text. Read preprocesed source in ISO mode. */
if (CPP_OPTION (pfile, preprocessed))
......
......@@ -327,6 +327,9 @@ struct cpp_options
traditional C. */
unsigned char warn_traditional;
/* Nonzero means warn about long long numeric constants. */
unsigned char warn_long_long;
/* Nonzero means warn about text after an #endif (or #else). */
unsigned char warn_endif_labels;
......@@ -577,6 +580,51 @@ extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *,
int, int));
extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
/* A preprocessing number. Code assumes that any unused high bits of
the double integer are set to zero. */
typedef unsigned HOST_WIDE_INT cpp_num_part;
typedef struct cpp_num cpp_num;
struct cpp_num
{
cpp_num_part high;
cpp_num_part low;
bool unsignedp; /* True if value should be treated as unsigned. */
bool overflow; /* True if the most recent calculation overflowed. */
};
/* cpplib provides two interfaces for interpretation of preprocessing
numbers.
cpp_classify_number categorizes numeric constants according to
their field (integer, floating point, or invalid), radix (decimal,
octal, hexadecimal), and type suffixes. */
#define CPP_N_CATEGORY 0x000F
#define CPP_N_INVALID 0x0000
#define CPP_N_INTEGER 0x0001
#define CPP_N_FLOATING 0x0002
#define CPP_N_WIDTH 0x00F0
#define CPP_N_SMALL 0x0010 /* int, float. */
#define CPP_N_MEDIUM 0x0020 /* long, double. */
#define CPP_N_LARGE 0x0040 /* long long, long double. */
#define CPP_N_RADIX 0x0F00
#define CPP_N_DECIMAL 0x0100
#define CPP_N_HEX 0x0200
#define CPP_N_OCTAL 0x0400
#define CPP_N_UNSIGNED 0x1000 /* Properties. */
#define CPP_N_IMAGINARY 0x2000
/* Classify a CPP_NUMBER token. The return value is a combination of
the flags from the above sets. */
extern unsigned cpp_classify_number PARAMS ((cpp_reader *, const cpp_token *));
/* Evaluate a token classified as category CPP_N_INTEGER. */
extern cpp_num cpp_interpret_integer PARAMS ((cpp_reader *, const cpp_token *,
unsigned int type));
/* 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-05-29 Neil Booth <neil@daikokuya.demon.co.uk>
* gcc.dg/cpp/c++98-pedantic.c, gcc.dg/cpp/c89-pedantic.c,
gcc.dg/cpp/c94-pedantic.c, gcc.dg/cpp/gnuc89-pedantic.c,
gcc.dg/cpp/if-1.c: Update for modified diagnostics.
2002-05-29 Hans-Peter Nilsson <hp@axis.com>
* gcc.c-torture/execute/20020529-1.c: New test.
......
......@@ -6,5 +6,5 @@
/* This file is for testing the preprocessor in -std=c++98 -pedantic mode.
Neil Booth, 2 Dec 2000. */
#if 1LL /* { dg-warning "too many" } */
#if 1LL /* { dg-warning "long long" } */
#endif
......@@ -6,5 +6,5 @@
/* This file is for testing the preprocessor in -std=c89 -pedantic mode.
Neil Booth, 2 Dec 2000. */
#if 1LL /* { dg-warning "too many" } */
#if 1LL /* { dg-warning "long long" } */
#endif
......@@ -6,5 +6,5 @@
/* This file is for testing the preprocessor in -std=iso9899:199409
-pedantic mode. Neil Booth, 2 Dec 2000. */
#if 1LL /* { dg-warning "too many" } */
#if 1LL /* { dg-warning "long long" } */
#endif
......@@ -6,5 +6,5 @@
/* This file is for testing the preprocessor in -std=gnu89 -pedantic mode.
Neil Booth, 2 Dec 2000. */
#if 1LL /* { dg-warning "too many" } */
#if 1LL /* { dg-warning "long long" } */
#endif
......@@ -22,7 +22,7 @@
#error 0xabc /* { dg-bogus "#error" "normal conversion" } */
#endif
#if 1.2 /* { dg-error "loating point numbers" "floating point in #if" } */
#if 1.2 /* { dg-error "loating constant" "floating point in #if" } */
#endif
#if 4uu /* { dg-error "invalid suffix" "too many suffixes" } */
......@@ -34,7 +34,7 @@
#if 1234lul /* { dg-error "invalid suffix" "u between ls" } */
#endif
#if 099 /* { dg-error "digits beyond the radix" "decimal in octal constant" } */
#if 099 /* { dg-error "invalid digit" "decimal in octal constant" } */
#endif
#if 0xfffffffffffffffff /* { dg-error "integer constant" "range error" } */
......
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