This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[diagnostics] kill %J specifier


The following patch removes all uses of %J. A follow-up patch will
remove %J itself.

Bootstrapped and regression tested x86_64-unknown-linux-gnu.

OK for trunk?

2009-07-07  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* cgraphunit.c: Replace %J by an explicit location. Update all
	calls.
	* c-decl.c: Likewise.
	* function.c: Likewise.
	* varasm.c: Likewise.
	* tree-ssa.c: Likewise.
	* c-common.c: Likewise.
	* tree-cfg.c: Likewise.
	* config/spu/spu.c: Likewise.
	* config/ia64/ia64.c: Likewise.
	* config/v850/v850.c: Likewise.
java/	
	* class.c: Replace %J by an explicit location. Update all calls.
objc/	
	* objc-act.c: Replace %J by an explicit location. Update all
	calls.
cp/
	* init.c: Replace %J by an explicit location. Update all calls.
	* decl.c: Likewise.
	* typeck2.c: Likewise.
	* pt.c: Likewise.
	* name-lookup.c: Likewise.
Index: gcc/java/class.c
===================================================================
--- gcc/java/class.c	(revision 149310)
+++ gcc/java/class.c	(working copy)
@@ -1607,11 +1607,12 @@ get_dispatch_table (tree type, tree this
     {
       tree method = TREE_VEC_ELT (vtable, i);
       if (METHOD_ABSTRACT (method))
 	{
 	  if (! abstract_p)
-	    warning (0, "%Jabstract method in non-abstract class", method);
+	    warning_at (DECL_SOURCE_LOCATION (method), 0,
+			"abstract method in non-abstract class");
 
 	  if (TARGET_VTABLE_USES_DESCRIPTORS)
 	    for (j = 0; j < TARGET_VTABLE_USES_DESCRIPTORS; ++j)
 	      list = tree_cons (NULL_TREE, null_pointer_node, list);
 	  else
Index: gcc/objc/objc-act.c
===================================================================
--- gcc/objc/objc-act.c	(revision 149310)
+++ gcc/objc/objc-act.c	(working copy)
@@ -5013,12 +5013,12 @@ synth_forward_declarations (void)
 }
 
 static void
 error_with_ivar (const char *message, tree decl)
 {
-  error ("%J%s %qs", decl,
-         message, identifier_to_locale (gen_declaration (decl)));
+  error_at (DECL_SOURCE_LOCATION (decl), "%s %qs",
+	    message, identifier_to_locale (gen_declaration (decl)));
 
 }
 
 static void
 check_ivars (tree inter, tree imp)
@@ -6148,34 +6148,36 @@ check_duplicates (hash hsh, int methods,
 	issue_warning:
 	  if (methods)
 	    {
 	      bool type = TREE_CODE (meth) == INSTANCE_METHOD_DECL;
 
-	      warning (0, "multiple methods named %<%c%E%> found",
-		       (is_class ? '+' : '-'),
-		       METHOD_SEL_NAME (meth));
-	      inform (0, "%Jusing %<%c%s%>", meth,
+	      warning_at (input_location, 0,
+			  "multiple methods named %<%c%E%> found",
+			  (is_class ? '+' : '-'),
+			  METHOD_SEL_NAME (meth));
+	      inform (DECL_SOURCE_LOCATION (meth), "using %<%c%s%>",
 		      (type ? '-' : '+'),
 		      identifier_to_locale (gen_method_decl (meth)));
 	    }
 	  else
 	    {
 	      bool type = TREE_CODE (meth) == INSTANCE_METHOD_DECL;
 
-	      warning (0, "multiple selectors named %<%c%E%> found",
-		       (is_class ? '+' : '-'),
-		       METHOD_SEL_NAME (meth));
-	      inform (0, "%Jfound %<%c%s%>", meth,
+	      warning_at (input_location, 0,
+			  "multiple selectors named %<%c%E%> found",
+			  (is_class ? '+' : '-'),
+			  METHOD_SEL_NAME (meth));
+	      inform (DECL_SOURCE_LOCATION (meth), "found %<%c%s%>",
 		      (type ? '-' : '+'),
 		      identifier_to_locale (gen_method_decl (meth)));
 	    }
 
 	  for (loop = hsh->list; loop; loop = loop->next)
 	    {
 	      bool type = TREE_CODE (loop->value) == INSTANCE_METHOD_DECL;
 
-	      inform (0, "%Jalso found %<%c%s%>", loop->value, 
+	      inform (DECL_SOURCE_LOCATION (loop->value), "also found %<%c%s%>",
 		      (type ? '-' : '+'),
 		      identifier_to_locale (gen_method_decl (loop->value)));
 	    }
         }
     }
@@ -8731,14 +8733,16 @@ really_start_method (tree method,
 	{
 	  if (!comp_proto_with_proto (method, proto, 1))
 	    {
 	      bool type = TREE_CODE (method) == INSTANCE_METHOD_DECL;
 
-	      warning (0, "%Jconflicting types for %<%c%s%>", method,
-		       (type ? '-' : '+'),
-		       identifier_to_locale (gen_method_decl (method)));
-	      inform (0, "%Jprevious declaration of %<%c%s%>", proto,
+	      warning_at (DECL_SOURCE_LOCATION (method), 0,
+			  "conflicting types for %<%c%s%>",
+			  (type ? '-' : '+'),
+			  identifier_to_locale (gen_method_decl (method)));
+	      inform (DECL_SOURCE_LOCATION (proto),
+		      "previous declaration of %<%c%s%>",
 		      (type ? '-' : '+'),
 		      identifier_to_locale (gen_method_decl (proto)));
 	    }
 	}
       else
Index: gcc/cgraphunit.c
===================================================================
--- gcc/cgraphunit.c	(revision 149310)
+++ gcc/cgraphunit.c	(working copy)
@@ -843,13 +843,13 @@ process_function_and_variable_attributes
 	     cgraph_mark_needed_node (node);
 	}
       if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
 	{
 	  if (! TREE_PUBLIC (node->decl))
-	    warning (OPT_Wattributes,
-		     "%J%<externally_visible%> attribute have effect only on public objects",
-		     node->decl);
+	    warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes,
+			"%<externally_visible%>"
+			" attribute have effect only on public objects");
 	  else
 	    {
 	      if (node->local.finalized)
 		cgraph_mark_needed_node (node);
 	      node->local.externally_visible = true;
@@ -866,13 +866,13 @@ process_function_and_variable_attributes
 	    varpool_mark_needed_node (vnode);
 	}
       if (lookup_attribute ("externally_visible", DECL_ATTRIBUTES (decl)))
 	{
 	  if (! TREE_PUBLIC (vnode->decl))
-	    warning (OPT_Wattributes,
-		     "%J%<externally_visible%> attribute have effect only on public objects",
-		     vnode->decl);
+	    warning_at (DECL_SOURCE_LOCATION (vnode->decl), OPT_Wattributes,
+			"%<externally_visible%>"
+			" attribute have effect only on public objects");
 	  else
 	    {
 	      if (vnode->finalized)
 		varpool_mark_needed_node (vnode);
 	      vnode->externally_visible = true;
Index: gcc/cp/init.c
===================================================================
--- gcc/cp/init.c	(revision 149310)
+++ gcc/cp/init.c	(working copy)
@@ -424,12 +424,13 @@ perform_member_init (tree member, tree i
   tree type = TREE_TYPE (member);
 
   /* Effective C++ rule 12 requires that all data members be
      initialized.  */
   if (warn_ecpp && init == NULL_TREE && TREE_CODE (type) != ARRAY_TYPE)
-    warning (OPT_Weffc__, "%J%qD should be initialized in the member initialization "
-	     "list", current_function_decl, member);
+    warning_at (DECL_SOURCE_LOCATION (current_function_decl), OPT_Weffc__,
+		"%qD should be initialized in the member initialization list",
+		member);
 
   /* Get an lvalue for the data member.  */
   decl = build_class_member_access_expr (current_class_ref, member,
 					 /*access_path=*/NULL_TREE,
 					 /*preserve_reference=*/true,
@@ -449,13 +450,13 @@ perform_member_init (tree member, tree i
 	  finish_expr_stmt (init);
 	}
       else
 	{
 	  if (TREE_CODE (type) == REFERENCE_TYPE)
-	    permerror (input_location, "%Jvalue-initialization of %q#D, "
-				       "which has reference type",
-		       current_function_decl, member);
+	    permerror (DECL_SOURCE_LOCATION (current_function_decl),
+		       "value-initialization of %q#D, which has reference type",
+		       member);
 	  else
 	    {
 	      init = build2 (INIT_EXPR, type, decl, build_value_init (type));
 	      finish_expr_stmt (init);
 	    }
@@ -490,27 +491,30 @@ perform_member_init (tree member, tree i
 	  if (CP_TYPE_CONST_P (type)
 	      && init == NULL_TREE
 	      && !type_has_user_provided_default_constructor (type))
 	    /* TYPE_NEEDS_CONSTRUCTING can be set just because we have a
 	       vtable; still give this diagnostic.  */
-	    permerror (input_location, "%Juninitialized member %qD with %<const%> type %qT",
-		       current_function_decl, member, type);
+	    permerror (DECL_SOURCE_LOCATION (current_function_decl),
+		       "uninitialized member %qD with %<const%> type %qT",
+		       member, type);
 	  finish_expr_stmt (build_aggr_init (decl, init, 0, 
 					     tf_warning_or_error));
 	}
     }
   else
     {
       if (init == NULL_TREE)
 	{
 	  /* member traversal: note it leaves init NULL */
 	  if (TREE_CODE (type) == REFERENCE_TYPE)
-	    permerror (input_location, "%Juninitialized reference member %qD",
-		       current_function_decl, member);
+	    permerror (DECL_SOURCE_LOCATION (current_function_decl),
+		       "uninitialized reference member %qD",
+		       member);
 	  else if (CP_TYPE_CONST_P (type))
-	    permerror (input_location, "%Juninitialized member %qD with %<const%> type %qT",
-		       current_function_decl, member, type);
+	    permerror (DECL_SOURCE_LOCATION (current_function_decl),
+		       "uninitialized member %qD with %<const%> type %qT",
+		       member, type);
 	}
       else if (TREE_CODE (init) == TREE_LIST)
 	/* There was an explicit member initialization.  Do some work
 	   in that case.  */
 	init = build_x_compound_expr_from_list (init, "member initializer");
@@ -659,11 +663,12 @@ sort_mem_initializers (tree t, tree mem_
 		     TREE_PURPOSE (next_subobject));
 	  if (TREE_CODE (subobject) == FIELD_DECL)
 	    warning (OPT_Wreorder, "  %q+#D", subobject);
 	  else
 	    warning (OPT_Wreorder, "  base %qT", subobject);
-	  warning (OPT_Wreorder, "%J  when initialized here", current_function_decl);
+	  warning_at (DECL_SOURCE_LOCATION (current_function_decl),
+		      OPT_Wreorder, "  when initialized here");
 	}
 
       /* Look again, from the beginning of the list.  */
       if (!subobject_init)
 	{
@@ -675,15 +680,17 @@ sort_mem_initializers (tree t, tree mem_
       /* It is invalid to initialize the same subobject more than
 	 once.  */
       if (TREE_VALUE (subobject_init))
 	{
 	  if (TREE_CODE (subobject) == FIELD_DECL)
-	    error ("%Jmultiple initializations given for %qD",
-		   current_function_decl, subobject);
+	    error_at (DECL_SOURCE_LOCATION (current_function_decl),
+		      "multiple initializations given for %qD",
+		      subobject);
 	  else
-	    error ("%Jmultiple initializations given for base %qT",
-		   current_function_decl, subobject);
+	    error_at (DECL_SOURCE_LOCATION (current_function_decl),
+		      "multiple initializations given for base %qT",
+		      subobject);
 	}
 
       /* Record the initialization.  */
       TREE_VALUE (subobject_init) = TREE_VALUE (init);
       next_subobject = subobject_init;
@@ -745,12 +752,13 @@ sort_mem_initializers (tree t, tree mem_
 	      while (1)
 		{
 		  if (same_type_p (last_field_type, field_type))
 		    {
 		      if (TREE_CODE (field_type) == UNION_TYPE)
-			error ("%Jinitializations for multiple members of %qT",
-			       current_function_decl, last_field_type);
+			error_at (DECL_SOURCE_LOCATION (current_function_decl),
+				  "initializations for multiple members of %qT",
+				  last_field_type);
 		      done = 1;
 		      break;
 		    }
 
 		  if (same_type_p (last_field_type, t))
@@ -808,13 +816,14 @@ emit_mem_initializers (tree mem_inits)
 	 is a user-defined constructor in the base class (other than the
 	 default constructor, which will be called anyway).  */
       if (extra_warnings && !arguments
 	  && DECL_COPY_CONSTRUCTOR_P (current_function_decl)
 	  && type_has_user_nondefault_constructor (BINFO_TYPE (subobject)))
-	warning (OPT_Wextra, "%Jbase class %q#T should be explicitly initialized in the "
-		 "copy constructor",
-		 current_function_decl, BINFO_TYPE (subobject));
+	warning_at (DECL_SOURCE_LOCATION (current_function_decl), OPT_Wextra,
+		    "base class %q#T should be explicitly initialized in the "
+		    "copy constructor",
+		    BINFO_TYPE (subobject));
 
       /* Initialize the base.  */
       if (BINFO_VIRTUAL_P (subobject))
 	construct_virtual_base (subobject, arguments);
       else
Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 149310)
+++ gcc/cp/decl.c	(working copy)
@@ -1467,12 +1467,13 @@ duplicate_decls (tree newdecl, tree oldd
 	       && DECL_INITIAL (olddecl) != NULL_TREE
 	       && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) == NULL_TREE
 	       && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != NULL_TREE)
 	{
 	  /* Prototype decl follows defn w/o prototype.  */
-	  warning (0, "prototype for %q+#D", newdecl);
-	  warning (0, "%Jfollows non-prototype definition here", olddecl);
+	  warning_at (input_location, 0, "prototype for %q+#D", newdecl);
+	  warning_at (DECL_SOURCE_LOCATION (olddecl), 0,
+		      "follows non-prototype definition here");
 	}
       else if ((TREE_CODE (olddecl) == FUNCTION_DECL
 		|| TREE_CODE (olddecl) == VAR_DECL)
 	       && DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl))
 	{
@@ -2049,14 +2050,14 @@ duplicate_decls (tree newdecl, tree oldd
   /* Warn about conflicting visibility specifications.  */
   if (DECL_VISIBILITY_SPECIFIED (olddecl)
       && DECL_VISIBILITY_SPECIFIED (newdecl)
       && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
     {
-      warning (OPT_Wattributes, "%q+D: visibility attribute ignored "
-	       "because it", newdecl);
-      warning (OPT_Wattributes, "%Jconflicts with previous "
-	       "declaration here", olddecl);
+      warning_at (input_location, OPT_Wattributes,
+		  "%q+D: visibility attribute ignored because it", newdecl);
+      warning_at (DECL_SOURCE_LOCATION (olddecl), OPT_Wattributes,
+		  "conflicts with previous declaration here");
     }
   /* Choose the declaration which specified visibility.  */
   if (DECL_VISIBILITY_SPECIFIED (olddecl))
     {
       DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl);
@@ -2639,11 +2640,11 @@ check_goto (tree decl)
       int u = decl_jump_unsafe (b);
 
       if (u > 1 && DECL_ARTIFICIAL (b))
 	{
 	  /* Can't skip init of __exception_info.  */
-	  error ("%J  enters catch block", b);
+	  error_at (DECL_SOURCE_LOCATION (b), "  enters catch block");
 	  saw_catch = true;
 	}
       else if (u > 1)
 	error ("  skips initialization of %q+#D", b);
       else
@@ -3793,13 +3794,15 @@ fixup_anonymous_aggr (tree t)
   if (TYPE_METHODS (t))
     {
       tree decl = TYPE_MAIN_DECL (t);
 
       if (TREE_CODE (t) != UNION_TYPE)
-	error ("%Jan anonymous struct cannot have function members", decl);
+	error_at (DECL_SOURCE_LOCATION (decl), 
+		  "an anonymous struct cannot have function members");
       else
-	error ("%Jan anonymous union cannot have function members", decl);
+	error_at (DECL_SOURCE_LOCATION (decl),
+		  "an anonymous union cannot have function members");
     }
 
   /* Anonymous aggregates cannot have fields with ctors, dtors or complex
      assignment operators (because they cannot have these methods themselves).
      For anonymous unions this is already checked because they are not allowed
@@ -4627,16 +4630,17 @@ maybe_commonize_var (tree decl)
 	      /* While for initialized variables, we must use internal
 		 linkage -- which means that multiple copies will not
 		 be merged.  */
 	      TREE_PUBLIC (decl) = 0;
 	      DECL_COMMON (decl) = 0;
-	      warning (0, "sorry: semantics of inline function static "
-		       "data %q+#D are wrong (you'll wind up "
-		       "with multiple copies)", decl);
-	      warning (0, "%J  you can work around this by removing "
-		       "the initializer",
-		       decl);
+	      warning_at (input_location, 0,
+			  "sorry: semantics of inline function static "
+			  "data %q+#D are wrong (you'll wind up "
+			  "with multiple copies)", decl);
+	      warning_at (DECL_SOURCE_LOCATION (decl), 0, 
+			  "  you can work around this by removing "
+			  "the initializer");
 	    }
 	}
     }
   else if (DECL_LANG_SPECIFIC (decl) && DECL_COMDAT (decl))
     /* Set it up again; we might have set DECL_INITIAL since the last
@@ -8813,11 +8817,12 @@ grokdeclarator (const cp_declarator *dec
       if (decl_context == FIELD)
 	decl = build_lang_decl (TYPE_DECL, unqualified_id, type);
       else
 	decl = build_decl (input_location, TYPE_DECL, unqualified_id, type);
       if (id_declarator && declarator->u.id.qualifying_scope) {
-	error ("%Jtypedef name may not be a nested-name-specifier", decl);
+	error_at (DECL_SOURCE_LOCATION (decl), 
+		  "typedef name may not be a nested-name-specifier");
 	TREE_TYPE (decl) = error_mark_node;
       }
 
       if (decl_context != FIELD)
 	{
@@ -10994,12 +10999,13 @@ start_enum (tree name, tree underlying_t
 				   /*tag_scope=*/ts_current,
 				   /*template_header_p=*/false);
 
   if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE)
     {
-      error ("multiple definition of %q#T", enumtype);
-      error ("%Jprevious definition here", TYPE_MAIN_DECL (enumtype));
+      error_at (input_location, "multiple definition of %q#T", enumtype);
+      error_at (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (enumtype)),
+		"previous definition here");
       /* Clear out TYPE_VALUES, and start again.  */
       TYPE_VALUES (enumtype) = NULL_TREE;
     }
   else
     {
Index: gcc/cp/typeck2.c
===================================================================
--- gcc/cp/typeck2.c	(revision 149310)
+++ gcc/cp/typeck2.c	(working copy)
@@ -310,23 +310,25 @@ abstract_virtuals_error (tree decl, tree
   if (VEC_length (tree, pure))
     {
       unsigned ix;
       tree fn;
 
-      inform (input_location, "%J  because the following virtual functions are pure "
-	      "within %qT:", TYPE_MAIN_DECL (type), type);
+      inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)),
+	      "  because the following virtual functions are pure within %qT:",
+	      type);
 
       for (ix = 0; VEC_iterate (tree, pure, ix, fn); ix++)
 	inform (input_location, "\t%+#D", fn);
       /* Now truncate the vector.  This leaves it non-null, so we know
 	 there are pure virtuals, but empty so we don't list them out
 	 again.  */
       VEC_truncate (tree, pure, 0);
     }
   else
-    inform (input_location, "%J  since type %qT has pure virtual functions",
-	    TYPE_MAIN_DECL (type), type);
+    inform (DECL_SOURCE_LOCATION (TYPE_MAIN_DECL (type)),
+	    "  since type %qT has pure virtual functions",
+	    type);
 
   return 1;
 }
 
 /* Print an error message for invalid use of an incomplete type.
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c	(revision 149310)
+++ gcc/cp/pt.c	(working copy)
@@ -4428,12 +4428,13 @@ redeclare_class_template (tree type, tre
 	{
 	  /* We have in [temp.param]:
 
 	     A template-parameter may not be given default arguments
 	     by two different declarations in the same scope.  */
-	  error ("redefinition of default argument for %q#D", parm);
-	  inform (input_location, "%Joriginal definition appeared here", tmpl_parm);
+	  error_at (input_location, "redefinition of default argument for %q#D", parm);
+	  inform (DECL_SOURCE_LOCATION (tmpl_parm),
+		  "original definition appeared here");
 	  return false;
 	}
 
       if (parm_default != NULL_TREE)
 	/* Update the previous template parameters (which are the ones
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c	(revision 149310)
+++ gcc/cp/name-lookup.c	(working copy)
@@ -1042,12 +1042,14 @@ pushdecl_maybe_friend (tree x, bool is_f
 		    }
 		}
 
 	      if (warn_shadow && !err)
 		{
-		  warning (OPT_Wshadow, "declaration of %q#D shadows a parameter", x);
-		  warning (OPT_Wshadow, "%Jshadowed declaration is here", oldlocal);
+		  warning_at (input_location, OPT_Wshadow,
+			      "declaration of %q#D shadows a parameter", x);
+		  warning_at (DECL_SOURCE_LOCATION (oldlocal), OPT_Wshadow,
+			      "shadowed declaration is here");
 		}
 	    }
 
 	  /* Maybe warn if shadowing something else.  */
 	  else if (warn_shadow && !DECL_EXTERNAL (x)
@@ -1073,20 +1075,23 @@ pushdecl_maybe_friend (tree x, bool is_f
 			   x);
 		}
 	      else if (oldlocal != NULL_TREE
 		       && TREE_CODE (oldlocal) == VAR_DECL)
 		{
-		  warning (OPT_Wshadow, "declaration of %qD shadows a previous local", x);
-		  warning (OPT_Wshadow, "%Jshadowed declaration is here", oldlocal);
+		  warning_at (input_location, OPT_Wshadow,
+			      "declaration of %qD shadows a previous local", x);
+		  warning_at (DECL_SOURCE_LOCATION (oldlocal), OPT_Wshadow,
+			      "shadowed declaration is here");
 		}
 	      else if (oldglobal != NULL_TREE
 		       && TREE_CODE (oldglobal) == VAR_DECL)
 		/* XXX shadow warnings in outer-more namespaces */
 		{
-		  warning (OPT_Wshadow, "declaration of %qD shadows a global declaration",
-			   x);
-		  warning (OPT_Wshadow, "%Jshadowed declaration is here", oldglobal);
+		  warning_at (input_location, OPT_Wshadow,
+			      "declaration of %qD shadows a global declaration", x);
+		  warning_at (DECL_SOURCE_LOCATION (oldglobal), OPT_Wshadow,
+			      "shadowed declaration is here");
 		}
 	    }
 	}
 
       if (TREE_CODE (x) == VAR_DECL)
Index: gcc/c-decl.c
===================================================================
--- gcc/c-decl.c	(revision 149310)
+++ gcc/c-decl.c	(working copy)
@@ -1888,13 +1888,14 @@ diagnose_mismatched_decls (tree newdecl,
 					DECL_ATTRIBUTES (newdecl)) != NULL;
 	  bool olda = lookup_attribute ("gnu_inline",
 					DECL_ATTRIBUTES (olddecl)) != NULL;
 	  if (newa != olda)
 	    {
-	      error ("%<gnu_inline%> attribute present on %q+D",
-		     newa ? newdecl : olddecl);
-	      error ("%Jbut not here", newa ? olddecl : newdecl);
+	      error_at (input_location, "%<gnu_inline%> attribute present on %q+D",
+			newa ? newdecl : olddecl);
+	      error_at (DECL_SOURCE_LOCATION (newa ? olddecl : newdecl),
+			"but not here");
 	    }
 	}
     }
   else if (TREE_CODE (newdecl) == VAR_DECL)
     {
@@ -2487,11 +2488,12 @@ warn_if_shadowing (tree new_decl)
 	  }
 	else
 	  warning (OPT_Wshadow, "declaration of %q+D shadows a previous local",
 		   new_decl);
 
-	warning (OPT_Wshadow, "%Jshadowed declaration is here", old_decl);
+	warning_at (DECL_SOURCE_LOCATION (old_decl), OPT_Wshadow,
+		    "shadowed declaration is here");
 
 	break;
       }
 }
 
@@ -6000,27 +6002,31 @@ grokparms (struct c_arg_info *arg_info, 
 	  if (!COMPLETE_TYPE_P (type))
 	    {
 	      if (funcdef_flag)
 		{
 		  if (DECL_NAME (parm))
-		    error ("parameter %u (%q+D) has incomplete type",
-			   parmno, parm);
+		    error_at (input_location,
+			      "parameter %u (%q+D) has incomplete type",
+			      parmno, parm);
 		  else
-		    error ("%Jparameter %u has incomplete type",
-			   parm, parmno);
+		    error_at (DECL_SOURCE_LOCATION (parm),
+			      "parameter %u has incomplete type",
+			      parmno);
 
 		  TREE_VALUE (typelt) = error_mark_node;
 		  TREE_TYPE (parm) = error_mark_node;
 		}
 	      else if (VOID_TYPE_P (type))
 		{
 		  if (DECL_NAME (parm))
-		    warning (0, "parameter %u (%q+D) has void type",
-			     parmno, parm);
+		    warning_at (input_location, 0,
+				"parameter %u (%q+D) has void type",
+				parmno, parm);
 		  else
-		    warning (0, "%Jparameter %u has void type",
-			     parm, parmno);
+		    warning_at (DECL_SOURCE_LOCATION (parm), 0,
+				"parameter %u has void type",
+				parmno);
 		}
 	    }
 
 	  errmsg = targetm.invalid_parameter_type (type);
 	  if (errmsg)
@@ -6720,32 +6726,31 @@ finish_struct (location_t loc, tree t, t
 	  && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE)
 	{
 	  if (TREE_CODE (t) == UNION_TYPE)
 	    {
 	      error_at (DECL_SOURCE_LOCATION (x),
-			"%Jflexible array member in union", x);
+			"flexible array member in union");
 	      TREE_TYPE (x) = error_mark_node;
 	    }
 	  else if (TREE_CHAIN (x) != NULL_TREE)
 	    {
 	      error_at (DECL_SOURCE_LOCATION (x),
-			"%Jflexible array member not at end of struct", x);
+			"flexible array member not at end of struct");
 	      TREE_TYPE (x) = error_mark_node;
 	    }
 	  else if (!saw_named_field)
 	    {
 	      error_at (DECL_SOURCE_LOCATION (x),
-			"%Jflexible array member in otherwise empty struct",
-			x);
+			"flexible array member in otherwise empty struct");
 	      TREE_TYPE (x) = error_mark_node;
 	    }
 	}
 
