From ef9db2a34a8eaca16ead74203d0bbda87f975f6e Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 17 Mar 2016 17:47:41 -0400
Subject: [PATCH 13/17] FIXME: eliminate error_at_rich_loc etc in favor of
 overloads

---
 gcc/auto-profile.c                 |  2 +-
 gcc/c-family/c-common.c            |  6 +++---
 gcc/c/c-decl.c                     |  4 ++--
 gcc/c/c-parser.c                   | 30 +++++++++++++++---------------
 gcc/c/c-typeck.c                   | 13 ++++++-------
 gcc/cp/class.c                     | 10 ++++++----
 gcc/cp/decl.c                      |  5 +++--
 gcc/cp/parser.c                    | 11 ++++-------
 gcc/cp/semantics.c                 |  2 +-
 gcc/cp/typeck.c                    |  2 +-
 gcc/diagnostic-core.h              | 13 ++++++-------
 gcc/diagnostic.c                   | 18 +++++++++---------
 gcc/gcc.c                          |  7 ++++---
 gcc/objc/objc-gnu-runtime-abi-01.c |  2 +-
 14 files changed, 62 insertions(+), 63 deletions(-)

diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index 5c0640a..81a8bf8 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -822,7 +822,7 @@ autofdo_source_profile::read ()
 {
   if (gcov_read_unsigned () != GCOV_TAG_AFDO_FUNCTION)
     {
-      inform (0, "Not expected TAG.");
+      inform (UNKNOWN_LOCATION, "Not expected TAG.");
       return false;
     }
 
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 08b761c..024b935 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3862,9 +3862,9 @@ binary_op_error (rich_location *richloc, enum tree_code code,
     default:
       gcc_unreachable ();
     }
-  error_at_rich_loc (richloc,
-		     "invalid operands to binary %s (have %qT and %qT)",
-		     opname, type0, type1);
+  error_at (richloc,
+	    "invalid operands to binary %s (have %qT and %qT)",
+	    opname, type0, type1);
 }
 
 /* Given an expression as a tree, return its original type.  Do this
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index fd2dd74..9f6a43b 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -3103,7 +3103,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl)
 	    rich_location richloc (line_table, loc);
 	    richloc.add_fixit_replace (get_range_from_loc (line_table, loc),
 				       IDENTIFIER_POINTER (hint));
-	    warned = pedwarn_at_rich_loc
+	    warned = pedwarn
 	      (&richloc, OPT_Wimplicit_function_declaration,
 	       "implicit declaration of function %qE; did you mean %qE?",
 	       id, hint);
@@ -3117,7 +3117,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl)
 	    rich_location richloc (line_table, loc);
 	    richloc.add_fixit_replace (get_range_from_loc (line_table, loc),
 				       IDENTIFIER_POINTER (hint));
-	    warned = warning_at_rich_loc
+	    warned = warning_at
 	      (&richloc, OPT_Wimplicit_function_declaration,
 	       G_("implicit declaration of function %qE;did you mean %qE?"),
 	       id, hint);
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index ebeda60..f0ad875 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -1670,26 +1670,26 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
 	{
 	  /* This is not C++ with its implicit typedef.  */
 	  richloc.add_fixit_insert (here, "struct");
