Commit 435ab236 by Gabriel Dos Reis Committed by Gabriel Dos Reis

c-decl.c (c_finish_incomplete_decl): Don't use xxx_with_decl.

	* c-decl.c (c_finish_incomplete_decl): Don't use xxx_with_decl.
	(pop_label_level): Likewise.
	(duplicate_decls): Likewise.
	(implicitly_declare): Likewise.
	(shadow_label): Likewise.
	(start_decl): Likewise.
	(finish_decl): Likewise.
	(grokdeclarator): Likewise.
	(get_parm_info): Likewise.
	(detect_field_duplicates): Likewise.
	(finish_struct): Likewise.
	(start_function): Likewise.
	(store_parm_decls): Likewise.
	(finish_function): Likewise.
	(c_expand_body_1): Likewise.
	(check_for_loop_decls): Likewise.
	(merge_translation_unit_decls): Likewise.

From-SVN: r69582
parent 2cc98056
2003-07-19 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-decl.c (c_finish_incomplete_decl): Don't use xxx_with_decl.
(pop_label_level): Likewise.
(duplicate_decls): Likewise.
(implicitly_declare): Likewise.
(shadow_label): Likewise.
(start_decl): Likewise.
(finish_decl): Likewise.
(grokdeclarator): Likewise.
(get_parm_info): Likewise.
(detect_field_duplicates): Likewise.
(finish_struct): Likewise.
(start_function): Likewise.
(store_parm_decls): Likewise.
(finish_function): Likewise.
(c_expand_body_1): Likewise.
(check_for_loop_decls): Likewise.
(merge_translation_unit_decls): Likewise.
2003-07-19 Neil Booth <neil@daikokuya.co.uk> 2003-07-19 Neil Booth <neil@daikokuya.co.uk>
* common.opt: Document --param. * common.opt: Document --param.
......
...@@ -337,7 +337,8 @@ c_finish_incomplete_decl (tree decl) ...@@ -337,7 +337,8 @@ c_finish_incomplete_decl (tree decl)
&& ! DECL_EXTERNAL (decl) && ! DECL_EXTERNAL (decl)
&& TYPE_DOMAIN (type) == 0) && TYPE_DOMAIN (type) == 0)
{ {
warning_with_decl (decl, "array `%s' assumed to have one element"); warning ("%Harray '%D' assumed to have one element",
&DECL_SOURCE_LOCATION (decl), decl);
complete_array_type (type, NULL_TREE, 1); complete_array_type (type, NULL_TREE, 1);
...@@ -611,12 +612,14 @@ poplevel (int keep, int reverse, int functionbody) ...@@ -611,12 +612,14 @@ poplevel (int keep, int reverse, int functionbody)
if (DECL_INITIAL (label) == 0) if (DECL_INITIAL (label) == 0)
{ {
error_with_decl (label, "label `%s' used but not defined"); error ("%Hlabel '%D' used but not defined",
&DECL_SOURCE_LOCATION (label), label);
/* Avoid crashing later. */ /* Avoid crashing later. */
define_label (input_location, DECL_NAME (label)); define_label (input_location, DECL_NAME (label));
} }
else if (warn_unused_label && !TREE_USED (label)) else if (warn_unused_label && !TREE_USED (label))
warning_with_decl (label, "label `%s' defined but not used"); warning ("%Hlabel '%D' defined but not used",
&DECL_SOURCE_LOCATION (label), label);
IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0; IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0;
/* Put the labels into the "variables" of the /* Put the labels into the "variables" of the
...@@ -701,14 +704,16 @@ pop_label_level (void) ...@@ -701,14 +704,16 @@ pop_label_level (void)
{ {
if (DECL_SOURCE_LINE (TREE_VALUE (link)) == 0) if (DECL_SOURCE_LINE (TREE_VALUE (link)) == 0)
{ {
error_with_decl (TREE_VALUE (link), error ("%Hlabel '%D' used but not defined",
"label `%s' used but not defined"); &DECL_SOURCE_LOCATION (TREE_VALUE (link)),
TREE_VALUE (link));
/* Avoid crashing later. */ /* Avoid crashing later. */
define_label (input_location, DECL_NAME (TREE_VALUE (link))); define_label (input_location, DECL_NAME (TREE_VALUE (link)));
} }
else if (warn_unused_label && !TREE_USED (TREE_VALUE (link))) else if (warn_unused_label && !TREE_USED (TREE_VALUE (link)))
warning_with_decl (TREE_VALUE (link), warning ("%Hlabel '%D' defined but not used",
"label `%s' defined but not used"); &DECL_SOURCE_LOCATION (TREE_VALUE (link)),
TREE_VALUE (link));
IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link))) = 0; IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link))) = 0;
/* Delete this element from the list. */ /* Delete this element from the list. */
...@@ -823,19 +828,20 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -823,19 +828,20 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
&& DECL_UNINLINABLE (olddecl) && DECL_UNINLINABLE (olddecl)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
{ {
warning_with_decl (newdecl, warning ("%Hfunction '%D' redeclared as inline",
"function `%s' redeclared as inline"); &DECL_SOURCE_LOCATION (newdecl), newdecl);
warning_with_decl (olddecl, warning ("%Hprevious declaration of function '%D' "
"previous declaration of function `%s' with attribute noinline"); "with attribute noinline",
&DECL_SOURCE_LOCATION (olddecl), olddecl);
} }
else if (DECL_DECLARED_INLINE_P (olddecl) else if (DECL_DECLARED_INLINE_P (olddecl)
&& DECL_UNINLINABLE (newdecl) && DECL_UNINLINABLE (newdecl)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
{ {
warning_with_decl (newdecl, warning ("%Hfunction '%D' redeclared with attribute noinline",
"function `%s' redeclared with attribute noinline"); &DECL_SOURCE_LOCATION (newdecl), newdecl);
warning_with_decl (olddecl, warning ("%Hprevious declaration of function '%D' was inline",
"previous declaration of function `%s' was inline"); &DECL_SOURCE_LOCATION (olddecl), olddecl);
} }
} }
...@@ -861,16 +867,19 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -861,16 +867,19 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
if (!TREE_PUBLIC (newdecl)) if (!TREE_PUBLIC (newdecl))
{ {
if (warn_shadow) if (warn_shadow)
warning_with_decl (newdecl, "shadowing built-in function `%s'"); warning ("%Hshadowing built-in function '%D'",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
} }
else else
warning_with_decl (newdecl, warning ("%Hbuilt-in function '%D' declared as non-function",
"built-in function `%s' declared as non-function"); &DECL_SOURCE_LOCATION (newdecl), newdecl);
} }
else else
{ {
error_with_decl (newdecl, "`%s' redeclared as different kind of symbol"); error ("%H'%D' redeclared as different kind of symbol",
error_with_decl (olddecl, "previous declaration of `%s'"); &DECL_SOURCE_LOCATION (newdecl), newdecl);
error ("%Hprevious declaration of '%D'",
&DECL_SOURCE_LOCATION (olddecl), olddecl);
} }
return 0; return 0;
...@@ -899,7 +908,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -899,7 +908,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
built-in definition is overridden, built-in definition is overridden,
but optionally warn this was a bad choice of name. */ but optionally warn this was a bad choice of name. */
if (warn_shadow) if (warn_shadow)
warning_with_decl (newdecl, "shadowing built-in function `%s'"); warning ("%Hshadowing built-in function '%D'",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
/* Discard the old built-in function. */ /* Discard the old built-in function. */
return 0; return 0;
} }
...@@ -968,7 +978,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -968,7 +978,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
if (!types_match) if (!types_match)
{ {
/* If types don't match for a built-in, throw away the built-in. */ /* If types don't match for a built-in, throw away the built-in. */
warning_with_decl (newdecl, "conflicting types for built-in function `%s'"); warning ("%Hconflicting types for built-in function '%D'",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
return 0; return 0;
} }
} }
...@@ -1011,7 +1022,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1011,7 +1022,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
&& TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node))) && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node)))
{ {
if (pedantic) if (pedantic)
pedwarn_with_decl (newdecl, "conflicting types for `%s'"); pedwarn ("%Hconflicting types for '%D'",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
/* Make sure we keep void * as ret type, not char *. */ /* Make sure we keep void * as ret type, not char *. */
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node) if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (oldtype))) == void_type_node)
TREE_TYPE (newdecl) = newtype = oldtype; TREE_TYPE (newdecl) = newtype = oldtype;
...@@ -1029,7 +1041,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1029,7 +1041,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
&& TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node
&& C_FUNCTION_IMPLICIT_INT (newdecl)) && C_FUNCTION_IMPLICIT_INT (newdecl))
{ {
pedwarn_with_decl (newdecl, "conflicting types for `%s'"); pedwarn ("%Hconflicting types for '%D'",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
/* Make sure we keep void as the return type. */ /* Make sure we keep void as the return type. */
TREE_TYPE (newdecl) = newtype = oldtype; TREE_TYPE (newdecl) = newtype = oldtype;
C_FUNCTION_IMPLICIT_INT (newdecl) = 0; C_FUNCTION_IMPLICIT_INT (newdecl) = 0;
...@@ -1044,7 +1057,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1044,7 +1057,8 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
TREE_TYPE (newtype), comptype_flags) TREE_TYPE (newtype), comptype_flags)
&& TYPE_ARG_TYPES (newtype) == 0)) && TYPE_ARG_TYPES (newtype) == 0))
{ {
error_with_decl (newdecl, "conflicting types for `%s'"); error ("%Hconflicting types for '%D'",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
/* Check for function type mismatch /* Check for function type mismatch
involving an empty arglist vs a nonempty one. */ involving an empty arglist vs a nonempty one. */
if (TREE_CODE (olddecl) == FUNCTION_DECL if (TREE_CODE (olddecl) == FUNCTION_DECL
...@@ -1079,9 +1093,11 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1079,9 +1093,11 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
} }
} }
if (C_DECL_IMPLICIT (olddecl)) if (C_DECL_IMPLICIT (olddecl))
error_with_decl (olddecl, "previous implicit declaration of `%s'"); error ("%Hprevious implicit declaration of '%D'",
&DECL_SOURCE_LOCATION (olddecl), olddecl);
else else
error_with_decl (olddecl, "previous declaration of `%s'"); error ("%Hprevious declaration of '%D'",
&DECL_SOURCE_LOCATION (olddecl), olddecl);
/* This is safer because the initializer might contain references /* This is safer because the initializer might contain references
to variables that were declared between olddecl and newdecl. This to variables that were declared between olddecl and newdecl. This
...@@ -1094,54 +1110,62 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1094,54 +1110,62 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
&& !DECL_THREAD_LOCAL (olddecl) && DECL_THREAD_LOCAL (newdecl)) && !DECL_THREAD_LOCAL (olddecl) && DECL_THREAD_LOCAL (newdecl))
{ {
error_with_decl (newdecl, "thread-local declaration of `%s' follows non thread-local declaration"); error ("%Hthread-local declaration of '%D' follows non thread-local "
error_with_decl (olddecl, "previous declaration of `%s'"); "declaration", &DECL_SOURCE_LOCATION (newdecl), newdecl);
error ("%Hprevious declaration of '%D'",
&DECL_SOURCE_LOCATION (olddecl), olddecl);
} }
/* non-TLS declaration cannot follow TLS declaration. */ /* non-TLS declaration cannot follow TLS declaration. */
else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL else if (TREE_CODE (olddecl) == VAR_DECL && TREE_CODE (newdecl) == VAR_DECL
&& DECL_THREAD_LOCAL (olddecl) && !DECL_THREAD_LOCAL (newdecl)) && DECL_THREAD_LOCAL (olddecl) && !DECL_THREAD_LOCAL (newdecl))
{ {
error_with_decl (newdecl, "non thread-local declaration of `%s' follows thread-local declaration"); error ("%Hnon thread-local declaration of '%D' follows "
error_with_decl (olddecl, "previous declaration of `%s'"); "thread-local declaration",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
error ("%Hprevious declaration of '%D'",
&DECL_SOURCE_LOCATION (olddecl), olddecl);
} }
else else
{ {
errmsg = redeclaration_error_message (newdecl, olddecl); errmsg = redeclaration_error_message (newdecl, olddecl);
if (errmsg) if (errmsg)
{ {
const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
switch (errmsg) switch (errmsg)
{ {
case 1: case 1:
error_with_decl (newdecl, "redefinition of `%s'"); error ("%Hredefinition of '%D'", locus, newdecl);
break; break;
case 2: case 2:
error_with_decl (newdecl, "redeclaration of `%s'"); error ("%Hredeclaration of '%D'", locus, newdecl);
break; break;
case 3: case 3:
error_with_decl (newdecl, "conflicting declarations of `%s'"); error ("%Hconflicting declarations of '%D'", locus, newdecl);
break; break;
default: default:
abort (); abort ();
} }
error_with_decl (olddecl, locus = &DECL_SOURCE_LOCATION (olddecl);
((DECL_INITIAL (olddecl) if (DECL_INITIAL (olddecl)
&& current_binding_level == global_binding_level) && current_binding_level == global_binding_level)
? "`%s' previously defined here" error ("%H'%D' previously defined here", locus, olddecl);
: "`%s' previously declared here")); else
error ("%H'%D' previously declared here", locus, olddecl);
return 0; return 0;
} }
else if (TREE_CODE (newdecl) == TYPE_DECL else if (TREE_CODE (newdecl) == TYPE_DECL
&& (DECL_IN_SYSTEM_HEADER (olddecl) && (DECL_IN_SYSTEM_HEADER (olddecl)
|| DECL_IN_SYSTEM_HEADER (newdecl))) || DECL_IN_SYSTEM_HEADER (newdecl)))
{ {
warning_with_decl (newdecl, "redefinition of `%s'"); const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
warning_with_decl warning ("%Hredefinition of '%D'", locus, newdecl);
(olddecl, locus = &DECL_SOURCE_LOCATION (olddecl);
((DECL_INITIAL (olddecl) if (DECL_INITIAL (olddecl)
&& current_binding_level == global_binding_level) && current_binding_level == global_binding_level)
? "`%s' previously defined here" warning ("%H'%D' previously defined here", locus, olddecl);
: "`%s' previously declared here")); else
warning ("%H'%D' previously declared here", locus, olddecl);
} }
else if (TREE_CODE (olddecl) == FUNCTION_DECL else if (TREE_CODE (olddecl) == FUNCTION_DECL
&& DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (olddecl) != 0
...@@ -1162,16 +1186,20 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1162,16 +1186,20 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node
&& TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node) && TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
{ {
warning_with_decl (newdecl, "prototype for `%s' follows"); const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
warning_with_decl (olddecl, "non-prototype definition here"); warning ("%Hprototype for '%D' follows", locus, newdecl);
locus = &DECL_SOURCE_LOCATION (olddecl);
warning ("%Hnon-prototype definition here", locus);
break; break;
} }
if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node if (TYPE_MAIN_VARIANT (TREE_VALUE (parm)) == void_type_node
|| TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node) || TYPE_MAIN_VARIANT (TREE_VALUE (type)) == void_type_node)
{ {
error_with_decl (newdecl, const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
"prototype for `%s' follows and number of arguments doesn't match"); error ("%Hprototype for '%D' follows and number of "
error_with_decl (olddecl, "non-prototype definition here"); "arguments doesn't match", locus, newdecl);
locus = &DECL_SOURCE_LOCATION (olddecl);
error ("%Hnon-prototype definition here", locus);
errmsg = 1; errmsg = 1;
break; break;
} }
...@@ -1180,10 +1208,11 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1180,10 +1208,11 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type), if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type),
comptype_flags)) comptype_flags))
{ {
error_with_decl (newdecl, const location_t *locus = &DECL_SOURCE_LOCATION (newdecl);
"prototype for `%s' follows and argument %d doesn't match", error ("%Hprototype for '%D' follows and argument %d "
nargs); "doesn't match", locus, newdecl, nargs);
error_with_decl (olddecl, "non-prototype definition here"); locus = &DECL_SOURCE_LOCATION (olddecl);
error ("%Hnon-prototype definition here", locus);
errmsg = 1; errmsg = 1;
break; break;
} }
...@@ -1198,21 +1227,22 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1198,21 +1227,22 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
&& ! DECL_DECLARED_INLINE_P (olddecl) && ! DECL_DECLARED_INLINE_P (olddecl)
&& DECL_DECLARED_INLINE_P (newdecl) && DECL_DECLARED_INLINE_P (newdecl)
&& TREE_USED (olddecl)) && TREE_USED (olddecl))
warning_with_decl (newdecl, warning ("%H'%D' declared inline after being called",
"`%s' declared inline after being called"); &DECL_SOURCE_LOCATION (newdecl), newdecl);
if (TREE_CODE (olddecl) == FUNCTION_DECL if (TREE_CODE (olddecl) == FUNCTION_DECL
&& ! DECL_DECLARED_INLINE_P (olddecl) && ! DECL_DECLARED_INLINE_P (olddecl)
&& DECL_DECLARED_INLINE_P (newdecl) && DECL_DECLARED_INLINE_P (newdecl)
&& DECL_INITIAL (olddecl) != 0) && DECL_INITIAL (olddecl) != 0)
warning_with_decl (newdecl, warning ("%H'%D' declared inline after its definition",
"`%s' declared inline after its definition"); &DECL_SOURCE_LOCATION (newdecl), newdecl);
/* If pedantic, warn when static declaration follows a non-static /* If pedantic, warn when static declaration follows a non-static
declaration. Otherwise, do so only for functions. */ declaration. Otherwise, do so only for functions. */
if ((pedantic || TREE_CODE (olddecl) == FUNCTION_DECL) if ((pedantic || TREE_CODE (olddecl) == FUNCTION_DECL)
&& TREE_PUBLIC (olddecl) && TREE_PUBLIC (olddecl)
&& !TREE_PUBLIC (newdecl)) && !TREE_PUBLIC (newdecl))
warning_with_decl (newdecl, "static declaration for `%s' follows non-static"); warning ("%Hstatic declaration for '%D' follows non-static",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
/* If warn_traditional, warn when a non-static function /* If warn_traditional, warn when a non-static function
declaration follows a static one. */ declaration follows a static one. */
...@@ -1220,21 +1250,24 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1220,21 +1250,24 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
&& TREE_CODE (olddecl) == FUNCTION_DECL && TREE_CODE (olddecl) == FUNCTION_DECL
&& !TREE_PUBLIC (olddecl) && !TREE_PUBLIC (olddecl)
&& TREE_PUBLIC (newdecl)) && TREE_PUBLIC (newdecl))
warning_with_decl (newdecl, "non-static declaration for `%s' follows static"); warning ("%Hnon-static declaration for '%D' follows static",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
/* Warn when const declaration follows a non-const /* Warn when const declaration follows a non-const
declaration, but not for functions. */ declaration, but not for functions. */
if (TREE_CODE (olddecl) != FUNCTION_DECL if (TREE_CODE (olddecl) != FUNCTION_DECL
&& !TREE_READONLY (olddecl) && !TREE_READONLY (olddecl)
&& TREE_READONLY (newdecl)) && TREE_READONLY (newdecl))
warning_with_decl (newdecl, "const declaration for `%s' follows non-const"); warning ("%Hconst declaration for '%D' follows non-const",
&DECL_SOURCE_LOCATION (newdecl), newdecl);
/* These bits are logically part of the type, for variables. /* These bits are logically part of the type, for variables.
But not for functions But not for functions
(where qualifiers are not valid ANSI anyway). */ (where qualifiers are not valid ANSI anyway). */
else if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL else if (pedantic && TREE_CODE (olddecl) != FUNCTION_DECL
&& (TREE_READONLY (newdecl) != TREE_READONLY (olddecl) && (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)
|| TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl))) || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)))
pedwarn_with_decl (newdecl, "type qualifiers for `%s' conflict with previous decl"); pedwarn ("%Htype qualifiers for '%D' conflict with previous "
"declaration", &DECL_SOURCE_LOCATION (newdecl), newdecl);
} }
} }
...@@ -1247,8 +1280,10 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level, ...@@ -1247,8 +1280,10 @@ duplicate_decls (tree newdecl, tree olddecl, int different_binding_level,
/* Don't warn about extern decl followed by (tentative) definition. */ /* Don't warn about extern decl followed by (tentative) definition. */
&& !(DECL_EXTERNAL (olddecl) && ! DECL_EXTERNAL (newdecl))) && !(DECL_EXTERNAL (olddecl) && ! DECL_EXTERNAL (newdecl)))
{ {
warning_with_decl (newdecl, "redundant redeclaration of `%s' in same scope"); warning ("%Hredundant redeclaration of '%D' in same scope",
warning_with_decl (olddecl, "previous declaration of `%s'"); &DECL_SOURCE_LOCATION (newdecl), newdecl);
warning ("%Hprevious declaration of '%D'",
&DECL_SOURCE_LOCATION (olddecl), olddecl);
} }
/* Copy all the DECL_... slots specified in the new decl /* Copy all the DECL_... slots specified in the new decl
...@@ -1875,7 +1910,8 @@ implicitly_declare (tree functionid) ...@@ -1875,7 +1910,8 @@ implicitly_declare (tree functionid)
{ {
implicit_decl_warning (DECL_NAME (decl)); implicit_decl_warning (DECL_NAME (decl));
if (! C_DECL_FILE_SCOPE (decl)) if (! C_DECL_FILE_SCOPE (decl))
warning_with_decl (decl, "previous declaration of `%s'"); warning ("%Hprevious declaration of '%D'",
&DECL_SOURCE_LOCATION (decl), decl);
C_DECL_IMPLICIT (decl) = 1; C_DECL_IMPLICIT (decl) = 1;
} }
/* If this function is global, then it must already be in the /* If this function is global, then it must already be in the
...@@ -2083,10 +2119,9 @@ shadow_label (tree name) ...@@ -2083,10 +2119,9 @@ shadow_label (tree name)
for (dup = named_labels; dup; dup = TREE_CHAIN (dup)) for (dup = named_labels; dup; dup = TREE_CHAIN (dup))
if (TREE_VALUE (dup) == decl) if (TREE_VALUE (dup) == decl)
{ {
error ("duplicate label declaration `%s'", error ("duplicate label declaration '%E'", name);
IDENTIFIER_POINTER (name)); error ("%Hthis is a previous declaration",
error_with_decl (TREE_VALUE (dup), &DECL_SOURCE_LOCATION (TREE_VALUE (dup)));
"this is a previous declaration");
/* Just use the previous declaration. */ /* Just use the previous declaration. */
return lookup_label (name); return lookup_label (name);
} }
...@@ -2620,7 +2655,8 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes) ...@@ -2620,7 +2655,8 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes)
if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL
&& MAIN_NAME_P (DECL_NAME (decl))) && MAIN_NAME_P (DECL_NAME (decl)))
warning_with_decl (decl, "`%s' is usually a function"); warning ("%H'%D' is usually a function",
&DECL_SOURCE_LOCATION (decl), decl);
if (initialized) if (initialized)
/* Is it valid for this decl to have an initializer at all? /* Is it valid for this decl to have an initializer at all?
...@@ -2727,8 +2763,8 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes) ...@@ -2727,8 +2763,8 @@ start_decl (tree declarator, tree declspecs, int initialized, tree attributes)
&& DECL_DECLARED_INLINE_P (decl) && DECL_DECLARED_INLINE_P (decl)
&& DECL_UNINLINABLE (decl) && DECL_UNINLINABLE (decl)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
warning_with_decl (decl, warning ("%Hinline function '%D' given attribute noinline",
"inline function `%s' given attribute noinline"); &DECL_SOURCE_LOCATION (decl), decl);
/* Add this decl to the current binding level. /* Add this decl to the current binding level.
TEM may equal DECL or it may be a previous decl of the same name. */ TEM may equal DECL or it may be a previous decl of the same name. */
...@@ -2800,12 +2836,14 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2800,12 +2836,14 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
type = TREE_TYPE (decl); type = TREE_TYPE (decl);
if (failure == 1) if (failure == 1)
error_with_decl (decl, "initializer fails to determine size of `%s'"); error ("%Hinitializer fails to determine size of '%D'",
&DECL_SOURCE_LOCATION (decl), decl);
else if (failure == 2) else if (failure == 2)
{ {
if (do_default) if (do_default)
error_with_decl (decl, "array size missing in `%s'"); error ("%Harray size missing in '%D'",
&DECL_SOURCE_LOCATION (decl), decl);
/* If a `static' var's size isn't known, /* If a `static' var's size isn't known,
make it extern as well as static, so it does not get make it extern as well as static, so it does not get
allocated. allocated.
...@@ -2821,7 +2859,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2821,7 +2859,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
warn only if the value is less than zero. */ warn only if the value is less than zero. */
else if (pedantic && TYPE_DOMAIN (type) != 0 else if (pedantic && TYPE_DOMAIN (type) != 0
&& tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) < 0) && tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) < 0)
error_with_decl (decl, "zero or negative size array `%s'"); error ("%Hzero or negative size array '%D'",
&DECL_SOURCE_LOCATION (decl), decl);
layout_decl (decl, 0); layout_decl (decl, 0);
} }
...@@ -2849,7 +2888,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2849,7 +2888,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
is an error. */ is an error. */
!DECL_EXTERNAL (decl))) !DECL_EXTERNAL (decl)))
{ {
error_with_decl (decl, "storage size of `%s' isn't known"); error ("%Hstorage size of '%D' isn't known",
&DECL_SOURCE_LOCATION (decl), decl);
TREE_TYPE (decl) = error_mark_node; TREE_TYPE (decl) = error_mark_node;
} }
...@@ -2859,7 +2899,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2859,7 +2899,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST) if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
constant_expression_warning (DECL_SIZE (decl)); constant_expression_warning (DECL_SIZE (decl));
else else
error_with_decl (decl, "storage size of `%s' isn't constant"); error ("%Hstorage size of '%D' isn't constant",
&DECL_SOURCE_LOCATION (decl), decl);
} }
if (TREE_USED (type)) if (TREE_USED (type))
...@@ -2938,8 +2979,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree) ...@@ -2938,8 +2979,8 @@ finish_decl (tree decl, tree init, tree asmspec_tree)
if (TREE_CODE (decl) == VAR_DECL if (TREE_CODE (decl) == VAR_DECL
&& !DECL_REGISTER (decl) && !DECL_REGISTER (decl)
&& !TREE_STATIC (decl)) && !TREE_STATIC (decl))
warning_with_decl (decl, warning ("%Hignoring asm-specifier for non-static local "
"ignoring asm-specifier for non-static local variable `%s'"); "variable '%D'", &DECL_SOURCE_LOCATION (decl), decl);
else else
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec)); SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
} }
...@@ -4426,7 +4467,8 @@ grokdeclarator (tree declarator, tree declspecs, ...@@ -4426,7 +4467,8 @@ grokdeclarator (tree declarator, tree declspecs,
C_DECL_VARIABLE_SIZE (decl) = 1; C_DECL_VARIABLE_SIZE (decl) = 1;
if (inlinep) if (inlinep)
pedwarn_with_decl (decl, "variable `%s' declared `inline'"); pedwarn ("%Hvariable '%D' declared `inline'",
&DECL_SOURCE_LOCATION (decl), decl);
DECL_EXTERNAL (decl) = extern_ref; DECL_EXTERNAL (decl) = extern_ref;
...@@ -4609,8 +4651,8 @@ get_parm_info (int void_at_end) ...@@ -4609,8 +4651,8 @@ get_parm_info (int void_at_end)
} }
else if (TREE_ASM_WRITTEN (decl)) else if (TREE_ASM_WRITTEN (decl))
{ {
error_with_decl (decl, error ("%Hparameter '%D' has just a forward declaration",
"parameter `%s' has just a forward declaration"); &DECL_SOURCE_LOCATION (decl), decl);
TREE_CHAIN (decl) = new_parms; TREE_CHAIN (decl) = new_parms;
new_parms = decl; new_parms = decl;
} }
...@@ -4892,7 +4934,8 @@ detect_field_duplicates (tree fieldlist) ...@@ -4892,7 +4934,8 @@ detect_field_duplicates (tree fieldlist)
for (y = fieldlist; y != x; y = TREE_CHAIN (y)) for (y = fieldlist; y != x; y = TREE_CHAIN (y))
if (DECL_NAME (y) == DECL_NAME (x)) if (DECL_NAME (y) == DECL_NAME (x))
{ {
error_with_decl (x, "duplicate member `%s'"); error ("%Hduplicate member '%D'",
&DECL_SOURCE_LOCATION (x), x);
DECL_NAME (x) = NULL_TREE; DECL_NAME (x) = NULL_TREE;
} }
} }
...@@ -4908,7 +4951,8 @@ detect_field_duplicates (tree fieldlist) ...@@ -4908,7 +4951,8 @@ detect_field_duplicates (tree fieldlist)
slot = htab_find_slot (htab, y, INSERT); slot = htab_find_slot (htab, y, INSERT);
if (*slot) if (*slot)
{ {
error_with_decl (x, "duplicate member `%s'"); error ("%Hduplicate member '%D'",
&DECL_SOURCE_LOCATION (x), x);
DECL_NAME (x) = NULL_TREE; DECL_NAME (x) = NULL_TREE;
} }
*slot = y; *slot = y;
...@@ -5009,8 +5053,8 @@ finish_struct (tree t, tree fieldlist, tree attributes) ...@@ -5009,8 +5053,8 @@ finish_struct (tree t, tree fieldlist, tree attributes)
constant_expression_warning (DECL_INITIAL (x)); constant_expression_warning (DECL_INITIAL (x));
else else
{ {
error_with_decl (x, error ("%Hbit-field '%D' width not an integer constant",
"bit-field `%s' width not an integer constant"); &DECL_SOURCE_LOCATION (x), x);
DECL_INITIAL (x) = NULL; DECL_INITIAL (x) = NULL;
} }
} }
...@@ -5021,7 +5065,8 @@ finish_struct (tree t, tree fieldlist, tree attributes) ...@@ -5021,7 +5065,8 @@ finish_struct (tree t, tree fieldlist, tree attributes)
&& TREE_CODE (TREE_TYPE (x)) != BOOLEAN_TYPE && TREE_CODE (TREE_TYPE (x)) != BOOLEAN_TYPE
&& TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE) && TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE)
{ {
error_with_decl (x, "bit-field `%s' has invalid type"); error ("%Hbit-field '%D' has invalid type",
&DECL_SOURCE_LOCATION (x), x);
DECL_INITIAL (x) = NULL; DECL_INITIAL (x) = NULL;
} }
...@@ -5033,7 +5078,8 @@ finish_struct (tree t, tree fieldlist, tree attributes) ...@@ -5033,7 +5078,8 @@ finish_struct (tree t, tree fieldlist, tree attributes)
&& !(TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE && !(TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE
&& (TYPE_PRECISION (TREE_TYPE (x)) && (TYPE_PRECISION (TREE_TYPE (x))
== TYPE_PRECISION (integer_type_node)))) == TYPE_PRECISION (integer_type_node))))
pedwarn_with_decl (x, "bit-field `%s' type invalid in ISO C"); pedwarn ("%Hbit-field '%D' type invalid in ISO C",
&DECL_SOURCE_LOCATION (x), x);
/* Detect and ignore out of range field width and process valid /* Detect and ignore out of range field width and process valid
field widths. */ field widths. */
...@@ -5044,11 +5090,14 @@ finish_struct (tree t, tree fieldlist, tree attributes) ...@@ -5044,11 +5090,14 @@ finish_struct (tree t, tree fieldlist, tree attributes)
? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x))); ? CHAR_TYPE_SIZE : TYPE_PRECISION (TREE_TYPE (x)));
if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0) if (tree_int_cst_sgn (DECL_INITIAL (x)) < 0)
error_with_decl (x, "negative width in bit-field `%s'"); error ("%Hnegative width in bit-field '%D'",
&DECL_SOURCE_LOCATION (x), x);
else if (0 < compare_tree_int (DECL_INITIAL (x), max_width)) else if (0 < compare_tree_int (DECL_INITIAL (x), max_width))
pedwarn_with_decl (x, "width of `%s' exceeds its type"); pedwarn ("%Hwidth of '%D' exceeds its type",
&DECL_SOURCE_LOCATION (x), x);
else if (integer_zerop (DECL_INITIAL (x)) && DECL_NAME (x) != 0) else if (integer_zerop (DECL_INITIAL (x)) && DECL_NAME (x) != 0)
error_with_decl (x, "zero width for bit-field `%s'"); error ("%Hzero width for bit-field '%D'",
&DECL_SOURCE_LOCATION (x), x);
else else
{ {
/* The test above has assured us that TREE_INT_CST_HIGH is 0. */ /* The test above has assured us that TREE_INT_CST_HIGH is 0. */
...@@ -5061,8 +5110,8 @@ finish_struct (tree t, tree fieldlist, tree attributes) ...@@ -5061,8 +5110,8 @@ finish_struct (tree t, tree fieldlist, tree attributes)
|| (width || (width
< min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)), < min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)),
TREE_UNSIGNED (TREE_TYPE (x)))))) TREE_UNSIGNED (TREE_TYPE (x))))))
warning_with_decl (x, warning ("%H'%D' is narrower than values of its type",
"`%s' is narrower than values of its type"); &DECL_SOURCE_LOCATION (x), x);
DECL_SIZE (x) = bitsize_int (width); DECL_SIZE (x) = bitsize_int (width);
DECL_BIT_FIELD (x) = 1; DECL_BIT_FIELD (x) = 1;
...@@ -5079,16 +5128,20 @@ finish_struct (tree t, tree fieldlist, tree attributes) ...@@ -5079,16 +5128,20 @@ finish_struct (tree t, tree fieldlist, tree attributes)
&& TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE) && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
{ {
if (TREE_CODE (t) == UNION_TYPE) if (TREE_CODE (t) == UNION_TYPE)
error_with_decl (x, "flexible array member in union"); error ("%Hflexible array member in union",
&DECL_SOURCE_LOCATION (x));
else if (TREE_CHAIN (x) != NULL_TREE) else if (TREE_CHAIN (x) != NULL_TREE)
error_with_decl (x, "flexible array member not at end of struct"); error ("%Hflexible array member not at end of struct",
&DECL_SOURCE_LOCATION (x));
else if (! saw_named_field) else if (! saw_named_field)
error_with_decl (x, "flexible array member in otherwise empty struct"); error ("%Hflexible array member in otherwise empty struct",
&DECL_SOURCE_LOCATION (x));
} }
if (pedantic && TREE_CODE (t) == RECORD_TYPE if (pedantic && TREE_CODE (t) == RECORD_TYPE
&& flexible_array_type_p (TREE_TYPE (x))) && flexible_array_type_p (TREE_TYPE (x)))
pedwarn_with_decl (x, "invalid use of structure with flexible array member"); pedwarn ("%Hinvalid use of structure with flexible array member",
&DECL_SOURCE_LOCATION (x));
if (DECL_NAME (x)) if (DECL_NAME (x))
saw_named_field = 1; saw_named_field = 1;
...@@ -5545,8 +5598,8 @@ start_function (tree declspecs, tree declarator, tree attributes) ...@@ -5545,8 +5598,8 @@ start_function (tree declspecs, tree declarator, tree attributes)
if (DECL_DECLARED_INLINE_P (decl1) if (DECL_DECLARED_INLINE_P (decl1)
&& DECL_UNINLINABLE (decl1) && DECL_UNINLINABLE (decl1)
&& lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1))) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
warning_with_decl (decl1, warning ("%Hinline function '%D' given attribute noinline",
"inline function `%s' given attribute noinline"); &DECL_SOURCE_LOCATION (decl1), decl1);
announce_function (decl1); announce_function (decl1);
...@@ -5595,27 +5648,29 @@ start_function (tree declspecs, tree declarator, tree attributes) ...@@ -5595,27 +5648,29 @@ start_function (tree declspecs, tree declarator, tree attributes)
&& TREE_PUBLIC (decl1) && TREE_PUBLIC (decl1)
&& ! MAIN_NAME_P (DECL_NAME (decl1)) && ! MAIN_NAME_P (DECL_NAME (decl1))
&& C_DECL_ISNT_PROTOTYPE (old_decl)) && C_DECL_ISNT_PROTOTYPE (old_decl))
warning_with_decl (decl1, "no previous prototype for `%s'"); warning ("%Hno previous prototype for '%D'",
&DECL_SOURCE_LOCATION (decl1), decl1);
/* Optionally warn of any def with no previous prototype /* Optionally warn of any def with no previous prototype
if the function has already been used. */ if the function has already been used. */
else if (warn_missing_prototypes else if (warn_missing_prototypes
&& old_decl != 0 && TREE_USED (old_decl) && old_decl != 0 && TREE_USED (old_decl)
&& TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0) && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) == 0)
warning_with_decl (decl1, warning ("%H'%D' was used with no prototype before its definition",
"`%s' was used with no prototype before its definition"); &DECL_SOURCE_LOCATION (decl1), decl1);
/* Optionally warn of any global def with no previous declaration. */ /* Optionally warn of any global def with no previous declaration. */
else if (warn_missing_declarations else if (warn_missing_declarations
&& TREE_PUBLIC (decl1) && TREE_PUBLIC (decl1)
&& old_decl == 0 && old_decl == 0
&& ! MAIN_NAME_P (DECL_NAME (decl1))) && ! MAIN_NAME_P (DECL_NAME (decl1)))
warning_with_decl (decl1, "no previous declaration for `%s'"); warning ("%Hno previous declaration for '%D'",
&DECL_SOURCE_LOCATION (decl1), decl1);
/* Optionally warn of any def with no previous declaration /* Optionally warn of any def with no previous declaration
if the function has already been used. */ if the function has already been used. */
else if (warn_missing_declarations else if (warn_missing_declarations
&& old_decl != 0 && TREE_USED (old_decl) && old_decl != 0 && TREE_USED (old_decl)
&& C_DECL_IMPLICIT (old_decl)) && C_DECL_IMPLICIT (old_decl))
warning_with_decl (decl1, warning ("%H`%D' was used with no declaration before its definition",
"`%s' was used with no declaration before its definition"); &DECL_SOURCE_LOCATION (decl1), decl1);
/* This is a definition, not a reference. /* This is a definition, not a reference.
So normally clear DECL_EXTERNAL. So normally clear DECL_EXTERNAL.
...@@ -5636,10 +5691,11 @@ start_function (tree declspecs, tree declarator, tree attributes) ...@@ -5636,10 +5691,11 @@ start_function (tree declspecs, tree declarator, tree attributes)
{ {
tree args; tree args;
int argct = 0; int argct = 0;
const location_t *locus = &DECL_SOURCE_LOCATION (decl1);
if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1))) if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
!= integer_type_node) != integer_type_node)
pedwarn_with_decl (decl1, "return type of `%s' is not `int'"); pedwarn ("%Hreturn type of '%D' is not `int'", locus, decl1);
for (args = TYPE_ARG_TYPES (TREE_TYPE (decl1)); args; for (args = TYPE_ARG_TYPES (TREE_TYPE (decl1)); args;
args = TREE_CHAIN (args)) args = TREE_CHAIN (args))
...@@ -5654,8 +5710,8 @@ start_function (tree declspecs, tree declarator, tree attributes) ...@@ -5654,8 +5710,8 @@ start_function (tree declspecs, tree declarator, tree attributes)
{ {
case 1: case 1:
if (TYPE_MAIN_VARIANT (type) != integer_type_node) if (TYPE_MAIN_VARIANT (type) != integer_type_node)
pedwarn_with_decl (decl1, pedwarn ("%Hfirst argument of '%D' should be `int'",
"first argument of `%s' should be `int'"); locus, decl1);
break; break;
case 2: case 2:
...@@ -5663,8 +5719,8 @@ start_function (tree declspecs, tree declarator, tree attributes) ...@@ -5663,8 +5719,8 @@ start_function (tree declspecs, tree declarator, tree attributes)
|| TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE || TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
|| (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))) || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type)))
!= char_type_node)) != char_type_node))
pedwarn_with_decl (decl1, pedwarn ("%Hsecond argument of '%D' should be 'char **'",
"second argument of `%s' should be `char **'"); locus, decl1);
break; break;
case 3: case 3:
...@@ -5672,8 +5728,8 @@ start_function (tree declspecs, tree declarator, tree attributes) ...@@ -5672,8 +5728,8 @@ start_function (tree declspecs, tree declarator, tree attributes)
|| TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE || TREE_CODE (TREE_TYPE (type)) != POINTER_TYPE
|| (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))) || (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type)))
!= char_type_node)) != char_type_node))
pedwarn_with_decl (decl1, pedwarn ("%Hthird argument of '%D' should probably be "
"third argument of `%s' should probably be `char **'"); "'char **'", locus, decl1);
break; break;
} }
} }
...@@ -5682,10 +5738,10 @@ start_function (tree declspecs, tree declarator, tree attributes) ...@@ -5682,10 +5738,10 @@ start_function (tree declspecs, tree declarator, tree attributes)
argument because it's only mentioned in an appendix of the argument because it's only mentioned in an appendix of the
standard. */ standard. */
if (argct > 0 && (argct < 2 || argct > 3)) if (argct > 0 && (argct < 2 || argct > 3))
pedwarn_with_decl (decl1, "`%s' takes only zero or two arguments"); pedwarn ("%H'%D' takes only zero or two arguments", locus, decl1);
if (! TREE_PUBLIC (decl1)) if (! TREE_PUBLIC (decl1))
pedwarn_with_decl (decl1, "`%s' is normally a non-static function"); pedwarn ("%H'%D' is normally a non-static function", locus, decl1);
} }
/* Record the decl so that the function name is defined. /* Record the decl so that the function name is defined.
...@@ -5781,8 +5837,8 @@ store_parm_decls (void) ...@@ -5781,8 +5837,8 @@ store_parm_decls (void)
{ {
tree decl, link; tree decl, link;
error_with_decl (fndecl, error ("%Hparm types given both in parmlist and separately",
"parm types given both in parmlist and separately"); &DECL_SOURCE_LOCATION (fndecl));
/* Get rid of the erroneous decls; don't keep them on /* Get rid of the erroneous decls; don't keep them on
the list of parms, since they might not be PARM_DECLs. */ the list of parms, since they might not be PARM_DECLs. */
for (decl = current_binding_level->names; for (decl = current_binding_level->names;
...@@ -5799,15 +5855,16 @@ store_parm_decls (void) ...@@ -5799,15 +5855,16 @@ store_parm_decls (void)
specparms = nreverse (specparms); specparms = nreverse (specparms);
for (parm = specparms; parm; parm = next) for (parm = specparms; parm; parm = next)
{ {
const location_t *locus = &DECL_SOURCE_LOCATION (parm);
next = TREE_CHAIN (parm); next = TREE_CHAIN (parm);
if (TREE_CODE (parm) == PARM_DECL) if (TREE_CODE (parm) == PARM_DECL)
{ {
if (DECL_NAME (parm) == 0) if (DECL_NAME (parm) == 0)
error_with_decl (parm, "parameter name omitted"); error ("%Hparameter name omitted", locus);
else if (TREE_CODE (TREE_TYPE (parm)) != ERROR_MARK else if (TREE_CODE (TREE_TYPE (parm)) != ERROR_MARK
&& VOID_TYPE_P (TREE_TYPE (parm))) && VOID_TYPE_P (TREE_TYPE (parm)))
{ {
error_with_decl (parm, "parameter `%s' declared void"); error ("%Hparameter '%D' declared void", locus, parm);
/* Change the type to error_mark_node so this parameter /* Change the type to error_mark_node so this parameter
will be ignored by assign_parms. */ will be ignored by assign_parms. */
TREE_TYPE (parm) = error_mark_node; TREE_TYPE (parm) = error_mark_node;
...@@ -5866,8 +5923,8 @@ store_parm_decls (void) ...@@ -5866,8 +5923,8 @@ store_parm_decls (void)
if (TREE_VALUE (parm) == 0) if (TREE_VALUE (parm) == 0)
{ {
error_with_decl (fndecl, error ("%Hparameter name missing from parameter list",
"parameter name missing from parameter list"); &DECL_SOURCE_LOCATION (fndecl));
TREE_PURPOSE (parm) = 0; TREE_PURPOSE (parm) = 0;
continue; continue;
} }
...@@ -5886,14 +5943,16 @@ store_parm_decls (void) ...@@ -5886,14 +5943,16 @@ store_parm_decls (void)
Complain, and don't use this decl twice. */ Complain, and don't use this decl twice. */
if (found && DECL_WEAK (found)) if (found && DECL_WEAK (found))
{ {
error_with_decl (found, "multiple parameters named `%s'"); error ("%Hmultiple parameters named '%D'",
&DECL_SOURCE_LOCATION (found), found);
found = 0; found = 0;
} }
/* If the declaration says "void", complain and ignore it. */ /* If the declaration says "void", complain and ignore it. */
if (found && VOID_TYPE_P (TREE_TYPE (found))) if (found && VOID_TYPE_P (TREE_TYPE (found)))
{ {
error_with_decl (found, "parameter `%s' declared void"); error ("%Hparameter '%D' declared void",
&DECL_SOURCE_LOCATION (found), found);
TREE_TYPE (found) = integer_type_node; TREE_TYPE (found) = integer_type_node;
DECL_ARG_TYPE (found) = integer_type_node; DECL_ARG_TYPE (found) = integer_type_node;
layout_decl (found, 0); layout_decl (found, 0);
...@@ -5907,9 +5966,11 @@ store_parm_decls (void) ...@@ -5907,9 +5966,11 @@ store_parm_decls (void)
DECL_ARG_TYPE (found) = TREE_TYPE (found); DECL_ARG_TYPE (found) = TREE_TYPE (found);
DECL_SOURCE_LOCATION (found) = DECL_SOURCE_LOCATION (fndecl); DECL_SOURCE_LOCATION (found) = DECL_SOURCE_LOCATION (fndecl);
if (flag_isoc99) if (flag_isoc99)
pedwarn_with_decl (found, "type of `%s' defaults to `int'"); pedwarn ("%Htype of '%D' defaults to `int'",
&DECL_SOURCE_LOCATION (found), found);
else if (extra_warnings) else if (extra_warnings)
warning_with_decl (found, "type of `%s' defaults to `int'"); warning ("%Htype of '%D' defaults to `int'",
&DECL_SOURCE_LOCATION (found), found);
pushdecl (found); pushdecl (found);
} }
...@@ -5928,6 +5989,7 @@ store_parm_decls (void) ...@@ -5928,6 +5989,7 @@ store_parm_decls (void)
nonparms = 0; nonparms = 0;
for (parm = parmdecls; parm;) for (parm = parmdecls; parm;)
{ {
const location_t *locus = &DECL_SOURCE_LOCATION (parm);
tree next = TREE_CHAIN (parm); tree next = TREE_CHAIN (parm);
TREE_CHAIN (parm) = 0; TREE_CHAIN (parm) = 0;
...@@ -5938,14 +6000,14 @@ store_parm_decls (void) ...@@ -5938,14 +6000,14 @@ store_parm_decls (void)
/* Complain about args with incomplete types. */ /* Complain about args with incomplete types. */
if (!COMPLETE_TYPE_P (TREE_TYPE (parm))) if (!COMPLETE_TYPE_P (TREE_TYPE (parm)))
{ {
error_with_decl (parm, "parameter `%s' has incomplete type"); error ("%Hparameter '%D' has incomplete type", locus, parm);
TREE_TYPE (parm) = error_mark_node; TREE_TYPE (parm) = error_mark_node;
} }
if (! DECL_WEAK (parm)) if (! DECL_WEAK (parm))
{ {
error_with_decl (parm, error ("%Hdeclaration for parameter '%D' but no such "
"declaration for parameter `%s' but no such parameter"); "parameter", locus, parm);
/* Pretend the parameter was not missing. /* Pretend the parameter was not missing.
This gets us to a standard state and minimizes This gets us to a standard state and minimizes
further error messages. */ further error messages. */
...@@ -6170,8 +6232,9 @@ finish_function (int nested, int can_defer_p) ...@@ -6170,8 +6232,9 @@ finish_function (int nested, int can_defer_p)
{ {
/* If warn_main is 1 (-Wmain) or 2 (-Wall), we have already warned. /* If warn_main is 1 (-Wmain) or 2 (-Wall), we have already warned.
If warn_main is -1 (-Wno-main) we don't want to be warned. */ If warn_main is -1 (-Wno-main) we don't want to be warned. */
if (! warn_main) if (!warn_main)
pedwarn_with_decl (fndecl, "return type of `%s' is not `int'"); pedwarn ("%Hreturn type of '%D' is not `int'",
&DECL_SOURCE_LOCATION (fndecl), fndecl);
} }
else else
{ {
...@@ -6422,17 +6485,16 @@ c_expand_body_1 (tree fndecl, int nested_p) ...@@ -6422,17 +6485,16 @@ c_expand_body_1 (tree fndecl, int nested_p)
&& 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type), && 0 < compare_tree_int (TYPE_SIZE_UNIT (ret_type),
larger_than_size)) larger_than_size))
{ {
const location_t *locus = &DECL_SOURCE_LOCATION (fndecl);
unsigned int size_as_int unsigned int size_as_int
= TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type)); = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (ret_type));
if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0) if (compare_tree_int (TYPE_SIZE_UNIT (ret_type), size_as_int) == 0)
warning_with_decl (fndecl, warning ("%Hsize of return value of '%D' is %u bytes",
"size of return value of `%s' is %u bytes", locus, fndecl, size_as_int);
size_as_int);
else else
warning_with_decl (fndecl, warning ("%Hsize of return value of '%D' is larger than %wd bytes",
"size of return value of `%s' is larger than %d bytes", locus, fndecl, larger_than_size);
larger_than_size);
} }
} }
...@@ -6531,12 +6593,16 @@ check_for_loop_decls (void) ...@@ -6531,12 +6593,16 @@ check_for_loop_decls (void)
for (t = getdecls (); t; t = TREE_CHAIN (t)) for (t = getdecls (); t; t = TREE_CHAIN (t))
{ {
const location_t *locus = &DECL_SOURCE_LOCATION (t);
if (TREE_CODE (t) != VAR_DECL && DECL_NAME (t)) if (TREE_CODE (t) != VAR_DECL && DECL_NAME (t))
error_with_decl (t, "declaration of non-variable `%s' in `for' loop initial declaration"); error ("%Hdeclaration of non-variable '%D' in 'for' loop "
"initial declaration", locus, t);
else if (TREE_STATIC (t)) else if (TREE_STATIC (t))
error_with_decl (t, "declaration of static variable `%s' in `for' loop initial declaration"); error ("%Hdeclaration of static variable '%D' in 'for' loop "
"initial declaration", locus, t);
else if (DECL_EXTERNAL (t)) else if (DECL_EXTERNAL (t))
error_with_decl (t, "declaration of `extern' variable `%s' in `for' loop initial declaration"); error ("%Hdeclaration of 'extern' variable '%D' in 'for' loop "
"initial declaration", locus, t);
} }
} }
...@@ -6860,8 +6926,10 @@ merge_translation_unit_decls (void) ...@@ -6860,8 +6926,10 @@ merge_translation_unit_decls (void)
} }
else else
{ {
error_with_decl (decl, "redefinition of global `%s'"); error ("%Hredefinition of global '%D'",
error_with_decl (old_decl, "`%s' previously defined here"); &DECL_SOURCE_LOCATION (decl), decl);
error ("%H'%D' previously defined here",
&DECL_SOURCE_LOCATION (old_decl), old_decl);
} }
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment