* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102168
138bc75d-0d04-0410-961f-
82ee72b054a4
+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>
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;
}
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);
}
}
#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(())
{
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));
}
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");
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);
}
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))
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)
{
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);
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;
}
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. */
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. */
{
/* 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);
{
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;
}
}
}
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
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
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)
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;
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
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
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);
}
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;
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;
return;
bad:
- warning (0, "malformed #pragma ghs section");
+ warning (OPT_Wpragmas, "malformed #pragma ghs section");
return;
reset:
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 ();
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
-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}
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.
#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;
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;
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)