-	  error_at_rich_loc (&richloc,
-			     "unknown type name %qE;"
-			     " use %<struct%> keyword to refer to the type",
-			     name);
+	  error_at (&richloc,
+		    "unknown type name %qE;"
+		    " use %<struct%> keyword to refer to the type",
+		    name);
 	}
       else if (tag_exists_p (UNION_TYPE, name))
 	{
 	  richloc.add_fixit_insert (here, "union");
-	  error_at_rich_loc (&richloc,
-			     "unknown type name %qE;"
-			     " use %<union%> keyword to refer to the type",
-			     name);
+	  error_at (&richloc,
+		    "unknown type name %qE;"
+		    " use %<union%> keyword to refer to the type",
+		    name);
 	}
       else if (tag_exists_p (ENUMERAL_TYPE, name))
 	{
 	  richloc.add_fixit_insert (here, "enum");
-	  error_at_rich_loc (&richloc,
-			     "unknown type name %qE;"
-			     " use %<enum%> keyword to refer to the type",
-			     name);
+	  error_at (&richloc,
+		    "unknown type name %qE;"
+		    " use %<enum%> keyword to refer to the type",
+		    name);
 	}
       else
 	{
@@ -1698,9 +1698,9 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok,
 	    {
 	      richloc.add_fixit_replace (get_range_from_loc (line_table, here),
 					 IDENTIFIER_POINTER (hint));
-	      error_at_rich_loc (&richloc,
-				 "unknown type name %qE; did you mean %qE?",
-				 name, hint);
+	      error_at (&richloc,
+			"unknown type name %qE; did you mean %qE?",
+			name, hint);
 	    }
 	  else
 	    error_at (here, "unknown type name %qE", name);
diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 43013af..7922416 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -2357,10 +2357,9 @@ build_component_ref (location_t loc, tree datum, tree component,
 		  rich_loc.add_fixit_replace (component_range,
 					      IDENTIFIER_POINTER (guessed_id));
 		}
-	      error_at_rich_loc
-		(&rich_loc,
-		 "%qT has no member named %qE; did you mean %qE?",
-		 type, component, guessed_id);
+	      error_at (&rich_loc,
+			"%qT has no member named %qE; did you mean %qE?",
+			type, component, guessed_id);
 	    }
 	  else
 	    error_at (loc, "%qT has no member named %qE", type, component);
@@ -2434,9 +2433,9 @@ build_component_ref (location_t loc, tree datum, tree component,
       rich_location richloc (line_table, loc);
       /* "loc" should be the "." token.  */
       richloc.add_fixit_replace (source_range::from_location (loc), "->");
-      error_at_rich_loc (&richloc,
-			 "%qE is a pointer; did you mean to use %<->%>?",
-			 datum);
+      error_at (&richloc,
+		"%qE is a pointer; did you mean to use %<->%>?",
+		datum);
       return error_mark_node;
     }
   else if (code != ERROR_MARK)
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index f6ad696..577863d 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5618,14 +5618,15 @@ explain_non_literal_class (tree t)
     /* Already explained.  */
     return;
 
-  inform (0, "%q+T is not literal because:", t);
+  inform (UNKNOWN_LOCATION, "%q+T is not literal because:", t);
   if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t))