-      if (pedantic && !in_system_header && TREE_CODE (t) == RECORD_TYPE
+      if (pedantic && TREE_CODE (t) == RECORD_TYPE
 	  && flexible_array_type_p (TREE_TYPE (x)))
-	pedwarn (loc, OPT_pedantic, 
-		 "%Jinvalid use of structure with flexible array member", x);
+	pedwarn (DECL_SOURCE_LOCATION (x), OPT_pedantic, 
+		 "invalid use of structure with flexible array member");
 
       if (DECL_NAME (x))
 	saw_named_field = 1;
     }
 
@@ -7463,12 +7468,13 @@ store_parm_decls_newstyle (tree fndecl, 
 {
   tree decl;
 
   if (current_scope->bindings)
     {
-      error ("%Jold-style parameter declarations in prototyped "
-	     "function definition", fndecl);
+      error_at (DECL_SOURCE_LOCATION (fndecl),
+		"old-style parameter declarations in prototyped "
+		"function definition");
 
       /* Get rid of the old-style declarations.  */
       pop_scope ();
       push_scope ();
     }
@@ -7476,13 +7482,12 @@ store_parm_decls_newstyle (tree fndecl, 
      warning if we got here because ARG_INFO_TYPES was error_mark_node
      (this happens when a function definition has just an ellipsis in
      its parameter list).  */
   else if (!in_system_header && !current_function_scope
 	   && arg_info->types != error_mark_node)
-    warning (OPT_Wtraditional,
-	     "%Jtraditional C rejects ISO C style function definitions",
-	     fndecl);
+    warning_at (DECL_SOURCE_LOCATION (fndecl), OPT_Wtraditional,
+		"traditional C rejects ISO C style function definitions");
 
   /* Now make all the parameter declarations visible in the function body.
      We can bypass most of the grunt work of pushdecl.  */
   for (decl = arg_info->parms; decl; decl = TREE_CHAIN (decl))
     {
@@ -7494,11 +7499,11 @@ store_parm_decls_newstyle (tree fndecl, 
 		UNKNOWN_LOCATION);
 	  if (!TREE_USED (decl))
 	    warn_if_shadowing (decl);
 	}
       else
-	error ("%Jparameter name omitted", decl);
+	error_at (DECL_SOURCE_LOCATION (decl), "parameter name omitted");
     }
 
   /* Record the parameter list in the function declaration.  */
   DECL_ARGUMENTS (fndecl) = arg_info->parms;
 
Index: gcc/function.c
===================================================================
--- gcc/function.c	(revision 149310)
+++ gcc/function.c	(working copy)
@@ -244,11 +244,12 @@ frame_offset_overflow (HOST_WIDE_INT off
 
   if (size > ((unsigned HOST_WIDE_INT) 1 << (GET_MODE_BITSIZE (Pmode) - 1))
 	       /* Leave room for the fixed part of the frame.  */
 	       - 64 * UNITS_PER_WORD)
     {
-      error ("%Jtotal size of local objects too large", func);
+      error_at (DECL_SOURCE_LOCATION (func),
+		"total size of local objects too large");
       return TRUE;
     }
 
   return FALSE;
 }
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c	(revision 149310)
+++ gcc/varasm.c	(working copy)
@@ -5463,11 +5463,12 @@ do_assemble_alias (tree decl, tree targe
 			  IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
 			  IDENTIFIER_POINTER (target));
 #else
       if (!SUPPORTS_WEAK)
 	{
-	  error ("%Jweakref is not supported in this configuration", decl);
+	  error_at (DECL_SOURCE_LOCATION (decl),
+		    "weakref is not supported in this configuration");
 	  return;
 	}
 #endif
       return;
     }
@@ -5603,16 +5604,18 @@ assemble_alias (tree decl, tree target)
     }
   else
     {
 #if !defined (ASM_OUTPUT_DEF)
 # if !defined(ASM_OUTPUT_WEAK_ALIAS) && !defined (ASM_WEAKEN_DECL)
-      error ("%Jalias definitions not supported in this configuration", decl);
+      error_at (DECL_SOURCE_LOCATION (decl),
+		"alias definitions not supported in this configuration");
       return;
 # else
       if (!DECL_WEAK (decl))
 	{
-	  error ("%Jonly weak aliases are supported in this configuration", decl);
+	  error_at (DECL_SOURCE_LOCATION (decl),
+		    "only weak aliases are supported in this configuration");
 	  return;
 	}
 # endif
 #endif
     }
