* 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
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_*).
if (spec == NULL)
{
- warning (0, "%qs attribute directive ignored",
+ warning (OPT_Wattributes, "%qs attribute directive ignored",
IDENTIFIER_POINTER (name));
continue;
}
}
else
{
- warning (0, "%qs attribute does not apply to types",
+ warning (OPT_Wattributes, "%qs attribute does not apply to types",
IDENTIFIER_POINTER (name));
continue;
}
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;
}
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;
}
DECL_COMMON (*node) = 0;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
DECL_COMMON (*node) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
TYPE_READONLY (TREE_TYPE (type)), 1));
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
DECL_UNINLINABLE (*node) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
TREE_USED (decl) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
}
TREE_THIS_VOLATILE (TREE_TYPE (type))));
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
DECL_TRANSPARENT_UNION (decl) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
*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;
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;
}
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
{
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;
}
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;
}
if (!DECL_THREAD_LOCAL (decl))
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
else
DECL_IS_MALLOC (*node) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
DECL_IS_RETURNS_TWICE (*node) = 1;
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
/* ??? TODO: Support types. */
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
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;
if (!host_integerp (size, 1))
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
return NULL_TREE;
}
/* ??? TODO: Support types. */
else
{
- warning (0, "%qE attribute ignored", name);
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
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;
}
/* 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;
}
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
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;
}
}
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;
}
&& 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. */
/* 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;
}
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);
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);
}
}
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
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;
}
{
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;
}
{
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;
}
{
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;
}
}
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
}
}
}
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
}
{
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;
}
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;
}
{
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;
}
{
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
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
{
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
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
&& 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;
}
if (TARGET_64BIT)
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
&& 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;
}
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;
}
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;
}
|| ((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;
}
{
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;
}
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);
}
}
}
else
{
- warning (0, "invalid argument of %qs attribute",
+ warning (OPT_Wattributes, "invalid argument of %qs attribute",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
break;
default:
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
break;
}
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
}
{
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;
}
&& 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;
}
}
else
{
- warning (0, "%qs attribute ignored", IDENTIFIER_POINTER (name));
+ warning (OPT_Wattributes, "%qs attribute ignored",
+ IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
&& 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;
}
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);
}
{
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
{
- warning (0, "%qs attribute only applies to functions",
+ warning (OPT_Wattributes, "%qs attribute only applies to functions",
IDENTIFIER_POINTER (name));
*no_add_attrs = true;
}
&& 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;
}
&& 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;
}
{
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;
}
{
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;
}
{
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
{
/* 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;
}
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;
}
| (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;
}
{
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;
}
&& 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;
}
}
{
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;
}
+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
&& 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);
}
}
&& 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))
DECL_NAMESPACE_ASSOCIATIONS (namespace));
}
else
- warning (0, "%qD attribute directive ignored", name);
+ warning (OPT_Wattributes, "%qD attribute directive ignored", name);
}
}
/* 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);
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. */
|| !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;
}
@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
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
+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.
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
{
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
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");
}
}
}
+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
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options -Wattributes } */
+
+void __attribute__((dj)) foo() { } /* { dg-warning "attribute directive ignored" } */
+
+int j __attribute__((unrecognized)); /* { dg-warning "attribute directive ignored" } */
--- /dev/null
+/* { 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" } */
--- /dev/null
+/* { dg-do compile } */
+
+void __attribute__((dj)) foo() { } /* { dg-warning "attribute directive ignored" } */
+
+int j __attribute__((unrecognized)); /* { dg-warning "attribute directive ignored" } */
}
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;
}
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
}