aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2005-05-25 00:18:19 -0400
committerDJ Delorie <dj@gcc.gnu.org>2005-05-25 00:18:19 -0400
commit5c498b10af2cf068e55361f7b2915c799f2508d3 (patch)
treef2b16cd3336a6bcdf0b58025f27679c1e19056ed /gcc
parent44c21c7f0304a014f491b822f7eaea34f2cc4c3c (diff)
downloadgcc-5c498b10af2cf068e55361f7b2915c799f2508d3.zip
gcc-5c498b10af2cf068e55361f7b2915c799f2508d3.tar.gz
gcc-5c498b10af2cf068e55361f7b2915c799f2508d3.tar.bz2
common.opt (-Wattributes): New.
* common.opt (-Wattributes): New. Default true. * doc/invoke.texi (-Wno-attributes): Document. * attribs.c (decl_attributes): Move warning control from if() to warning(OPT_*). * c-common.c (handle_packed_attribute): Likewise. (handle_nocommon_attribute): Likewise. (handle_common_attribute): Likewise. (handle_noreturn_attribute): Likewise. (handle_noinline_attribute): Likewise. (handle_always_inline_attribute): Likewise. (handle_used_attribute): Likewise. (handle_unused_attribute): Likewise. (handle_const_attribute): Likewise. (handle_transparent_union_attribute): Likewise. (handle_constructor_attribute): Likewise. (handle_destructor_attribute): Likewise. (handle_mode_attribute): Likewise. (handle_alias_attribute): Likewise. (handle_visibility_attribute): Likewise. (handle_tls_model_attribute): Likewise. (handle_malloc_attribute): Likewise. (handle_returns_twice_attribute): Likewise. (handle_pure_attribute): Likewise. (handle_deprecated_attribute): Likewise. (handle_vector_size_attribute): Likewise. (handle_nothrow_attribute): Likewise. (handle_cleanup_attribute): Likewise. (handle_warn_unused_result_attribute): Likewise. (handle_sentinel_attribute): Likewise. * c-decl.c (diagnose_mismatched_decls): Likewise. (start_decl): Likewise. (grokdeclarator): Likewise. (start_function): Likewise. * c-format.c (check_function_format): Likewise. * stor-layout.c (place_field): Likewise. (finalize_record_size): Likewise. * tree.c (handle_dll_attribute)): Likewise. * varasm.c (default_assemble_visibility): Likewise. * config/darwin.c (darwin_handle_weak_import_attribute): Likewise. (darwin_assemble_visibility): Likewise. * config/arc/arc.c (arc_handle_interrupt_attribute): Likewise. * config/arm/arm.c (arm_handle_fndecl_attribute): Likewise. (arm_handle_isr_attribute): Likewise. * config/avr/avr.c (avr_handle_progmem_attribute): Likewise. (avr_handle_fndecl_attribute): Likewise. * config/bfin/bfin.c (handle_int_attribute): Likewise. * config/c4x/c4x.c (c4x_handle_fntype_attribute): Likewise. * config/h8300/h8300.c (h8300_handle_fndecl_attribute): Likewise. (h8300_handle_eightbit_data_attribute): Likewise. (h8300_handle_tiny_data_attribute): Likewise. * config/i386/i386.c (ix86_handle_cdecl_attribute): Likewise. (ix86_handle_regparm_attribute): Likewise. (ix86_handle_struct_attribute): Likewise. * config/i386/winnt.c (ix86_handle_shared_attribute): Likewise. (i386_pe_encode_section_info): Likewise. * config/ia64/ia64.c (ia64_handle_model_attribute): Likewise. * config/ip2k/ip2k.c (ip2k_handle_progmem_attribute): Likewise. (ip2k_handle_fndecl_attribute): Likewise. * config/m32r/m32r.c (m32r_handle_model_attribute): Likewise. * config/m68hc11/m68hc11 (m68hc11_handle_page0_attribute): Likewise. (m68hc11_handle_fntype_attribute): Likewise. (m68hc11_encode_section_info): Likewise. * config/m68k/m68k.c (m68k_handle_fndecl_attribute): Likewise. * config/mcore/mcore.c (mcore_handle_naked_attribute): Likewise. * config/ns32k/ns32k.c (ns32k_handle_fntype_attribute): Likewise. * config/rs6000/rs6000.c (rs6000_handle_longcall_attribute): Likewise. * config/sh/sh.c (sh_handle_interrupt_handler_attribute): Likewise. (sh_handle_sp_switch_attribute): Likewise. (sh_handle_trap_exit_attribute): Likewise. * config/sh/symbian.c (sh_symbian_dllimport_p): Likewise. (sh_symbian_handle_dll_attribute): Likewise. * config/stormy16/stormy16.c (xstormy16_handle_interrupt_attribute): Likewise. (xstormy16_handle_below100_attribute): Likewise. * config/v850/v850.c (v850_handle_interrupt_attribute): Likewise. [testsuite] * gcc.dg/Wattributes-1.c: New. * gcc.dg/Wattributes-2.c: New. * gcc.dg/Wattributes-3.c: New. [cp] * decl.c (duplicate_decls): Move warning control from if() to warning(OPT_*). * name-lookup.c (parse_using_directive): Likewise. * parser.c (cp_parser_elaborated_type_specifier): Likewise. (cp_parser_init_declarator): Likewise. * tree.c (handle_com_interface_attribute): Likewise. [java] * class.c (set_constant_value): Move warning control from if() to warning(OPT_*). From-SVN: r100136
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog76
-rw-r--r--gcc/attribs.c7
-rw-r--r--gcc/c-common.c68
-rw-r--r--gcc/c-decl.c15
-rw-r--r--gcc/c-format.c3
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/config/arc/arc.c6
-rw-r--r--gcc/config/arm/arm.c10
-rw-r--r--gcc/config/avr/avr.c5
-rw-r--r--gcc/config/bfin/bfin.c2
-rw-r--r--gcc/config/c4x/c4x.c2
-rw-r--r--gcc/config/darwin.c7
-rw-r--r--gcc/config/h8300/h8300.c8
-rw-r--r--gcc/config/i386/i386.c17
-rw-r--r--gcc/config/i386/winnt.c7
-rw-r--r--gcc/config/ia64/ia64.c5
-rw-r--r--gcc/config/ip2k/ip2k.c5
-rw-r--r--gcc/config/m32r/m32r.c2
-rw-r--r--gcc/config/m68hc11/m68hc11.c10
-rw-r--r--gcc/config/m68k/m68k.c2
-rw-r--r--gcc/config/mcore/mcore.c2
-rw-r--r--gcc/config/ns32k/ns32k.c2
-rw-r--r--gcc/config/rs6000/rs6000.c2
-rw-r--r--gcc/config/sh/sh.c20
-rw-r--r--gcc/config/sh/symbian.c10
-rw-r--r--gcc/config/stormy16/stormy16.c8
-rw-r--r--gcc/config/v850/v850.c2
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/decl.c20
-rw-r--r--gcc/cp/name-lookup.c2
-rw-r--r--gcc/cp/parser.c6
-rw-r--r--gcc/cp/tree.c3
-rw-r--r--gcc/doc/invoke.texi10
-rw-r--r--gcc/java/ChangeLog5
-rw-r--r--gcc/java/class.c6
-rw-r--r--gcc/stor-layout.c18
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/Wattributes-1.c6
-rw-r--r--gcc/testsuite/gcc.dg/Wattributes-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/Wattributes-3.c5
-rw-r--r--gcc/tree.c3
-rw-r--r--gcc/varasm.c3
42 files changed, 290 insertions, 125 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 256fbf5..01d57e2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,80 @@
2005-05-24 DJ Delorie <dj@redhat.com>
+
+ * common.opt (-Wattributes): New. Default true.
+ * doc/invoke.texi (-Wno-attributes): Document.
+
+ * attribs.c (decl_attributes): Move warning control from if() to
+ warning(OPT_*).
+ * c-common.c (handle_packed_attribute): Likewise.
+ (handle_nocommon_attribute): Likewise.
+ (handle_common_attribute): Likewise.
+ (handle_noreturn_attribute): Likewise.
+ (handle_noinline_attribute): Likewise.
+ (handle_always_inline_attribute): Likewise.
+ (handle_used_attribute): Likewise.
+ (handle_unused_attribute): Likewise.
+ (handle_const_attribute): Likewise.
+ (handle_transparent_union_attribute): Likewise.
+ (handle_constructor_attribute): Likewise.
+ (handle_destructor_attribute): Likewise.
+ (handle_mode_attribute): Likewise.
+ (handle_alias_attribute): Likewise.
+ (handle_visibility_attribute): Likewise.
+ (handle_tls_model_attribute): Likewise.
+ (handle_malloc_attribute): Likewise.
+ (handle_returns_twice_attribute): Likewise.
+ (handle_pure_attribute): Likewise.
+ (handle_deprecated_attribute): Likewise.
+ (handle_vector_size_attribute): Likewise.
+ (handle_nothrow_attribute): Likewise.
+ (handle_cleanup_attribute): Likewise.
+ (handle_warn_unused_result_attribute): Likewise.
+ (handle_sentinel_attribute): Likewise.
+ * c-decl.c (diagnose_mismatched_decls): Likewise.
+ (start_decl): Likewise.
+ (grokdeclarator): Likewise.
+ (start_function): Likewise.
+ * c-format.c (check_function_format): Likewise.
+ * stor-layout.c (place_field): Likewise.
+ (finalize_record_size): Likewise.
+ * tree.c (handle_dll_attribute)): Likewise.
+ * varasm.c (default_assemble_visibility): Likewise.
+ * config/darwin.c (darwin_handle_weak_import_attribute): Likewise.
+ (darwin_assemble_visibility): Likewise.
+ * config/arc/arc.c (arc_handle_interrupt_attribute): Likewise.
+ * config/arm/arm.c (arm_handle_fndecl_attribute): Likewise.
+ (arm_handle_isr_attribute): Likewise.
+ * config/avr/avr.c (avr_handle_progmem_attribute): Likewise.
+ (avr_handle_fndecl_attribute): Likewise.
+ * config/bfin/bfin.c (handle_int_attribute): Likewise.
+ * config/c4x/c4x.c (c4x_handle_fntype_attribute): Likewise.
+ * config/h8300/h8300.c (h8300_handle_fndecl_attribute): Likewise.
+ (h8300_handle_eightbit_data_attribute): Likewise.
+ (h8300_handle_tiny_data_attribute): Likewise.
+ * config/i386/i386.c (ix86_handle_cdecl_attribute): Likewise.
+ (ix86_handle_regparm_attribute): Likewise.
+ (ix86_handle_struct_attribute): Likewise.
+ * config/i386/winnt.c (ix86_handle_shared_attribute): Likewise.
+ (i386_pe_encode_section_info): Likewise.
+ * config/ia64/ia64.c (ia64_handle_model_attribute): Likewise.
+ * config/ip2k/ip2k.c (ip2k_handle_progmem_attribute): Likewise.
+ (ip2k_handle_fndecl_attribute): Likewise.
+ * config/m32r/m32r.c (m32r_handle_model_attribute): Likewise.
+ * config/m68hc11/m68hc11 (m68hc11_handle_page0_attribute): Likewise.
+ (m68hc11_handle_fntype_attribute): Likewise.
+ (m68hc11_encode_section_info): Likewise.
+ * config/m68k/m68k.c (m68k_handle_fndecl_attribute): Likewise.
+ * config/mcore/mcore.c (mcore_handle_naked_attribute): Likewise.
+ * config/ns32k/ns32k.c (ns32k_handle_fntype_attribute): Likewise.
+ * config/rs6000/rs6000.c (rs6000_handle_longcall_attribute): Likewise.
+ * config/sh/sh.c (sh_handle_interrupt_handler_attribute): Likewise.
+ (sh_handle_sp_switch_attribute): Likewise.
+ (sh_handle_trap_exit_attribute): Likewise.
+ * config/sh/symbian.c (sh_symbian_dllimport_p): Likewise.
+ (sh_symbian_handle_dll_attribute): Likewise.
+ * config/stormy16/stormy16.c (xstormy16_handle_interrupt_attribute): Likewise.
+ (xstormy16_handle_below100_attribute): Likewise.
+ * config/v850/v850.c (v850_handle_interrupt_attribute): Likewise.
* c-common.c (unsigned_conversion_warning): Move warning control
from if() to warning(OPT_*).
diff --git a/gcc/attribs.c b/gcc/attribs.c
index f04dfb9..019618c 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -172,7 +172,7 @@ decl_attributes (tree *node, tree attributes, int flags)
if (spec == NULL)
{
- warning (0, "%qs attribute directive ignored",
+ warning (OPT_Wattributes, "%qs attribute directive ignored",
IDENTIFIER_POINTER (name));
continue;
}
@@ -197,7 +197,7 @@ decl_attributes (tree *node, tree attributes, int flags)
}
else
{
- warning (0, "%qs attribute does not apply to types",
+ warning (OPT_Wattributes, "%qs attribute does not apply to types",
IDENTIFIER_POINTER (name));
continue;
}
@@ -243,7 +243,8 @@ decl_attributes (tree *node, tree attributes, int flags)
if (TREE_CODE (*anode) != FUNCTION_TYPE
&& TREE_CODE (*anode) != METHOD_TYPE)
{
- warning (0, "%qs attribute only applies to function types",
+ warning (OPT_Wattributes,
+ "%qs attribute only applies to function types",
IDENTIFIER_POINTER (name));
continue;
}
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 17efd33..cd7f653 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -3959,7 +3959,7 @@ handle_packed_attribute (tree *node, tree name, tree ARG_UNUSED (args),
that changes what the typedef is typing. */
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -3978,7 +3978,7 @@ handle_nocommon_attribute (tree *node, tree name,
DECL_COMMON (*node) = 0;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -3996,7 +3996,7 @@ handle_common_attribute (tree *node, tree name, tree ARG_UNUSED (args),
DECL_COMMON (*node) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4023,7 +4023,7 @@ handle_noreturn_attribute (tree *node, tree name, tree ARG_UNUSED (args),
TYPE_READONLY (TREE_TYPE (type)), 1));
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4042,7 +4042,7 @@ handle_noinline_attribute (tree *node, tree name,
DECL_UNINLINABLE (*node) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4065,7 +4065,7 @@ handle_always_inline_attribute (tree *node, tree name,
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4089,7 +4089,7 @@ handle_used_attribute (tree *pnode, tree name, tree ARG_UNUSED (args),
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4115,7 +4115,7 @@ handle_unused_attribute (tree *node, tree name, tree ARG_UNUSED (args),
TREE_USED (decl) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
}
@@ -4149,7 +4149,7 @@ handle_const_attribute (tree *node, tree name, tree ARG_UNUSED (args),
TREE_THIS_VOLATILE (TREE_TYPE (type))));
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4193,7 +4193,7 @@ handle_transparent_union_attribute (tree *node, tree name,
DECL_TRANSPARENT_UNION (decl) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4221,7 +4221,7 @@ handle_constructor_attribute (tree *node, tree name,
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4249,7 +4249,7 @@ handle_destructor_attribute (tree *node, tree name,
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4268,7 +4268,7 @@ handle_mode_attribute (tree *node, tree name, tree args,
*no_add_attrs = true;
if (TREE_CODE (TREE_VALUE (args)) != IDENTIFIER_NODE)
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
else
{
int j;
@@ -4326,9 +4326,10 @@ handle_mode_attribute (tree *node, tree name, tree args,
case MODE_VECTOR_INT:
case MODE_VECTOR_FLOAT:
- warning (0, "specifying vector types with __attribute__ ((mode)) "
- "is deprecated");
- warning (0, "use __attribute__ ((vector_size)) instead");
+ warning (OPT_Wattributes, "specifying vector types with "
+ "__attribute__ ((mode)) is deprecated");
+ warning (OPT_Wattributes,
+ "use __attribute__ ((vector_size)) instead");
valid_mode = vector_mode_valid_p (mode);
break;
@@ -4593,7 +4594,7 @@ handle_alias_attribute (tree *node, tree name, tree args,
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4617,13 +4618,14 @@ handle_visibility_attribute (tree *node, tree name, tree args,
{
if (TREE_CODE (*node) != RECORD_TYPE && TREE_CODE (*node) != UNION_TYPE)
{
- warning (0, "%qE attribute ignored on non-class types", name);
+ warning (OPT_Wattributes, "%qE attribute ignored on non-class types",
+ name);
return NULL_TREE;
}
}
else if (decl_function_context (decl) != 0 || !TREE_PUBLIC (decl))
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
return NULL_TREE;
}
@@ -4641,7 +4643,7 @@ handle_visibility_attribute (tree *node, tree name, tree args,
return NULL_TREE;
if (TREE_CODE (decl) == IDENTIFIER_NODE)
{
- warning (0, "%qE attribute ignored on types",
+ warning (OPT_Wattributes, "%qE attribute ignored on types",
name);
return NULL_TREE;
}
@@ -4715,7 +4717,7 @@ handle_tls_model_attribute (tree *node, tree name, tree args,
if (!DECL_THREAD_LOCAL (decl))
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
else
@@ -4782,7 +4784,7 @@ handle_malloc_attribute (tree *node, tree name, tree ARG_UNUSED (args),
DECL_IS_MALLOC (*node) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4800,7 +4802,7 @@ handle_returns_twice_attribute (tree *node, tree name, tree ARG_UNUSED (args),
DECL_IS_RETURNS_TWICE (*node) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4846,7 +4848,7 @@ handle_pure_attribute (tree *node, tree name, tree ARG_UNUSED (args),
/* ??? TODO: Support types. */
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -4914,9 +4916,9 @@ handle_deprecated_attribute (tree *node, tree name,
what = DECL_NAME (TYPE_NAME (type));
}
if (what)
- warning (0, "%qE attribute ignored for %qE", name, what);
+ warning (OPT_Wattributes, "%qE attribute ignored for %qE", name, what);
else
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
}
return NULL_TREE;
@@ -4940,7 +4942,7 @@ handle_vector_size_attribute (tree *node, tree name, tree args,
if (!host_integerp (size, 1))
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
return NULL_TREE;
}
@@ -5218,7 +5220,7 @@ handle_nothrow_attribute (tree *node, tree name, tree ARG_UNUSED (args),
/* ??? TODO: Support types. */
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -5241,7 +5243,7 @@ handle_cleanup_attribute (tree *node, tree name, tree args,
we'd be missing too much, since we do have attribute constructor. */
if (TREE_CODE (decl) != VAR_DECL || TREE_STATIC (decl))
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
return NULL_TREE;
}
@@ -5280,7 +5282,7 @@ handle_warn_unused_result_attribute (tree *node, tree name,
/* Ignore the attribute for functions not returning any value. */
if (VOID_TYPE_P (TREE_TYPE (*node)))
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
@@ -5297,7 +5299,8 @@ handle_sentinel_attribute (tree *node, tree name, tree args,
if (!params)
{
- warning (0, "%qE attribute requires prototypes with named arguments", name);
+ warning (OPT_Wattributes,
+ "%qE attribute requires prototypes with named arguments", name);
*no_add_attrs = true;
}
else
@@ -5307,7 +5310,8 @@ handle_sentinel_attribute (tree *node, tree name, tree args,
if (VOID_TYPE_P (TREE_VALUE (params)))
{
- warning (0, "%qE attribute only applies to variadic functions", name);
+ warning (OPT_Wattributes,
+ "%qE attribute only applies to variadic functions", name);
*no_add_attrs = true;
}
}
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index efbd512..d5e13ab 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -1480,15 +1480,15 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
if (DECL_DECLARED_INLINE_P (newdecl)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
{
- warning (0, "%Jinline declaration of %qD follows "
+ warning (OPT_Wattributes, "%Jinline declaration of %qD follows "
"declaration with attribute noinline", newdecl, newdecl);
warned = true;
}
else if (DECL_DECLARED_INLINE_P (olddecl)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
{
- warning (0, "%Jdeclaration of %qD with attribute noinline follows "
- "inline declaration ", newdecl, newdecl);
+ warning (OPT_Wattributes, "%Jdeclaration of %qD with attribute "
+ "noinline follows inline declaration ", newdecl, newdecl);
warned = true;
}
@@ -3198,7 +3198,8 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
&& DECL_DECLARED_INLINE_P (decl)
&& DECL_UNINLINABLE (decl)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
- warning (0, "%Jinline function %qD given attribute noinline", decl, decl);
+ warning (OPT_Wattributes, "%Jinline function %qD given attribute noinline",
+ decl, decl);
/* Add this decl to the current scope.
TEM may equal DECL or it may be a previous decl of the same name. */
@@ -4433,7 +4434,8 @@ grokdeclarator (const struct c_declarator *declarator,
/* We don't yet implement attributes in this context. */
if (array_ptr_attrs != NULL_TREE)
- warning (0, "attributes in parameter array declarator ignored");
+ warning (OPT_Wattributes,
+ "attributes in parameter array declarator ignored");
size_varies = 0;
}
@@ -5782,7 +5784,8 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
if (DECL_DECLARED_INLINE_P (decl1)
&& DECL_UNINLINABLE (decl1)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
- warning (0, "%Jinline function %qD given attribute noinline", decl1, decl1);
+ warning (OPT_Wattributes, "%Jinline function %qD given attribute noinline",
+ decl1, decl1);
announce_function (decl1);
diff --git a/gcc/c-format.c b/gcc/c-format.c
index f413e39..f27d6d0 100644
--- a/gcc/c-format.c
+++ b/gcc/c-format.c
@@ -833,7 +833,8 @@ check_function_format (tree attrs, tree params)
break;
}
if (args != 0)
- warning (0, "function might be possible candidate for %qs format attribute",
+ warning (OPT_Wattributes, "function might be possible "
+ "candidate for %qs format attribute",
format_types[info.format_type].name);
}
}
diff --git a/gcc/common.opt b/gcc/common.opt
index ab0129f..91cc3c1 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -57,6 +57,10 @@ Waggregate-return
Common Var(warn_aggregate_return)
Warn about returning structures, unions or arrays
+Wattributes
+Common Var(warn_attributes) Init(1)
+Warn about inappropriate attribute usage
+
Wcast-align
Common Var(warn_cast_align)
Warn about pointer casts which increase alignment
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 52eca9f..2161817 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -410,14 +410,16 @@ arc_handle_interrupt_attribute (tree *node ATTRIBUTE_UNUSED,
if (TREE_CODE (value) != STRING_CST)
{
- warning (0, "argument of %qs attribute is not a string constant",
+ warning (OPT_Wattributes,
+ "argument of %qs attribute is not a string constant",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
else if (strcmp (TREE_STRING_POINTER (value), "ilink1")
&& strcmp (TREE_STRING_POINTER (value), "ilink2"))
{
- warning (0, "argument of %qs attribute is not \"ilink1\" or \"ilink2\"",
+ warning (OPT_Wattributes,
+ "argument of %qs attribute is not \"ilink1\" or \"ilink2\"",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 26fb38c..f2266c7 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -2812,7 +2812,7 @@ arm_handle_fndecl_attribute (tree *node, tree name, tree args ATTRIBUTE_UNUSED,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -2830,7 +2830,7 @@ arm_handle_isr_attribute (tree *node, tree name, tree args, int flags,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -2844,7 +2844,8 @@ arm_handle_isr_attribute (tree *node, tree name, tree args, int flags,
{
if (arm_isr_value (args) == ARM_FT_UNKNOWN)
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
}
@@ -2871,7 +2872,8 @@ arm_handle_isr_attribute (tree *node, tree name, tree args, int flags,
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
}
}
}
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index 0be2f1c..45b51f2 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -4676,7 +4676,8 @@ avr_handle_progmem_attribute (tree *node, tree name,
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
}
@@ -4695,7 +4696,7 @@ avr_handle_fndecl_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 653c200..8f3e054 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -2558,7 +2558,7 @@ handle_int_attribute (tree *node, tree name,
if (TREE_CODE (x) != FUNCTION_TYPE)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/c4x/c4x.c b/gcc/config/c4x/c4x.c
index 0998544..119c7be 100644
--- a/gcc/config/c4x/c4x.c
+++ b/gcc/config/c4x/c4x.c
@@ -4486,7 +4486,7 @@ c4x_handle_fntype_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != FUNCTION_TYPE)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 602df2f..7b3289f 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -1222,7 +1222,8 @@ darwin_handle_weak_import_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != FUNCTION_DECL && TREE_CODE (*node) != VAR_DECL)
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
else
@@ -1335,8 +1336,8 @@ darwin_assemble_visibility (tree decl, int vis)
fputs ("\n", asm_out_file);
}
else
- warning (0, "internal and protected visibility attributes not supported "
- "in this configuration; ignored");
+ warning (OPT_Wattributes, "internal and protected visibility attributes "
+ "not supported in this configuration; ignored");
}
/* Output a difference of two labels that will be an assembly time
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c
index 77a7768..45fb514 100644
--- a/gcc/config/h8300/h8300.c
+++ b/gcc/config/h8300/h8300.c
@@ -5255,7 +5255,7 @@ h8300_handle_fndecl_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -5279,7 +5279,8 @@ h8300_handle_eightbit_data_attribute (tree *node, tree name,
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -5302,7 +5303,8 @@ h8300_handle_tiny_data_attribute (tree *node, tree name,
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 2ed8edf..43fcd2e 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -1815,7 +1815,7 @@ ix86_handle_cdecl_attribute (tree *node, tree name,
&& TREE_CODE (*node) != FIELD_DECL
&& TREE_CODE (*node) != TYPE_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -1843,7 +1843,8 @@ ix86_handle_cdecl_attribute (tree *node, tree name,
if (TARGET_64BIT)
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -1861,7 +1862,7 @@ ix86_handle_regparm_attribute (tree *node, tree name, tree args,
&& TREE_CODE (*node) != FIELD_DECL
&& TREE_CODE (*node) != TYPE_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -1872,13 +1873,14 @@ ix86_handle_regparm_attribute (tree *node, tree name, tree args,
cst = TREE_VALUE (args);
if (TREE_CODE (cst) != INTEGER_CST)
{
- warning (0, "%qs attribute requires an integer constant argument",
+ warning (OPT_Wattributes,
+ "%qs attribute requires an integer constant argument",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
else if (compare_tree_int (cst, REGPARM_MAX) > 0)
{
- warning (0, "argument to %qs attribute larger than %d",
+ warning (OPT_Wattributes, "argument to %qs attribute larger than %d",
IDENTIFIER_POINTER (name), REGPARM_MAX);
*no_add_attrs = true;
}
@@ -16054,7 +16056,8 @@ ix86_handle_struct_attribute (tree *node, tree name,
if (!(type && (TREE_CODE (*type) == RECORD_TYPE
|| TREE_CODE (*type) == UNION_TYPE)))
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -16063,7 +16066,7 @@ ix86_handle_struct_attribute (tree *node, tree name,
|| ((is_attribute_p ("gcc_struct", name)
&& lookup_attribute ("ms_struct", TYPE_ATTRIBUTES (*type)))))
{
- warning (0, "%qs incompatible attribute ignored",
+ warning (OPT_Wattributes, "%qs incompatible attribute ignored",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/i386/winnt.c b/gcc/config/i386/winnt.c
index 74375aa..6eae2e7 100644
--- a/gcc/config/i386/winnt.c
+++ b/gcc/config/i386/winnt.c
@@ -71,7 +71,7 @@ ix86_handle_shared_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != VAR_DECL)
{
- warning (0, "%qs attribute only applies to variables",
+ warning (OPT_Wattributes, "%qs attribute only applies to variables",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -466,8 +466,9 @@ i386_pe_encode_section_info (tree decl, rtx rtl, int first)
warning (0, "%J'%D' defined locally after being "
"referenced with dllimport linkage", decl, decl);
else
- warning (0, "%J'%D' redeclared without dllimport attribute "
- "after being referenced with dllimport linkage", decl, decl);
+ warning (OPT_Wattributes, "%J'%D' redeclared without dllimport "
+ "attribute after being referenced with dllimport linkage",
+ decl, decl);
}
}
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index c8e0ea3..a52b7d8 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -484,7 +484,7 @@ ia64_handle_model_attribute (tree *node, tree name, tree args,
}
else
{
- warning (0, "invalid argument of %qs attribute",
+ warning (OPT_Wattributes, "invalid argument of %qs attribute",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -516,7 +516,8 @@ ia64_handle_model_attribute (tree *node, tree name, tree args,
break;
default:
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
break;
}
diff --git a/gcc/config/ip2k/ip2k.c b/gcc/config/ip2k/ip2k.c
index 314a2c7..7542b46 100644
--- a/gcc/config/ip2k/ip2k.c
+++ b/gcc/config/ip2k/ip2k.c
@@ -3161,7 +3161,8 @@ ip2k_handle_progmem_attribute (tree *node, tree name,
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
}
@@ -3179,7 +3180,7 @@ ip2k_handle_fndecl_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c
index 6e08203..c27b244 100644
--- a/gcc/config/m32r/m32r.c
+++ b/gcc/config/m32r/m32r.c
@@ -387,7 +387,7 @@ m32r_handle_model_attribute (tree *node ATTRIBUTE_UNUSED, tree name,
&& arg != large_ident1
&& arg != large_ident2)
{
- warning (0, "invalid argument of %qs attribute",
+ warning (OPT_Wattributes, "invalid argument of %qs attribute",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/m68hc11/m68hc11.c b/gcc/config/m68hc11/m68hc11.c
index 6b68d25..fca34d2 100644
--- a/gcc/config/m68hc11/m68hc11.c
+++ b/gcc/config/m68hc11/m68hc11.c
@@ -1115,7 +1115,8 @@ m68hc11_handle_page0_attribute (tree *node, tree name,
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -1151,7 +1152,7 @@ m68hc11_handle_fntype_attribute (tree *node, tree name,
&& TREE_CODE (*node) != FIELD_DECL
&& TREE_CODE (*node) != TYPE_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -1236,13 +1237,14 @@ m68hc11_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED)
trap_handler = lookup_attribute ("trap", func_attr) != NULL_TREE;
if (trap_handler && is_far)
{
- warning (0, "%<trap%> and %<far%> attributes are not compatible, ignoring %<far%>");
+ warning (OPT_Wattributes, "%<trap%> and %<far%> attributes are "
+ "not compatible, ignoring %<far%>");
trap_handler = 0;
}
if (trap_handler)
{
if (trap_handler_symbol != 0)
- warning (0, "%<trap%> attribute is already used");
+ warning (OPT_Wattributes, "%<trap%> attribute is already used");
else
trap_handler_symbol = XEXP (rtl, 0);
}
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index e456317..9db2ddd 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -373,7 +373,7 @@ m68k_handle_fndecl_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c
index fff8a3e..e07f247 100644
--- a/gcc/config/mcore/mcore.c
+++ b/gcc/config/mcore/mcore.c
@@ -3029,7 +3029,7 @@ mcore_handle_naked_attribute (tree * node, tree name, tree args ATTRIBUTE_UNUSED
}
else
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/ns32k/ns32k.c b/gcc/config/ns32k/ns32k.c
index f15e5dc..e4448ef 100644
--- a/gcc/config/ns32k/ns32k.c
+++ b/gcc/config/ns32k/ns32k.c
@@ -1106,7 +1106,7 @@ ns32k_handle_fntype_attribute (tree *node, tree name,
&& TREE_CODE (*node) != FIELD_DECL
&& TREE_CODE (*node) != TYPE_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index bcf38e1..228af5d 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16527,7 +16527,7 @@ rs6000_handle_longcall_attribute (tree *node, tree name,
&& TREE_CODE (*node) != FIELD_DECL
&& TREE_CODE (*node) != TYPE_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index a0b7862..9da837e 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -7393,7 +7393,7 @@ sh_handle_interrupt_handler_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -7414,21 +7414,21 @@ sh_handle_sp_switch_attribute (tree *node, tree name, tree args,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
else if (!pragma_interrupt)
{
/* The sp_switch attribute only has meaning for interrupt functions. */
- warning (0, "%qs attribute only applies to interrupt functions",
- IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute only applies to "
+ "interrupt functions", IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
else if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
{
/* The argument must be a constant string. */
- warning (0, "%qs attribute argument not a string constant",
+ warning (OPT_Wattributes, "%qs attribute argument not a string constant",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -7449,22 +7449,22 @@ sh_handle_trap_exit_attribute (tree *node, tree name, tree args,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
else if (!pragma_interrupt)
{
/* The trap_exit attribute only has meaning for interrupt functions. */
- warning (0, "%qs attribute only applies to interrupt functions",
- IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute only applies to "
+ "interrupt functions", IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
else if (TREE_CODE (TREE_VALUE (args)) != INTEGER_CST)
{
/* The argument must be a constant integer. */
- warning (0, "%qs attribute argument not an integer constant",
- IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute argument not an "
+ "integer constant", IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
else
diff --git a/gcc/config/sh/symbian.c b/gcc/config/sh/symbian.c
index b3e8287..cc51841 100644
--- a/gcc/config/sh/symbian.c
+++ b/gcc/config/sh/symbian.c
@@ -144,7 +144,8 @@ sh_symbian_dllimport_p (tree decl)
{
/* Don't warn about artificial methods. */
if (!DECL_ARTIFICIAL (decl))
- warning (0, "%H function '%D' is defined after prior declaration as dllimport: attribute ignored",
+ warning (OPT_Wattributes, "%H function '%D' is defined after prior "
+ "declaration as dllimport: attribute ignored",
& DECL_SOURCE_LOCATION (decl), decl);
return false;
}
@@ -155,7 +156,8 @@ sh_symbian_dllimport_p (tree decl)
else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl))
{
if (extra_warnings)
- warning (0, "%Hinline function '%D' is declared as dllimport: attribute ignored.",
+ warning (OPT_Wattributes, "%Hinline function '%D' is declared as "
+ "dllimport: attribute ignored.",
& DECL_SOURCE_LOCATION (decl), decl);
return false;
}
@@ -403,14 +405,14 @@ sh_symbian_handle_dll_attribute (tree *pnode, tree name, tree args,
| (int) ATTR_FLAG_FUNCTION_NEXT
| (int) ATTR_FLAG_ARRAY_NEXT))
{
- warning (0, "%qs attribute ignored", attr);
+ warning (OPT_Wattributes, "%qs attribute ignored", attr);
*no_add_attrs = true;
return tree_cons (name, args, NULL_TREE);
}
if (TREE_CODE (node) != RECORD_TYPE && TREE_CODE (node) != UNION_TYPE)
{
- warning (0, "%qs attribute ignored", attr);
+ warning (OPT_Wattributes, "%qs attribute ignored", attr);
*no_add_attrs = true;
}
diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c
index 79d35de..469ecf5 100644
--- a/gcc/config/stormy16/stormy16.c
+++ b/gcc/config/stormy16/stormy16.c
@@ -2276,7 +2276,7 @@ xstormy16_handle_interrupt_attribute (tree *node, tree name,
{
if (TREE_CODE (*node) != FUNCTION_TYPE)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
@@ -2297,14 +2297,16 @@ xstormy16_handle_below100_attribute (tree *node,
&& TREE_CODE (*node) != POINTER_TYPE
&& TREE_CODE (*node) != TYPE_DECL)
{
- warning (0, "%<__BELOW100__%> attribute only applies to variables");
+ warning (OPT_Wattributes,
+ "%<__BELOW100__%> attribute only applies to variables");
*no_add_attrs = true;
}
else if (args == NULL_TREE && TREE_CODE (*node) == VAR_DECL)
{
if (! (TREE_PUBLIC (*node) || TREE_STATIC (*node)))
{
- warning (0, "__BELOW100__ attribute not allowed with auto storage class.");
+ warning (OPT_Wattributes, "__BELOW100__ attribute not allowed "
+ "with auto storage class.");
*no_add_attrs = true;
}
}
diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c
index 06e26db..f67c4e7 100644
--- a/gcc/config/v850/v850.c
+++ b/gcc/config/v850/v850.c
@@ -2101,7 +2101,7 @@ v850_handle_interrupt_attribute (tree * node,
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 524c943..aa8b26c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2005-05-25 DJ Delorie <dj@redhat.com>
+
+ * decl.c (duplicate_decls): Move warning control from if() to
+ warning(OPT_*).
+ * name-lookup.c (parse_using_directive): Likewise.
+ * parser.c (cp_parser_elaborated_type_specifier): Likewise.
+ (cp_parser_init_declarator): Likewise.
+ * tree.c (handle_com_interface_attribute): Likewise.
+
2005-05-24 Ziemowit Laski <zlaski@apple.com>
* class.c (layout_class_type): Do not issue C++ ABI warnings
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0da9937..d354417 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1051,17 +1051,18 @@ duplicate_decls (tree newdecl, tree olddecl)
&& DECL_UNINLINABLE (olddecl)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
{
- warning (0, "%Jfunction %qD redeclared as inline", newdecl, newdecl);
- warning (0, "%Jprevious declaration of %qD with attribute noinline",
- olddecl, olddecl);
+ warning (OPT_Wattributes, "%Jfunction %qD redeclared as inline",
+ newdecl, newdecl);
+ warning (OPT_Wattributes, "%Jprevious declaration of %qD "
+ "with attribute noinline", olddecl, olddecl);
}
else if (DECL_DECLARED_INLINE_P (olddecl)
&& DECL_UNINLINABLE (newdecl)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
{
- warning (0, "%Jfunction %qD redeclared with attribute noinline",
- newdecl, newdecl);
- warning (0, "%Jprevious declaration of %qD was inline",
+ warning (OPT_Wattributes, "%Jfunction %qD redeclared with "
+ "attribute noinline", newdecl, newdecl);
+ warning (OPT_Wattributes, "%Jprevious declaration of %qD was inline",
olddecl, olddecl);
}
}
@@ -1802,9 +1803,10 @@ duplicate_decls (tree newdecl, tree olddecl)
&& DECL_VISIBILITY_SPECIFIED (newdecl)
&& DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
{
- warning (0, "%J%qD: visibility attribute ignored because it",
- newdecl, newdecl);
- warning (0, "%Jconflicts with previous declaration here", olddecl);
+ warning (OPT_Wattributes, "%J%qD: visibility attribute ignored "
+ "because it", newdecl, newdecl);
+ warning (OPT_Wattributes, "%Jconflicts with previous "
+ "declaration here", olddecl);
}
/* Choose the declaration which specified visibility. */
if (DECL_VISIBILITY_SPECIFIED (olddecl))
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 0bb8888..bd83695 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3207,7 +3207,7 @@ parse_using_directive (tree namespace, tree attribs)
DECL_NAMESPACE_ASSOCIATIONS (namespace));
}
else
- warning (0, "%qD attribute directive ignored", name);
+ warning (OPT_Wattributes, "%qD attribute directive ignored", name);
}
}
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 2527fb2..a0d71b3 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -10024,7 +10024,8 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
/* Warn about attributes. They are ignored. */
if (attributes)
- warning (0, "type attributes are honored only at type definition");
+ warning (OPT_Wattributes,
+ "type attributes are honored only at type definition");
type = xref_tag (tag_type, identifier, ts,
parser->num_template_parameter_lists);
@@ -10869,7 +10870,8 @@ cp_parser_init_declarator (cp_parser* parser,
attributes -- but ignores them. */
if (cp_parser_allow_gnu_extensions_p (parser) && is_parenthesized_init)
if (cp_parser_attributes_opt (parser))
- warning (0, "attributes after parenthesized initializer ignored");
+ warning (OPT_Wattributes,
+ "attributes after parenthesized initializer ignored");
/* For an in-class declaration, use `grokfield' to create the
declaration. */
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 114275c..64a5aa5 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1769,7 +1769,8 @@ handle_com_interface_attribute (tree* node,
|| !CLASS_TYPE_P (*node)
|| *node != TYPE_MAIN_VARIANT (*node))
{
- warning (0, "%qE attribute can only be applied to class definitions", name);
+ warning (OPT_Wattributes, "%qE attribute can only be applied "
+ "to class definitions", name);
return NULL_TREE;
}
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 1a96988..a104c54 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -218,7 +218,7 @@ Objective-C and Objective-C++ Dialects}.
@item Warning Options
@xref{Warning Options,,Options to Request or Suppress Warnings}.
@gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
--w -Wextra -Wall -Waggregate-return @gol
+-w -Wextra -Wall -Waggregate-return -Wno-attributes @gol
-Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
-Wconversion -Wno-deprecated-declarations @gol
-Wdisabled-optimization -Wno-div-by-zero -Wno-endif-labels @gol
@@ -3046,6 +3046,14 @@ Warn if any functions that return structures or unions are defined or
called. (In languages where you can return an array, this also elicits
a warning.)
+@item -Wno-attributes
+@opindex Wno-attributes
+@opindex Wattributes
+Do not warn if an unexpected @code{__attribute__} is used, such as
+unrecognized attributes, function attributes applied to variables,
+etc. This will not stop errors for incorrect use of supported
+attributes.
+
@item -Wstrict-prototypes @r{(C only)}
@opindex Wstrict-prototypes
Warn if a function is declared or defined without specifying the
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 8617681..a9bcf44 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -1,3 +1,8 @@
+2005-05-25 DJ Delorie <dj@redhat.com>
+
+ * class.c (set_constant_value): Move warning control from if() to
+ warning(OPT_*).
+
2005-05-24 Richard Henderson <rth@redhat.com>
* builtins.c (define_builtin): Don't call make_decl_rtl.
diff --git a/gcc/java/class.c b/gcc/java/class.c
index 5616351..3e8ae26 100644
--- a/gcc/java/class.c
+++ b/gcc/java/class.c
@@ -790,9 +790,11 @@ void
set_constant_value (tree field, tree constant)
{
if (field == NULL_TREE)
- warning (0, "misplaced ConstantValue attribute (not in any field)");
+ warning (OPT_Wattributes,
+ "misplaced ConstantValue attribute (not in any field)");
else if (DECL_INITIAL (field) != NULL_TREE)
- warning (0, "duplicate ConstantValue attribute for field '%s'",
+ warning (OPT_Wattributes,
+ "duplicate ConstantValue attribute for field '%s'",
IDENTIFIER_POINTER (DECL_NAME (field)));
else
{
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 65d98f8..12581c5 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -851,11 +851,11 @@ place_field (record_layout_info rli, tree field)
if (TYPE_ALIGN (type) > desired_align)
{
if (STRICT_ALIGNMENT)
- warning (0, "%Jpacked attribute causes inefficient alignment "
- "for %qD", field, field);
+ warning (OPT_Wattributes, "%Jpacked attribute causes "
+ "inefficient alignment for %qD", field, field);
else
- warning (0, "%Jpacked attribute is unnecessary for %qD",
- field, field);
+ warning (OPT_Wattributes, "%Jpacked attribute is "
+ "unnecessary for %qD", field, field);
}
}
else
@@ -1298,17 +1298,19 @@ finalize_record_size (record_layout_info rli)
name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (rli->t)));
if (STRICT_ALIGNMENT)
- warning (0, "packed attribute causes inefficient "
+ warning (OPT_Wattributes, "packed attribute causes inefficient "
"alignment for %qs", name);
else
- warning (0, "packed attribute is unnecessary for %qs", name);
+ warning (OPT_Wattributes,
+ "packed attribute is unnecessary for %qs", name);
}
else
{
if (STRICT_ALIGNMENT)
- warning (0, "packed attribute causes inefficient alignment");
+ warning (OPT_Wattributes,
+ "packed attribute causes inefficient alignment");
else
- warning (0, "packed attribute is unnecessary");
+ warning (OPT_Wattributes, "packed attribute is unnecessary");
}
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f5d5943..9adf65f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2005-05-25 DJ Delorie <dj@redhat.com>
+
+ * gcc.dg/Wattributes-1.c: New.
+ * gcc.dg/Wattributes-2.c: New.
+ * gcc.dg/Wattributes-3.c: New.
+
20005-05-24 Janis Johnson <janis187@us.ibm.com>
PR tree-optimization/19833
diff --git a/gcc/testsuite/gcc.dg/Wattributes-1.c b/gcc/testsuite/gcc.dg/Wattributes-1.c
new file mode 100644
index 0000000..29e07e4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wattributes-1.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options -Wattributes } */
+
+void __attribute__((dj)) foo() { } /* { dg-warning "attribute directive ignored" } */
+
+int j __attribute__((unrecognized)); /* { dg-warning "attribute directive ignored" } */
diff --git a/gcc/testsuite/gcc.dg/Wattributes-2.c b/gcc/testsuite/gcc.dg/Wattributes-2.c
new file mode 100644
index 0000000..6918704
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wattributes-2.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options -Wno-attributes } */
+
+void __attribute__((dj)) foo() { } /* { dg-bogus "attribute directive ignored" } */
+
+int j __attribute__((unrecognized)); /* { dg-bogus "attribute directive ignored" } */
diff --git a/gcc/testsuite/gcc.dg/Wattributes-3.c b/gcc/testsuite/gcc.dg/Wattributes-3.c
new file mode 100644
index 0000000..59d14c7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wattributes-3.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+void __attribute__((dj)) foo() { } /* { dg-warning "attribute directive ignored" } */
+
+int j __attribute__((unrecognized)); /* { dg-warning "attribute directive ignored" } */
diff --git a/gcc/tree.c b/gcc/tree.c
index de74fe9..9b45e0a 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -3270,7 +3270,8 @@ handle_dll_attribute (tree * pnode, tree name, tree args, int flags,
}
if (TREE_CODE (node) != RECORD_TYPE && TREE_CODE (node) != UNION_TYPE)
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 4590d92..8192a7a 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -4689,7 +4689,8 @@ default_assemble_visibility (tree decl, int vis)
assemble_name (asm_out_file, name);
fprintf (asm_out_file, "\n");
#else
- warning (0, "visibility attribute not supported in this configuration; ignored");
+ warning (OPT_Wattributes, "visibility attribute not supported "
+ "in this configuration; ignored");
#endif
}