diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 39 | ||||
-rw-r--r-- | gcc/c-decl.c | 19 | ||||
-rw-r--r-- | gcc/c-lex.c | 3 | ||||
-rw-r--r-- | gcc/c-pragma.c | 35 | ||||
-rw-r--r-- | gcc/c.opt | 4 | ||||
-rw-r--r-- | gcc/config/c4x/c4x-c.c | 5 | ||||
-rw-r--r-- | gcc/config/ia64/ia64-c.c | 2 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000-c.c | 10 | ||||
-rw-r--r-- | gcc/config/v850/v850-c.c | 24 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 9 | ||||
-rw-r--r-- | gcc/errors.h | 4 | ||||
-rw-r--r-- | gcc/function.c | 2 | ||||
-rw-r--r-- | gcc/toplev.h | 1 |
13 files changed, 109 insertions, 48 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e3c6e3..ec8a08e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,42 @@ +2005-07-15 DJ Delorie <dj@redhat.com> + + * toplev.h: Add comment about the first parameter for warning(). + * errors.h: Likewise. + + * c.opt (Wpragmas): New. + * doc/invoke.texi: Document it. + + * function.c (do_warn_unused_parameter): Add warning control to + warning call. + * c-decl.c (warn_if_shadowing): Likewise. + * c-lex.c (cb_def_pragma): Likewise. + * c-pragma.c (GCC_BAD, GCC_BAD2): Likewise. + (pop_alignment): Likewise. + (handle_pragma_pack): Likewise. + (apply_pragma_weak): Likewise. + (handle_pragma_weak): Likewise. + (handle_pragma_redefine_extname): Likewise. + (add_to_renaming_pragma_list): Likewise. + (handle_pragma_extern_prefix): Likewise. + (maybe_apply_renaming_pragma): Likewise. + (handle_pragma_visibility): Likewise. + + * config/c4x/c4x-c.c (BAD): Likewise. + (c4x_parse_pragma): Likewise. + * config/ia64/ia64-c.c (ia64_hpux_handle_builtin_pragma): Likewise. + * config/rs6000/rs6000-c.c (SYNTAX_ERROR): Likewise. + (rs6000_pragma_longcall): Likewise. + * config/v850/v850-c.c (pop_data_area): Likewise. + (ghs_pragma_section): Likewise. + (ghs_pragma_section): Likewise. + (ghs_pragma_interrupt): Likewise. + (ghs_pragma_starttda): Likewise. + (ghs_pragma_startsda): Likewise. + (ghs_pragma_startzda): Likewise. + (ghs_pragma_endtda): Likewise. + (ghs_pragma_endsda): Likewise. + (ghs_pragma_endzda): Likewise. + 2005-07-19 Danny Berlin <dberlin@dberlin.org> Kenneth Zadeck <zadeck@naturalbridge.com> diff --git a/gcc/c-decl.c b/gcc/c-decl.c index aff59bc1..71a9553 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1908,27 +1908,28 @@ warn_if_shadowing (tree new_decl) if (old_decl == error_mark_node) { - warning (0, "declaration of %q+D shadows previous non-variable", - new_decl); + warning (OPT_Wshadow, "declaration of %q+D shadows previous " + "non-variable", new_decl); break; } else if (TREE_CODE (old_decl) == PARM_DECL) - warning (0, "declaration of %q+D shadows a parameter", new_decl); - else if (DECL_FILE_SCOPE_P (old_decl)) - warning (0, "declaration of %q+D shadows a global declaration", + warning (OPT_Wshadow, "declaration of %q+D shadows a parameter", new_decl); + else if (DECL_FILE_SCOPE_P (old_decl)) + warning (OPT_Wshadow, "declaration of %q+D shadows a global " + "declaration", new_decl); else if (TREE_CODE (old_decl) == FUNCTION_DECL && DECL_BUILT_IN (old_decl)) { - warning (0, "declaration of %q+D shadows a built-in function", - new_decl); + warning (OPT_Wshadow, "declaration of %q+D shadows " + "a built-in function", new_decl); break; } else - warning (0, "declaration of %q+D shadows a previous local", + warning (OPT_Wshadow, "declaration of %q+D shadows a previous local", new_decl); - warning (0, "%Jshadowed declaration is here", old_decl); + warning (OPT_Wshadow, "%Jshadowed declaration is here", old_decl); break; } diff --git a/gcc/c-lex.c b/gcc/c-lex.c index 52f9b68..1c832c5 100644 --- a/gcc/c-lex.c +++ b/gcc/c-lex.c @@ -299,7 +299,8 @@ cb_def_pragma (cpp_reader *pfile, source_location loc) name = cpp_token_as_text (pfile, s); } - warning (0, "%Hignoring #pragma %s %s", &fe_loc, space, name); + warning (OPT_Wunknown_pragmas, "%Hignoring #pragma %s %s", + &fe_loc, space, name); } } diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index 65b12ce..1407a11 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -37,9 +37,10 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "vec.h" #include "target.h" -#define GCC_BAD(gmsgid) do { warning (0, gmsgid); return; } while (0) +#define GCC_BAD(gmsgid) \ + do { warning (OPT_Wpragmas, gmsgid); return; } while (0) #define GCC_BAD2(gmsgid, arg) \ - do { warning (0, gmsgid, arg); return; } while (0) + do { warning (OPT_Wpragmas, gmsgid, arg); return; } while (0) typedef struct align_stack GTY(()) { @@ -110,7 +111,7 @@ pop_alignment (tree id) break; } if (entry == NULL) - warning (0, "\ + warning (OPT_Wpragmas, "\ #pragma pack(pop, %s) encountered without matching #pragma pack(push, %s)" , IDENTIFIER_POINTER (id), IDENTIFIER_POINTER (id)); } @@ -203,7 +204,7 @@ handle_pragma_pack (cpp_reader * ARG_UNUSED (dummy)) GCC_BAD ("malformed %<#pragma pack%> - ignored"); if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of %<#pragma pack%>"); + warning (OPT_Wpragmas, "junk at end of %<#pragma pack%>"); if (flag_pack_struct) GCC_BAD ("#pragma pack has no effect with -fpack-struct - ignored"); @@ -259,8 +260,8 @@ apply_pragma_weak (tree decl, tree value) if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl) && !DECL_WEAK (decl) /* Don't complain about a redundant #pragma. */ && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) - warning (0, "applying #pragma weak %q+D after first use results " - "in unspecified behavior", decl); + warning (OPT_Wpragmas, "applying #pragma weak %q+D after first use " + "results in unspecified behavior", decl); declare_weak (decl); } @@ -342,7 +343,7 @@ handle_pragma_weak (cpp_reader * ARG_UNUSED (dummy)) t = c_lex (&x); } if (t != CPP_EOF) - warning (0, "junk at end of #pragma weak"); + warning (OPT_Wpragmas, "junk at end of #pragma weak"); decl = identifier_global_value (name); if (decl && DECL_P (decl)) @@ -415,7 +416,7 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy)) GCC_BAD ("malformed #pragma redefine_extname, ignored"); t = c_lex (&x); if (t != CPP_EOF) - warning (0, "junk at end of #pragma redefine_extname"); + warning (OPT_Wpragmas, "junk at end of #pragma redefine_extname"); if (!flag_mudflap && !targetm.handle_pragma_redefine_extname) { @@ -438,8 +439,8 @@ handle_pragma_redefine_extname (cpp_reader * ARG_UNUSED (dummy)) name = targetm.strip_name_encoding (name); if (strcmp (name, IDENTIFIER_POINTER (newname))) - warning (0, "#pragma redefine_extname ignored due to conflict with " - "previous rename"); + warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " + "conflict with previous rename"); } else change_decl_assembler_name (decl, newname); @@ -461,8 +462,8 @@ add_to_renaming_pragma_list (tree oldname, tree newname) if (previous) { if (TREE_VALUE (previous) != newname) - warning (0, "#pragma redefine_extname ignored due to conflict with " - "previous #pragma redefine_extname"); + warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " + "conflict with previous #pragma redefine_extname"); return; } @@ -483,7 +484,7 @@ handle_pragma_extern_prefix (cpp_reader * ARG_UNUSED (dummy)) GCC_BAD ("malformed #pragma extern_prefix, ignored"); t = c_lex (&x); if (t != CPP_EOF) - warning (0, "junk at end of #pragma extern_prefix"); + warning (OPT_Wpragmas, "junk at end of #pragma extern_prefix"); if (targetm.handle_pragma_extern_prefix) /* Note that the length includes the null terminator. */ @@ -516,7 +517,7 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) oldname = targetm.strip_name_encoding (oldname); if (asmname && strcmp (TREE_STRING_POINTER (asmname), oldname)) - warning (0, "asm declaration ignored due to " + warning (OPT_Wpragmas, "asm declaration ignored due to " "conflict with previous rename"); /* Take any pending redefine_extname off the list. */ @@ -525,7 +526,7 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) { /* Only warn if there is a conflict. */ if (strcmp (IDENTIFIER_POINTER (TREE_VALUE (t)), oldname)) - warning (0, "#pragma redefine_extname ignored due to " + warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " "conflict with previous rename"); *p = TREE_CHAIN (t); @@ -547,7 +548,7 @@ maybe_apply_renaming_pragma (tree decl, tree asmname) { if (strcmp (TREE_STRING_POINTER (asmname), IDENTIFIER_POINTER (newname)) != 0) - warning (0, "#pragma redefine_extname ignored due to " + warning (OPT_Wpragmas, "#pragma redefine_extname ignored due to " "conflict with __asm__ declaration"); return asmname; } @@ -661,7 +662,7 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED) } } if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of %<#pragma GCC visibility%>"); + warning (OPT_Wpragmas, "junk at end of %<#pragma GCC visibility%>"); } #endif @@ -331,6 +331,10 @@ Wpointer-to-int-cast C ObjC Var(warn_pointer_to_int_cast) Init(1) Warn when a pointer is cast to an integer of a different size +Wpragmas +C ObjC C++ ObjC++ Var(warn_pragmas) Init(1) +Warn about misuses of pragmas + Wprotocol ObjC ObjC++ Var(warn_protocol) Init(1) Warn if inherited methods are unimplemented diff --git a/gcc/config/c4x/c4x-c.c b/gcc/config/c4x/c4x-c.c index 644fe86..fe3a922 100644 --- a/gcc/config/c4x/c4x-c.c +++ b/gcc/config/c4x/c4x-c.c @@ -57,7 +57,8 @@ static int c4x_parse_pragma (const char *, tree *, tree *); the STRING_CST node of the string. If SECT is null, then this pragma doesn't take a section string. Returns 0 for a good pragma, -1 for a malformed pragma. */ -#define BAD(gmsgid, arg) do { warning (0, gmsgid, arg); return -1; } while (0) +#define BAD(gmsgid, arg) \ + do { warning (OPT_Wpragmas, gmsgid, arg); return -1; } while (0) static int c4x_parse_pragma (name, func, sect) @@ -86,7 +87,7 @@ c4x_parse_pragma (name, func, sect) BAD ("missing ')' for '#pragma %s' - ignored", name); if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of '#pragma %s'", name); + warning (OPT_Wpragmas, "junk at end of '#pragma %s'", name); *func = f; return 0; diff --git a/gcc/config/ia64/ia64-c.c b/gcc/config/ia64/ia64-c.c index d29d15a..d51a98d 100644 --- a/gcc/config/ia64/ia64-c.c +++ b/gcc/config/ia64/ia64-c.c @@ -49,7 +49,7 @@ ia64_hpux_handle_builtin_pragma (cpp_reader *pfile ATTRIBUTE_UNUSED) type = c_lex (&x); } if (type != CPP_EOF) - warning (0, "malformed #pragma builtin"); + warning (OPT_Wpragmas, "malformed #pragma builtin"); } /* List of standard math functions which do not set matherr by default diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 1e851e4..c125c78 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -50,10 +50,10 @@ static tree altivec_resolve_overloaded_builtin (tree, tree); whether or not new function declarations receive a longcall attribute by default. */ -#define SYNTAX_ERROR(gmsgid) do { \ - warning (0, gmsgid); \ - warning (0, "ignoring malformed #pragma longcall"); \ - return; \ +#define SYNTAX_ERROR(gmsgid) do { \ + warning (OPT_Wpragmas, gmsgid); \ + warning (OPT_Wpragmas, "ignoring malformed #pragma longcall"); \ + return; \ } while (0) void @@ -75,7 +75,7 @@ rs6000_pragma_longcall (cpp_reader *pfile ATTRIBUTE_UNUSED) SYNTAX_ERROR ("number must be 0 or 1"); if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma longcall"); + warning (OPT_Wpragmas, "junk at end of #pragma longcall"); rs6000_default_long_calls = (n == integer_one_node); } diff --git a/gcc/config/v850/v850-c.c b/gcc/config/v850/v850-c.c index a7acf99..cbb86cd 100644 --- a/gcc/config/v850/v850-c.c +++ b/gcc/config/v850/v850-c.c @@ -64,9 +64,11 @@ static int pop_data_area (v850_data_area data_area) { if (data_area_stack == NULL) - warning (0, "#pragma GHS endXXXX found without previous startXXX"); + warning (OPT_Wpragmas, "#pragma GHS endXXXX found without " + "previous startXXX"); else if (data_area != data_area_stack->data_area) - warning (0, "#pragma GHS endXXX does not match previous startXXX"); + warning (OPT_Wpragmas, "#pragma GHS endXXX does not match " + "previous startXXX"); else { data_area_stack_element * elem; @@ -144,7 +146,7 @@ ghs_pragma_section (cpp_reader * pfile ATTRIBUTE_UNUSED) if (type == CPP_COMMA) repeat = 1; else if (type != CPP_EOF) - warning (0, "junk at end of #pragma ghs section"); + warning (OPT_Wpragmas, "junk at end of #pragma ghs section"); if (streq (sect, "data")) kind = GHS_SECTION_KIND_DATA; else if (streq (sect, "text")) kind = GHS_SECTION_KIND_TEXT; @@ -176,7 +178,7 @@ ghs_pragma_section (cpp_reader * pfile ATTRIBUTE_UNUSED) return; bad: - warning (0, "malformed #pragma ghs section"); + warning (OPT_Wpragmas, "malformed #pragma ghs section"); return; reset: @@ -195,7 +197,7 @@ ghs_pragma_interrupt (cpp_reader * pfile ATTRIBUTE_UNUSED) tree x; if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma ghs interrupt"); + warning (OPT_Wpragmas, "junk at end of #pragma ghs interrupt"); mark_current_function_as_interrupt (); } @@ -206,7 +208,7 @@ ghs_pragma_starttda (cpp_reader * pfile ATTRIBUTE_UNUSED) tree x; if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma ghs starttda"); + warning (OPT_Wpragmas, "junk at end of #pragma ghs starttda"); push_data_area (DATA_AREA_TDA); } @@ -217,7 +219,7 @@ ghs_pragma_startsda (cpp_reader * pfile ATTRIBUTE_UNUSED) tree x; if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma ghs startsda"); + warning (OPT_Wpragmas, "junk at end of #pragma ghs startsda"); push_data_area (DATA_AREA_SDA); } @@ -228,7 +230,7 @@ ghs_pragma_startzda (cpp_reader * pfile ATTRIBUTE_UNUSED) tree x; if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma ghs startzda"); + warning (OPT_Wpragmas, "junk at end of #pragma ghs startzda"); push_data_area (DATA_AREA_ZDA); } @@ -239,7 +241,7 @@ ghs_pragma_endtda (cpp_reader * pfile ATTRIBUTE_UNUSED) tree x; if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma ghs endtda"); + warning (OPT_Wpragmas, "junk at end of #pragma ghs endtda"); pop_data_area (DATA_AREA_TDA); } @@ -250,7 +252,7 @@ ghs_pragma_endsda (cpp_reader * pfile ATTRIBUTE_UNUSED) tree x; if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma ghs endsda"); + warning (OPT_Wpragmas, "junk at end of #pragma ghs endsda"); pop_data_area (DATA_AREA_SDA); } @@ -261,7 +263,7 @@ ghs_pragma_endzda (cpp_reader * pfile ATTRIBUTE_UNUSED) tree x; if (c_lex (&x) != CPP_EOF) - warning (0, "junk at end of #pragma ghs endzda"); + warning (OPT_Wpragmas, "junk at end of #pragma ghs endzda"); pop_data_area (DATA_AREA_ZDA); } diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d4a504b..48764a6 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -241,7 +241,7 @@ Objective-C and Objective-C++ Dialects}. -Wsign-compare -Wstrict-aliasing -Wstrict-aliasing=2 @gol -Wswitch -Wswitch-default -Wswitch-enum @gol -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol --Wunknown-pragmas -Wunreachable-code @gol +-Wunknown-pragmas -Wno-pragmas -Wunreachable-code @gol -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol -Wunused-value -Wunused-variable -Wwrite-strings @gol -Wvariadic-macros} @@ -2709,6 +2709,13 @@ GCC@. If this command line option is used, warnings will even be issued for unknown pragmas in system header files. This is not the case if the warnings were only enabled by the @option{-Wall} command line option. +@item -Wno-pragmas +@opindex Wno-pragmas +@opindex Wpragmas +Do not warn about misuses of pragmas, such as incorrect parameters, +invalid syntax, or conflicts between pragmas. See also +@samp{-Wunknown-pragmas}. + @item -Wstrict-aliasing @opindex Wstrict-aliasing This option is only active when @option{-fstrict-aliasing} is active. diff --git a/gcc/errors.h b/gcc/errors.h index ecb0af1..5fefa07 100644 --- a/gcc/errors.h +++ b/gcc/errors.h @@ -30,6 +30,10 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #ifndef GCC_ERRORS_H #define GCC_ERRORS_H +/* The first parameter is for compatibility with the non-generator + version of warning(). For those, you'd pass an OPT_W* value from + options.h, but in generator programs it has no effect, so it's OK + to just pass zero for calls from generator-only files. */ extern void warning (int, const char *, ...) ATTRIBUTE_PRINTF_2; extern void error (const char *, ...) ATTRIBUTE_PRINTF_1; extern void fatal (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1; diff --git a/gcc/function.c b/gcc/function.c index 160c80d..38f56a6 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4315,7 +4315,7 @@ do_warn_unused_parameter (tree fn) decl; decl = TREE_CHAIN (decl)) if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL && DECL_NAME (decl) && !DECL_ARTIFICIAL (decl)) - warning (0, "unused parameter %q+D", decl); + warning (OPT_Wunused_parameter, "unused parameter %q+D", decl); } static GTY(()) rtx initial_trampoline; diff --git a/gcc/toplev.h b/gcc/toplev.h index 48339db..45797b1 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -57,6 +57,7 @@ extern void _fatal_insn (const char *, rtx, const char *, int, const char *) extern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2) ATTRIBUTE_NORETURN; extern void warning0 (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); +/* Pass one of the OPT_W* from options.h as the first parameter. */ extern void warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3); extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2); extern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2) |