-    inform (0, "  %q+T has a non-trivial destructor", t);
+    inform (UNKNOWN_LOCATION, "  %q+T has a non-trivial destructor", t);
   else if (CLASSTYPE_NON_AGGREGATE (t)
 	   && !TYPE_HAS_TRIVIAL_DFLT (t)
 	   && !TYPE_HAS_CONSTEXPR_CTOR (t))
     {
-      inform (0, "  %q+T is not an aggregate, does not have a trivial "
+      inform (UNKNOWN_LOCATION,
+	      "  %q+T is not an aggregate, does not have a trivial "
 	      "default constructor, and has no constexpr constructor that "
 	      "is not a copy or move constructor", t);
       if (type_has_non_user_provided_default_constructor (t))
@@ -5660,7 +5661,8 @@ explain_non_literal_class (tree t)
 	  tree basetype = TREE_TYPE (base_binfo);
 	  if (!CLASSTYPE_LITERAL_P (basetype))
 	    {
-	      inform (0, "  base class %qT of %q+T is non-literal",
+	      inform (UNKNOWN_LOCATION,
+		      "  base class %qT of %q+T is non-literal",
 		      basetype, t);
 	      explain_non_literal_class (basetype);
 	      return;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 27c3597..bd8e2dd 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1216,9 +1216,10 @@ check_redeclaration_exception_specification (tree new_decl,
       if (! DECL_IN_SYSTEM_HEADER (old_decl))
 	error (msg, new_decl);
       else
-	complained = pedwarn (0, OPT_Wsystem_headers, msg, new_decl);
+	complained = pedwarn (UNKNOWN_LOCATION, OPT_Wsystem_headers, msg,
+			      new_decl);
       if (complained)
-	inform (0, "from previous declaration %q+F", old_decl);
+	inform (UNKNOWN_LOCATION, "from previous declaration %q+F", old_decl);
     }
 }
 
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index fb1250a..e04a6d2 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -21416,14 +21416,11 @@ cp_parser_class_specifier_1 (cp_parser* parser)
 	richloc.add_fixit_insert (next_loc, ";");
 
 	if (CLASSTYPE_DECLARED_CLASS (type))
-	  error_at_rich_loc (&richloc,
-			     "expected %<;%> after class definition");
+	  error_at (&richloc, "expected %<;%> after class definition");
 	else if (TREE_CODE (type) == RECORD_TYPE)
-	  error_at_rich_loc (&richloc,
-			     "expected %<;%> after struct definition");
+	  error_at (&richloc, "expected %<;%> after struct definition");
 	else if (TREE_CODE (type) == UNION_TYPE)
-	  error_at_rich_loc (&richloc,
-			     "expected %<;%> after union definition");
+	  error_at (&richloc, "expected %<;%> after union definition");
 	else
 	  gcc_unreachable ();
 
@@ -21857,7 +21854,7 @@ cp_parser_class_head (cp_parser* parser,
                          get_finish (type_start_token->location));
       rich_location richloc (line_table, reported_loc);
       richloc.add_fixit_insert (class_head_start_location, "template <> ");
-      error_at_rich_loc
+      error_at
         (&richloc,
          "an explicit specialization must be preceded by %<template <>%>");
       invalid_explicit_specialization_p = true;
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 1574e60..e22d1fb 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -3365,7 +3365,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain)
 	    inform (location_of (closure),
 		    "the lambda has no capture-default");
 	  else if (TYPE_CLASS_SCOPE_P (closure))
-	    inform (0, "lambda in local class %q+T cannot "
+	    inform (UNKNOWN_LOCATION, "lambda in local class %q+T cannot "
 		    "capture variables from the enclosing context",
 		    TYPE_CONTEXT (closure));
 	  inform (DECL_SOURCE_LOCATION (decl), "%q#D declared here", decl);
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 98a8bc7..428c5d2 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -2825,7 +2825,7 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p,
 		      rich_loc.add_fixit_replace
 			(bogus_component_range,
 			 IDENTIFIER_POINTER (guessed_id));
-		      error_at_rich_loc
+		      error_at
 			(&rich_loc,
 			 "%q#T has no member named %qE; did you mean %qE?",
 			 TREE_CODE (access_path) == TREE_BINFO
diff --git a/gcc/diagnostic-core.h b/gcc/diagnostic-core.h
index 51df150..fb37bf2 100644
--- a/gcc/diagnostic-core.h
+++ b/gcc/diagnostic-core.h
@@ -63,28 +63,27 @@ extern bool warning_n (location_t, int, int, const char *, const char *, ...)
     ATTRIBUTE_GCC_DIAG(4,6) ATTRIBUTE_GCC_DIAG(5,6);
 extern bool warning_at (location_t, int, const char *, ...)
     ATTRIBUTE_GCC_DIAG(3,4);
-extern bool warning_at_rich_loc (rich_location *, int, const char *, ...)
+extern bool warning_at (rich_location *, int, const char *, ...)
     ATTRIBUTE_GCC_DIAG(3,4);
 extern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 extern void error_n (location_t, int, const char *, const char *, ...)
     ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
 extern void error_at (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
-extern void error_at_rich_loc (rich_location *, const char *, ...)
+extern void error_at (rich_location *, const char *, ...)
   ATTRIBUTE_GCC_DIAG(2,3);
 extern void fatal_error (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3)
      ATTRIBUTE_NORETURN;
 /* Pass one of the OPT_W* from options.h as the second parameter.  */
 extern bool pedwarn (location_t, int, const char *, ...)
      ATTRIBUTE_GCC_DIAG(3,4);
-extern bool pedwarn_at_rich_loc (rich_location *, int, const char *, ...)
+extern bool pedwarn (rich_location *, int, const char *, ...)
      ATTRIBUTE_GCC_DIAG(3,4);
 extern bool permerror (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
-extern bool permerror_at_rich_loc (rich_location *, const char *,
-				   ...) ATTRIBUTE_GCC_DIAG(2,3);
+extern bool permerror (rich_location *, const char *,
+		       ...) ATTRIBUTE_GCC_DIAG(2,3);
 extern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
 extern void inform (location_t, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
-extern void inform_at_rich_loc (rich_location *, const char *,
-				...) ATTRIBUTE_GCC_DIAG(2,3);
+extern void inform (rich_location *, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
 extern void inform_n (location_t, int, const char *, const char *, ...)
     ATTRIBUTE_GCC_DIAG(3,5) ATTRIBUTE_GCC_DIAG(4,5);
 extern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 8aa7a04..3107457 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -957,9 +957,9 @@ inform (location_t location, const char *gmsgid, ...)
   va_end (ap);
 }
 
-/* Same as "inform", but at RICHLOC.  */
+/* Same as above, but at RICHLOC.  */
 void
-inform_at_rich_loc (rich_location *richloc, const char *gmsgid, ...)
+inform (rich_location *richloc, const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
@@ -1028,10 +1028,10 @@ warning_at (location_t location, int opt, const char *gmsgid, ...)
   return ret;
 }
 
-/* Same as warning at, but using RICHLOC.  */
+/* Same as above, but using RICHLOC.  */
 
 bool
-warning_at_rich_loc (rich_location *richloc, int opt, const char *gmsgid, ...)
+warning_at (rich_location *richloc, int opt, const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
@@ -1098,10 +1098,10 @@ pedwarn (location_t location, int opt, const char *gmsgid, ...)
   return ret;
 }
 
-/* Same as pedwarn, but using RICHLOC.  */
+/* Same as above, but using RICHLOC.  */
 
 bool
-pedwarn_at_rich_loc (rich_location *richloc, int opt, const char *gmsgid, ...)
+pedwarn (rich_location *richloc, int opt, const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
@@ -1139,10 +1139,10 @@ permerror (location_t location, const char *gmsgid, ...)
   return ret;
 }
 
-/* Same as "permerror", but at RICHLOC.  */
+/* Same as above, but at RICHLOC.  */
 
 bool
-permerror_at_rich_loc (rich_location *richloc, const char *gmsgid, ...)
+permerror (rich_location *richloc, const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
@@ -1207,7 +1207,7 @@ error_at (location_t loc, const char *gmsgid, ...)
 /* Same as above, but use RICH_LOC.  */
 
 void
-error_at_rich_loc (rich_location *rich_loc, const char *gmsgid, ...)
+error_at (rich_location *rich_loc, const char *gmsgid, ...)
 {
   diagnostic_info diagnostic;
   va_list ap;
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 1af5920..bc034b0 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -5222,7 +5222,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
 	      buf = (char *) alloca (p - q + 1);
 	      strncpy (buf, q, p - q);
 	      buf[p - q] = 0;
-	      inform (0, "%s", _(buf));
+	      inform (UNKNOWN_LOCATION, "%s", _(buf));
 	      if (*p)
 		p++;
 	    }
@@ -8044,7 +8044,8 @@ driver::do_spec_on_infiles () const
 	      else if (compare_debug && debug_check_temp_file[0])
 		{
 		  if (verbose_flag)
-		    inform (0, "recompiling with -fcompare-debug");
+		    inform (UNKNOWN_LOCATION,
+			    "recompiling with -fcompare-debug");
 
 		  compare_debug = -compare_debug;
 		  n_switches = n_switches_debug_check[1];
@@ -8069,7 +8070,7 @@ driver::do_spec_on_infiles () const
 					       debug_check_temp_file[1]));
 
 		  if (verbose_flag)
-		    inform (0, "comparing final insns dumps");
+		    inform (UNKNOWN_LOCATION, "comparing final insns dumps");
 
 		  if (compare_files (debug_check_temp_file))
 		    this_file_error = 1;
diff --git a/gcc/objc/objc-gnu-runtime-abi-01.c b/gcc/objc/objc-gnu-runtime-abi-01.c
index 61360ce..910d339 100644
--- a/gcc/objc/objc-gnu-runtime-abi-01.c
+++ b/gcc/objc/objc-gnu-runtime-abi-01.c
@@ -128,7 +128,7 @@ objc_gnu_runtime_abi_01_init (objc_runtime_hooks *rthooks)
   /* GNU runtime does not need the compiler to change code in order to do GC. */
   if (flag_objc_gc)
     {
-      warning_at (0, 0, "%<-fobjc-gc%> is ignored for %<-fgnu-runtime%>");
+      warning_at (UNKNOWN_LOCATION, 0, "%<-fobjc-gc%> is ignored for %<-fgnu-runtime%>");
       flag_objc_gc = 0;
     }
 
-- 
1.8.5.3