Index: gcc/tree-ssa.c
===================================================================
--- gcc/tree-ssa.c	(revision 149310)
+++ gcc/tree-ssa.c	(working copy)
@@ -1268,11 +1268,11 @@ warn_uninit (tree t, const char *gmsgid,
       TREE_NO_WARNING (var) = 1;
 
       if (xloc.file != floc.file
 	  || xloc.line < floc.line
 	  || xloc.line > LOCATION_LINE (cfun->function_end_locus))
-	inform (location, "%J%qD was declared here", var, var);
+	inform (DECL_SOURCE_LOCATION (var), "%qD was declared here", var);
     }
 }
 
 struct walk_data {
   gimple stmt;
Index: gcc/c-common.c
===================================================================
--- gcc/c-common.c	(revision 149310)
+++ gcc/c-common.c	(working copy)
@@ -5415,17 +5415,19 @@ match_case_to_enum_1 (tree key, tree typ
     snprintf (buf, sizeof (buf), HOST_WIDE_INT_PRINT_DOUBLE_HEX,
 	      (unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (key),
 	      (unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (key));
 
   if (TYPE_NAME (type) == 0)
-    warning (warn_switch ? OPT_Wswitch : OPT_Wswitch_enum,
-	     "%Jcase value %qs not in enumerated type",
-	     CASE_LABEL (label), buf);
-  else
-    warning (warn_switch ? OPT_Wswitch : OPT_Wswitch_enum,
-	     "%Jcase value %qs not in enumerated type %qT",
-	     CASE_LABEL (label), buf, type);
+    warning_at (DECL_SOURCE_LOCATION (CASE_LABEL (label)),
+		warn_switch ? OPT_Wswitch : OPT_Wswitch_enum,
+		"case value %qs not in enumerated type",
+		buf);
+  else
+    warning_at (DECL_SOURCE_LOCATION (CASE_LABEL (label)),
+		warn_switch ? OPT_Wswitch : OPT_Wswitch_enum,
+		"case value %qs not in enumerated type %qT",
+		buf, type);
 }
 
 /* Subroutine of c_do_switch_warnings, called via splay_tree_foreach.
    Used to verify that case values match up with enumerator values.  */
 
@@ -6491,12 +6493,13 @@ handle_section_attribute (tree *node, tr
 	{
 	  if (TREE_CODE (decl) == VAR_DECL
 	      && current_function_decl != NULL_TREE
 	      && !TREE_STATIC (decl))
 	    {
-	      error ("%Jsection attribute cannot be specified for "
-		     "local variables", decl);
+	      error_at (DECL_SOURCE_LOCATION (decl), 
+			"section attribute cannot be specified for "
+			"local variables");
 	      *no_add_attrs = true;
 	    }
 
 	  /* The decl may have already been given a section attribute
 	     from a previous declaration.  Ensure they match.  */
@@ -6524,11 +6527,12 @@ handle_section_attribute (tree *node, tr
 	  *no_add_attrs = true;
 	}
     }
   else
     {
-      error ("%Jsection attributes are not supported for this target", *node);
+      error_at (DECL_SOURCE_LOCATION (*node),
+		"section attributes are not supported for this target");
       *no_add_attrs = true;
     }
 
   return NULL_TREE;
 }
@@ -6743,12 +6747,12 @@ handle_weakref_attribute (tree *node, tr
       decl_attributes (node, attr, flags);
     }
   else
     {
       if (lookup_attribute ("alias", DECL_ATTRIBUTES (*node)))
-	error ("%Jweakref attribute must appear before alias attribute",
-	       *node);
+	error_at (DECL_SOURCE_LOCATION (*node),
+		  "weakref attribute must appear before alias attribute");
 
       /* Can't call declare_weak because it wants this to be TREE_PUBLIC,
 	 and that isn't supported; and because it wants to add it to
 	 the list of weak decls, which isn't helpful.  */
       DECL_WEAK (*node) = 1;
@@ -6954,16 +6958,18 @@ handle_no_instrument_function_attribute 
 {
   tree decl = *node;
 
   if (TREE_CODE (decl) != FUNCTION_DECL)
     {
-      error ("%J%qE attribute applies only to functions", decl, name);
+      error_at (DECL_SOURCE_LOCATION (decl),
+		"%qE attribute applies only to functions", name);
       *no_add_attrs = true;
     }
   else if (DECL_INITIAL (decl))
     {
-      error ("%Jcan%'t set %qE attribute after definition", decl, name);
+      error_at (DECL_SOURCE_LOCATION (decl),
+		"can%'t set %qE attribute after definition", name);
       *no_add_attrs = true;
     }
   else
     DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
 
@@ -7044,16 +7050,18 @@ handle_no_limit_stack_attribute (tree *n
 {
   tree decl = *node;
 
   if (TREE_CODE (decl) != FUNCTION_DECL)
     {
-      error ("%J%qE attribute applies only to functions", decl, name);
+      error_at (DECL_SOURCE_LOCATION (decl),
+	     "%qE attribute applies only to functions", name);
       *no_add_attrs = true;
     }
   else if (DECL_INITIAL (decl))
     {
-      error ("%Jcan%'t set %qE attribute after definition", decl, name);
+      error_at (DECL_SOURCE_LOCATION (decl),
+		"can%'t set %qE attribute after definition", name);
       *no_add_attrs = true;
     }
   else
     DECL_NO_LIMIT_STACK (decl) = 1;
 
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c	(revision 149310)
+++ gcc/tree-cfg.c	(working copy)
@@ -7340,13 +7340,13 @@ execute_warn_function_noreturn (void)
 {
   if (warn_missing_noreturn
       && !TREE_THIS_VOLATILE (cfun->decl)
       && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0
       && !lang_hooks.missing_noreturn_ok_p (cfun->decl))
-    warning (OPT_Wmissing_noreturn, "%Jfunction might be possible candidate "
-	     "for attribute %<noreturn%>",
-	     cfun->decl);
+    warning_at (DECL_SOURCE_LOCATION (cfun->decl), OPT_Wmissing_noreturn,
+		"function might be possible candidate "
+		"for attribute %<noreturn%>");
   return 0;
 }
 
 struct gimple_opt_pass pass_warn_function_noreturn =
 {
Index: gcc/config/spu/spu.c
===================================================================
--- gcc/config/spu/spu.c	(revision 149310)
+++ gcc/config/spu/spu.c	(working copy)
@@ -4942,12 +4942,11 @@ array_to_constant (enum machine_mode mod
 }
 
 static void
 reloc_diagnostic (rtx x)
 {
-  tree loc_decl, decl = 0;
-  const char *msg;
+  tree decl = 0;
   if (!flag_pic || !(TARGET_WARN_RELOC || TARGET_ERROR_RELOC))
     return;
 
   if (GET_CODE (x) == SYMBOL_REF)
     decl = SYMBOL_REF_DECL (x);
@@ -4957,28 +4956,36 @@ reloc_diagnostic (rtx x)
 
   /* SYMBOL_REF_DECL is not necessarily a DECL. */
   if (decl && !DECL_P (decl))
     decl = 0;
 
-  /* We use last_assemble_variable_decl to get line information.  It's
-     not always going to be right and might not even be close, but will
-     be right for the more common cases. */
-  if (!last_assemble_variable_decl || in_section == ctors_section)
-    loc_decl = decl;
-  else
-    loc_decl = last_assemble_variable_decl;
-
   /* The decl could be a string constant.  */
   if (decl && DECL_P (decl))
-    msg = "%Jcreating run-time relocation for %qD";
-  else
-    msg = "creating run-time relocation";
+    {
+      location_t loc;
+      /* We use last_assemble_variable_decl to get line information.  It's
+	 not always going to be right and might not even be close, but will
+	 be right for the more common cases. */
+      if (!last_assemble_variable_decl || in_section == ctors_section)
+	loc = DECL_SOURCE_LOCATION (decl);
+      else
+	loc = DECL_SOURCE_LOCATION (last_assemble_variable_decl);
 
-  if (TARGET_WARN_RELOC)
-    warning (0, msg, loc_decl, decl);
-  else
-    error (msg, loc_decl, decl);
+      if (TARGET_WARN_RELOC)
+	warning_at (loc, 0,
+		    "creating run-time relocation for %qD", decl);
+      else
+	error_at (loc,
+		  "creating run-time relocation for %qD", decl);
+    }
+  else 
+    {
+      if (TARGET_WARN_RELOC)
+	warning_at (input_location, 0, "creating run-time relocation");
+      else
+	error_at (input_location, "creating run-time relocation");
+    }
 }
 
 /* Hook into assemble_integer so we can generate an error for run-time
    relocations.  The SPU ABI disallows them. */
 static bool
Index: gcc/config/ia64/ia64.c
===================================================================
--- gcc/config/ia64/ia64.c	(revision 149310)
+++ gcc/config/ia64/ia64.c	(working copy)
@@ -591,12 +591,13 @@ ia64_handle_model_attribute (tree *node,
     case VAR_DECL:
       if ((DECL_CONTEXT (decl) && TREE_CODE (DECL_CONTEXT (decl))
 	   == FUNCTION_DECL)
 	  && !TREE_STATIC (decl))
 	{
-	  error ("%Jan address area attribute cannot be specified for "
-		 "local variables", decl);
+	  error_at (DECL_SOURCE_LOCATION (decl),
+		    "an address area attribute cannot be specified for "
+		    "local variables");
 	  *no_add_attrs = true;
 	}
       area = ia64_get_addr_area (decl);
       if (area != ADDR_AREA_NORMAL && addr_area != area)
 	{
@@ -605,12 +606,13 @@ ia64_handle_model_attribute (tree *node,
 	  *no_add_attrs = true;
 	}
       break;
 
     case FUNCTION_DECL:
-      error ("%Jaddress area attribute cannot be specified for functions",
-	     decl);
+      error_at (DECL_SOURCE_LOCATION (decl),
+		"address area attribute cannot be specified for functions",
+		decl);
       *no_add_attrs = true;
       break;
 
     default:
       warning (OPT_Wattributes, "%qE attribute ignored",
Index: gcc/config/v850/v850.c
===================================================================
--- gcc/config/v850/v850.c	(revision 149310)
+++ gcc/config/v850/v850.c	(working copy)
@@ -2088,12 +2088,13 @@ v850_handle_data_area_attribute (tree* n
   switch (TREE_CODE (decl))
     {
     case VAR_DECL:
       if (current_function_decl != NULL_TREE)
 	{
-          error ("%Jdata area attributes cannot be specified for "
-                 "local variables", decl);
+          error_at (DECL_SOURCE_LOCATION (decl),
+		    "data area attributes cannot be specified for "
+		    "local variables");
 	  *no_add_attrs = true;
 	}
 
       /* Drop through.  */
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]