diff options
-rw-r--r-- | gcc/ChangeLog | 21 | ||||
-rw-r--r-- | gcc/config/convex/fixinc.convex | 10 | ||||
-rw-r--r-- | gcc/cp/rtti.c | 8 | ||||
-rw-r--r-- | gcc/cppexp.c | 5 | ||||
-rw-r--r-- | gcc/cppinit.c | 4 | ||||
-rw-r--r-- | gcc/cpplex.c | 12 | ||||
-rw-r--r-- | gcc/cpplib.c | 9 | ||||
-rw-r--r-- | gcc/enquire.c | 2 | ||||
-rwxr-xr-x | gcc/fixinc/fixinc.irix | 4 | ||||
-rwxr-xr-x | gcc/fixinc/fixinc.sco | 2 | ||||
-rwxr-xr-x | gcc/fixinc/fixinc.wrap | 6 | ||||
-rw-r--r-- | gcc/fixinc/fixincl.x | 6 | ||||
-rw-r--r-- | gcc/fixinc/inclhack.def | 6 | ||||
-rwxr-xr-x | gcc/fixinc/inclhack.sh | 6 | ||||
-rw-r--r-- | gcc/gsyslimits.h | 2 | ||||
-rw-r--r-- | gcc/limity.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp-as1.c (renamed from gcc/testsuite/gcc.c-torture/compile/981211-1.c) | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp-as2.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/cpp-tradwarn1.c | 30 |
20 files changed, 122 insertions, 48 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 099177cc954..acb203488c7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,24 @@ +2000-04-02 Zack Weinberg <zack@wolery.cumb.org> + + * cppinit.c (cpp_start_read): Turn off -Wtraditional if + processing C++. + * cpplib.c (_cpp_handle_directive): Improve warnings for + traditional C and indented directives. + + * enquire.c, gsyslimits.h, limity.h, config/convex/fixinc.convex, + fixinc/fixinc.irix, fixinc/fixinc.sco, fixinc/fixinc.wrap, + fixinc/inclhack.def: Indent the # of #include_next one space. + * cp/rtti.c: Un-indent #if and #endif. + + * cppexp.c (_cpp_parse_expr): If lex returns '#', it's a + syntax error, but an error has already been printed. + * cpplex.c (_cpp_parse_assertion): Give a more specific error + message when called with nothing remaining on the line. + (_cpp_lex_token): If _cpp_parse_assertion fails, return an + OTHER token, not an ASSERTION. + * cpplib.c (do_assert): When we create a 'base' node, clear + its aschain pointer. + 2000-04-02 Neil Booth <NeilB@earthling.net> * cppexp.c: New typedef op_t. struct operation and struct diff --git a/gcc/config/convex/fixinc.convex b/gcc/config/convex/fixinc.convex index 0dc5f302c8c..c14dcd42b03 100644 --- a/gcc/config/convex/fixinc.convex +++ b/gcc/config/convex/fixinc.convex @@ -15,7 +15,7 @@ sed 's/^@//' > "include/limits.h" <<'@//E*O*F include/limits.h//' #ifndef _LIMITS_H #define _LIMITS_H -#include_next <limits.h> + #include_next <limits.h> /* Minimum and maximum values a `char' can hold. */ #ifdef __CHAR_UNSIGNED__ @@ -34,7 +34,7 @@ sed 's/^@//' > "include/math.h" <<'@//E*O*F include/math.h//' #ifndef _MATH_H #define _MATH_H -#include_next <math.h> + #include_next <math.h> #undef HUGE_VAL @@ -386,7 +386,7 @@ typedef __WCHAR_TYPE__ wchar_t; #endif /* __WCHAR_T */ -#include_next <stddef.h> + #include_next <stddef.h> #endif /* _STDDEF_H */ @//E*O*F include/stddef.h// @@ -400,12 +400,12 @@ sed 's/^@//' > "include/stdlib.h" <<'@//E*O*F include/stdlib.h//' #if _CONVEX_SOURCE #define alloca __non_builtin_alloca -#include_next <stdlib.h> + #include_next <stdlib.h> #undef alloca #else -#include_next <stdlib.h> + #include_next <stdlib.h> #endif /* _CONVEX_SOURCE */ diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index a91bef857b4..e9873ba9718 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1816,9 +1816,9 @@ emit_support_tinfos () &void_type_node, &boolean_type_node, &wchar_type_node, - #if 0 +#if 0 &signed_wchar_type_node, &unsigned_wchar_type_node, - #endif +#endif &char_type_node, &signed_char_type_node, &unsigned_char_type_node, &short_integer_type_node, &short_unsigned_type_node, &integer_type_node, &unsigned_type_node, @@ -1827,11 +1827,11 @@ emit_support_tinfos () &float_type_node, &double_type_node, &long_double_type_node, /* GCC extension types */ - #if 0 +#if 0 &complex_integer_type_node, &complex_float_type_node, &complex_double_type_node, &complex_long_double_type_node, - #endif +#endif 0 }; diff --git a/gcc/cppexp.c b/gcc/cppexp.c index a2c60b71935..b89eca8e58e 100644 --- a/gcc/cppexp.c +++ b/gcc/cppexp.c @@ -785,6 +785,11 @@ _cpp_parse_expr (pfile) cpp_ice (pfile, "lex returns a NAME"); case ERROR: goto syntax_error; + case '#': + /* We get '#' when get_directive_token hits a syntactically + invalid assertion predicate. _cpp_parse_assertion has + already issued an error. */ + goto syntax_error; default: cpp_error (pfile, "invalid character in #if"); goto syntax_error; diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 93298efeec9..62da1f34238 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -852,6 +852,10 @@ cpp_start_read (pfile, fname) CPP_OPTION (pfile, trigraphs) = 0; } + /* -Wtraditional is not useful in C++ mode. */ + if (CPP_OPTION (pfile, cplusplus)) + CPP_OPTION (pfile, warn_traditional) = 0; + /* Set this if it hasn't been set already. */ if (user_label_prefix == NULL) user_label_prefix = USER_LABEL_PREFIX; diff --git a/gcc/cpplex.c b/gcc/cpplex.c index b0d3f5f8cfc..a57eb8b7f47 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -604,7 +604,12 @@ _cpp_parse_assertion (pfile) int c, dropwhite; _cpp_skip_hspace (pfile); c = PEEKC(); - if (! is_idstart(c)) + if (c == '\n') + { + cpp_error (pfile, "assertion without predicate"); + return 0; + } + else if (! is_idstart(c)) { cpp_error (pfile, "assertion predicate is not an identifier"); return 0; @@ -709,8 +714,9 @@ _cpp_lex_token (pfile) if (pfile->parsing_if_directive) { _cpp_skip_hspace (pfile); - _cpp_parse_assertion (pfile); - return CPP_ASSERTION; + if (_cpp_parse_assertion (pfile)) + return CPP_ASSERTION; + goto randomchar; } if (pfile->parsing_define_directive && ! CPP_TRADITIONAL (pfile)) diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 747f6f52821..2c24de8598e 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -232,11 +232,11 @@ _cpp_handle_directive (pfile) if (CPP_WTRADITIONAL (pfile)) { if (!hash_at_bol && dtable[i].origin == KANDR) - cpp_warning (pfile, "the # in #%s should be at the left margin", + cpp_warning (pfile, "traditional C ignores #%s with the # indented", dtable[i].name); else if (hash_at_bol && dtable[i].origin != KANDR) cpp_warning (pfile, - "the # in #%s should not be at the left margin", + "traditional C rejects #%s unless the # is indented", dtable[i].name); } @@ -1658,7 +1658,10 @@ do_assert (pfile) bslot = _cpp_lookup_slot (pfile, sym, blen, 1, &bhash); if (! *bslot) - *bslot = base = _cpp_make_hashnode (sym, blen, T_ASSERT, bhash); + { + *bslot = base = _cpp_make_hashnode (sym, blen, T_ASSERT, bhash); + base->value.aschain = 0; + } else { base = *bslot; diff --git a/gcc/enquire.c b/gcc/enquire.c index bb5ea0be604..8b4bdda3d52 100644 --- a/gcc/enquire.c +++ b/gcc/enquire.c @@ -716,7 +716,7 @@ int main(argc, argv) int argc; char *argv[]; { printf ("#ifndef _FLOAT_H___\n"); printf ("#define _FLOAT_H___\n"); if (SYS_FLOAT_H_WRAP) - printf ("#include_next <float.h>\n"); + printf (" #include_next <float.h>\n"); } #ifdef ID printf("%sProduced on %s by enquire version %s, CWI, Amsterdam%s\n", diff --git a/gcc/fixinc/fixinc.irix b/gcc/fixinc/fixinc.irix index 403c5441e83..3eab1a6619e 100755 --- a/gcc/fixinc/fixinc.irix +++ b/gcc/fixinc/fixinc.irix @@ -90,7 +90,7 @@ if [ -r $INPUT/$file ]; then #ifdef __cplusplus # define exception __math_exception #endif -#include_next <math.h> + #include_next <math.h> #ifdef __cplusplus # undef exception #endif @@ -123,7 +123,7 @@ if [ -r $INPUT/$file ]; then #ifdef __cplusplus # define bool __curses_bool_t #endif -#include_next <curses.h> + #include_next <curses.h> #ifdef __cplusplus # undef bool #endif diff --git a/gcc/fixinc/fixinc.sco b/gcc/fixinc/fixinc.sco index a026a776683..77d96e34f41 100755 --- a/gcc/fixinc/fixinc.sco +++ b/gcc/fixinc/fixinc.sco @@ -394,7 +394,7 @@ do #ifdef __cplusplus # define bool __curses_bool_t #endif -#include_next <$file> + #include_next <$file> #ifdef __cplusplus # undef bool #endif diff --git a/gcc/fixinc/fixinc.wrap b/gcc/fixinc/fixinc.wrap index 0c27536ce18..46318967c70 100755 --- a/gcc/fixinc/fixinc.wrap +++ b/gcc/fixinc/fixinc.wrap @@ -57,7 +57,7 @@ if [ -r $INPUT/$file ]; then #ifdef __cplusplus # define exception __math_exception #endif -#include_next <math.h> + #include_next <math.h> #ifdef __cplusplus # undef exception #endif @@ -86,7 +86,7 @@ if [ -r $INPUT/$file ]; then #ifdef __cplusplus # define queue __stream_queue #endif -#include_next <sys/stream.h> + #include_next <sys/stream.h> #ifdef __cplusplus # undef queue #endif @@ -116,7 +116,7 @@ if [ -r $INPUT/$file ]; then #ifdef __cplusplus # define bool __curses_bool_t #endif -#include_next <curses.h> + #include_next <curses.h> #ifdef __cplusplus # undef bool #endif diff --git a/gcc/fixinc/fixincl.x b/gcc/fixinc/fixincl.x index f120a2391b6..1196ebb18c0 100644 --- a/gcc/fixinc/fixincl.x +++ b/gcc/fixinc/fixincl.x @@ -352,7 +352,7 @@ const char* apzAab_Fd_Zero_Asm_Posix_Types_HPatch[] = { for older versions of the Linux kernel. */\n\ #ifndef _POSIX_TYPES_H_WRAPPER\n\ #include <features.h>\n\ -#include_next <asm/posix_types.h>\n\ + #include_next <asm/posix_types.h>\n\ \n\ #if defined(__FD_ZERO) && !defined(__GLIBC__)\n\ #undef __FD_ZERO\n\ @@ -399,7 +399,7 @@ const char* apzAab_Fd_Zero_Gnu_Types_HPatch[] = { "/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */\n\ #ifndef _TYPES_H_WRAPPER\n\ #include <features.h>\n\ -#include_next <gnu/types.h>\n\ + #include_next <gnu/types.h>\n\ \n\ #if defined(__FD_ZERO) && !defined(__GLIBC__)\n\ #undef __FD_ZERO\n\ @@ -446,7 +446,7 @@ const char* apzAab_Fd_Zero_Selectbits_HPatch[] = { "/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */\n\ #ifndef _SELECTBITS_H_WRAPPER\n\ #include <features.h>\n\ -#include_next <selectbits.h>\n\ + #include_next <selectbits.h>\n\ \n\ #if defined(__FD_ZERO) && defined(__GLIBC__) \\\n\ \t&& defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\\n\ diff --git a/gcc/fixinc/inclhack.def b/gcc/fixinc/inclhack.def index e431d1fa562..a49771b94ff 100644 --- a/gcc/fixinc/inclhack.def +++ b/gcc/fixinc/inclhack.def @@ -180,7 +180,7 @@ fix = { for older versions of the Linux kernel. */ \#ifndef _POSIX_TYPES_H_WRAPPER \#include <features.h> -\#include_next <asm/posix_types.h> + \#include_next <asm/posix_types.h> \#if defined(__FD_ZERO) && !defined(__GLIBC__) \#undef __FD_ZERO @@ -219,7 +219,7 @@ fix = { '/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */ \#ifndef _TYPES_H_WRAPPER \#include <features.h> -\#include_next <gnu/types.h> + \#include_next <gnu/types.h> \#if defined(__FD_ZERO) && !defined(__GLIBC__) \#undef __FD_ZERO @@ -258,7 +258,7 @@ fix = { '/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */ \#ifndef _SELECTBITS_H_WRAPPER \#include <features.h> -\#include_next <selectbits.h> + \#include_next <selectbits.h> \#if defined(__FD_ZERO) && defined(__GLIBC__) \\ && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\ diff --git a/gcc/fixinc/inclhack.sh b/gcc/fixinc/inclhack.sh index 67a99745331..74fc8533980 100755 --- a/gcc/fixinc/inclhack.sh +++ b/gcc/fixinc/inclhack.sh @@ -563,7 +563,7 @@ _EOF_ for older versions of the Linux kernel. */ #ifndef _POSIX_TYPES_H_WRAPPER #include <features.h> -#include_next <asm/posix_types.h> + #include_next <asm/posix_types.h> #if defined(__FD_ZERO) && !defined(__GLIBC__) #undef __FD_ZERO @@ -600,7 +600,7 @@ _EOF_ /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */ #ifndef _TYPES_H_WRAPPER #include <features.h> -#include_next <gnu/types.h> + #include_next <gnu/types.h> #if defined(__FD_ZERO) && !defined(__GLIBC__) #undef __FD_ZERO @@ -636,7 +636,7 @@ _EOF_ /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */ #ifndef _SELECTBITS_H_WRAPPER #include <features.h> -#include_next <selectbits.h> + #include_next <selectbits.h> #if defined(__FD_ZERO) && defined(__GLIBC__) \ && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \ diff --git a/gcc/gsyslimits.h b/gcc/gsyslimits.h index a3628025e8a..cc7b3fb877a 100644 --- a/gcc/gsyslimits.h +++ b/gcc/gsyslimits.h @@ -4,5 +4,5 @@ instead of this text. */ #define _GCC_NEXT_LIMITS_H /* tell gcc's limits.h to recurse */ -#include_next <limits.h> + #include_next <limits.h> #undef _GCC_NEXT_LIMITS_H diff --git a/gcc/limity.h b/gcc/limity.h index 8bb398f6786..b2831fc459b 100644 --- a/gcc/limity.h +++ b/gcc/limity.h @@ -4,7 +4,7 @@ #else /* not _GCC_LIMITS_H_ */ #ifdef _GCC_NEXT_LIMITS_H -#include_next <limits.h> /* recurse down to the real one */ + #include_next <limits.h> /* recurse down to the real one */ #endif #endif /* not _GCC_LIMITS_H_ */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2bb0cbada3f..f36a7c422e4 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2000-04-02 Zack Weinberg <zack@wolery.cumb.org> + + * gcc.c-torture/compile/981211-1.c: Move to... + * gcc.dg/cpp-as1.c: ...here. + * gcc.dg/cpp-as2.c: New file. + + * gcc.dg/cpp-tradwarn1.c: Change warning regexps to match the + compiler. + 2000-04-02 Neil Booth <NeilB@earthling.net> * gcc.dg/cpp-cond.c New tests. diff --git a/gcc/testsuite/gcc.c-torture/compile/981211-1.c b/gcc/testsuite/gcc.dg/cpp-as1.c index 92c9cfb7013..6e8c0f827be 100644 --- a/gcc/testsuite/gcc.c-torture/compile/981211-1.c +++ b/gcc/testsuite/gcc.dg/cpp-as1.c @@ -1,4 +1,6 @@ /* Basic tests of the #assert preprocessor extension. */ +/* { dg-do compile } */ +/* { dg-options "" } */ #define fail int fail diff --git a/gcc/testsuite/gcc.dg/cpp-as2.c b/gcc/testsuite/gcc.dg/cpp-as2.c new file mode 100644 index 00000000000..a69627027d3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/cpp-as2.c @@ -0,0 +1,24 @@ +/* Malformed assertion tests. */ +/* { dg-do preprocess } */ +/* { dg-options "" } */ + +#assert /* { dg-error "without predicate" "assert w/o predicate" } */ +#assert % /* { dg-error "not an identifier" "assert punctuation" } */ +#assert 12 /* { dg-error "not an identifier" "assert number" } */ +#assert abc /* { dg-error "missing token-sequence" "assert w/o answer" } */ + +#if # /* { dg-error "without predicate" "test w/o predicate" } */ +#endif + +#if #% /* { dg-error "not an identifier" "test punctuation" } */ +#endif + +#if #12 /* { dg-error "not an identifier" "test number" } */ +#endif + +#if #abc +#error /* { dg-bogus "error" "test w/o answer" } */ +#endif + +#if #abc[def] /* { dg-error "invalid char" "test with malformed answer" } */ +#endif diff --git a/gcc/testsuite/gcc.dg/cpp-tradwarn1.c b/gcc/testsuite/gcc.dg/cpp-tradwarn1.c index 8395c80441b..9085ea6791f 100644 --- a/gcc/testsuite/gcc.dg/cpp-tradwarn1.c +++ b/gcc/testsuite/gcc.dg/cpp-tradwarn1.c @@ -2,27 +2,27 @@ /* { dg-do preprocess } */ /* { dg-options "-pedantic -Wtraditional" } */ -/* Block 1: K+R directives should have the # at the left margin. */ +/* Block 1: K+R directives should have the # indented. */ -#define foo bar /* { dg-bogus "left margin" "^#kandr" } */ -# define foo bar /* { dg-bogus "left margin" "^# kandr" } */ - #define foo bar /* { dg-warning "left margin" "^ #kandr" } */ - # define foo bar /* { dg-warning "left margin" "^ # kandr" } */ +#define foo bar /* { dg-bogus "indented" "^#kandr" } */ +# define foo bar /* { dg-bogus "indented" "^# kandr" } */ + #define foo bar /* { dg-warning "indented" "^ #kandr" } */ + # define foo bar /* { dg-warning "indented" "^ # kandr" } */ -/* Block 2: C89 directives should not have the # at the left margin. */ +/* Block 2: C89 directives should not have the # indented. */ -#pragma whatever /* { dg-warning "left margin" "^#c89" } */ -# pragma whatever /* { dg-warning "left margin" "^# c89" } */ - #pragma whatever /* { dg-bogus "left margin" "^ #c89" } */ - # pragma whatever /* { dg-bogus "left margin" "^ # c89" } */ +#pragma whatever /* { dg-warning "indented" "^#c89" } */ +# pragma whatever /* { dg-warning "indented" "^# c89" } */ + #pragma whatever /* { dg-bogus "indented" "^ #c89" } */ + # pragma whatever /* { dg-bogus "indented" "^ # c89" } */ -/* Block 3: Extensions should not have the # at the left margin, +/* Block 3: Extensions should not have the # indented, _and_ they should get a -pedantic warning. */ -#assert foo(bar) /* { dg-warning "left margin" "^#ext" } */ -# assert bar(baz) /* { dg-warning "left margin" "^# ext" } */ - #assert baz(quux) /* { dg-bogus "left margin" "^ #ext" } */ - # assert quux(weeble) /* { dg-bogus "left margin" "^ # ext" } */ +#assert foo(bar) /* { dg-warning "indented" "^#ext" } */ +# assert bar(baz) /* { dg-warning "indented" "^# ext" } */ + #assert baz(quux) /* { dg-bogus "indented" "^ #ext" } */ + # assert quux(weeble) /* { dg-bogus "indented" "^ # ext" } */ /* { dg-warning "ISO C does not" "extension warning" { target native } 22 } */ /* { dg-warning "ISO C does not" "extension warning" { target native } 23 } */ |