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]

[PATCH 5/7] clean up quoting problems - c-family (PR 80280 et al.)


The attached patch adds missing quoting to diagnostic directives
in files in the cp/ directory.

Martin
gcc/cp/ChangeLog:

	* call.c (print_z_candidate): Add missing quoting to %D and other
	like directives.
	(build_op_call_1): Same.
	* constraint.cc (diagnose_check_constraint): Same.
	* mangle.c (mangle_decl): Same.
	* name-lookup.c (cp_binding_level_debug): Same.
	(set_decl_namespace): Same.
	* parser.c (cp_parser_tx_qualifier_opt): Same.
	* pt.c (print_candidates_1): Same.
	(check_template_variable): Same.
	(tsubst_default_argument): Same.
	(most_specialized_partial_spec): Same.
	* semantics.c (omp_reduction_lookup): Same.
	* tree.c (check_abi_tag_redeclaration): Same.
	* typeck.c (comptypes): Same.
	* typeck2.c (abstract_virtuals_error_sfinae): Same.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c15b8e4..002815e 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3457,26 +3457,26 @@ print_z_candidate (location_t loc, const char *msgstr,
     {
       cloc = loc;
       if (candidate->num_convs == 3)
-	inform (cloc, "%s%D(%T, %T, %T) <built-in>", msg, fn,
+	inform (cloc, "%<%s%D(%T, %T, %T) <built-in>%>", msg, fn,
 		candidate->convs[0]->type,
 		candidate->convs[1]->type,
 		candidate->convs[2]->type);
       else if (candidate->num_convs == 2)
-	inform (cloc, "%s%D(%T, %T) <built-in>", msg, fn,
+	inform (cloc, "%<%s%D(%T, %T) <built-in>%>", msg, fn,
 		candidate->convs[0]->type,
 		candidate->convs[1]->type);
       else
-	inform (cloc, "%s%D(%T) <built-in>", msg, fn,
+	inform (cloc, "%<%s%D(%T) <built-in>%>", msg, fn,
 		candidate->convs[0]->type);
     }
   else if (TYPE_P (fn))
-    inform (cloc, "%s%T <conversion>", msg, fn);
+    inform (cloc, "%s%qT <conversion>", msg, fn);
   else if (candidate->viable == -1)
-    inform (cloc, "%s%#D <near match>", msg, fn);
+    inform (cloc, "%s%#qD <near match>", msg, fn);
   else if (DECL_DELETED_FN (fn))
-    inform (cloc, "%s%#D <deleted>", msg, fn);
+    inform (cloc, "%s%#qD <deleted>", msg, fn);
   else
-    inform (cloc, "%s%#D", msg, fn);
+    inform (cloc, "%s%#qD", msg, fn);
   if (fn != candidate->fn)
     {
       cloc = location_of (candidate->fn);
@@ -4426,7 +4426,8 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain)
       if (complain & tf_error)
         /* It's no good looking for an overloaded operator() on a
            pointer-to-member-function.  */
-        error ("pointer-to-member function %E cannot be called without an object; consider using .* or ->*", obj);
+        error ("pointer-to-member function %qE cannot be called without "
+               "an object; consider using %<.*%> or %<->*%>", obj);
       return error_mark_node;
     }
 
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index e91b116..289700a 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2859,7 +2859,7 @@ diagnose_check_constraint (location_t loc, tree orig, tree cur, tree args)
     {
       if (elide_constraint_failure_p ())
         return;
-      inform (loc, "in the expansion of concept %qE %S", check, sub);
+      inform (loc, "in the expansion of concept %qE %qS", check, sub);
       cur = get_concept_definition (decl);
       tsubst_expr (cur, targs, tf_warning_or_error, NULL_TREE, false);
       return;
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 6f7e21c..cbc7c7d 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -3906,6 +3906,8 @@ mangle_decl (const tree decl)
 
       if (warn_abi)
 	{
+          const char fabi_version[] = "-fabi-version";
+
 	  if (flag_abi_compat_version != warn_abi_version
 	      || id2 == NULL_TREE)
 	    {
@@ -3921,15 +3923,15 @@ mangle_decl (const tree decl)
 		   && abi_version_at_least (warn_abi_version))
 	    warning_at (DECL_SOURCE_LOCATION (G.entity), OPT_Wabi,
 			"the mangled name of %qD changed between "
-			"-fabi-version=%d (%D) and -fabi-version=%d (%D)",
-			G.entity, warn_abi_version, id2,
-			save_ver, id);
+			"%<%s=%d%> (%qD) and %<%s=%d%> (%qD)",
+			G.entity, fabi_version, warn_abi_version, id2,
+			fabi_version, save_ver, id);
 	  else
 	    warning_at (DECL_SOURCE_LOCATION (G.entity), OPT_Wabi,
 			"the mangled name of %qD changes between "
-			"-fabi-version=%d (%D) and -fabi-version=%d (%D)",
-			G.entity, save_ver, id,
-			warn_abi_version, id2);
+			"%<%s=%d%> (%qD) and %<%s=%d%> (%qD)",
+			G.entity, fabi_version, save_ver, id,
+			fabi_version, warn_abi_version, id2);
 	}
 
       flag_abi_version = save_ver;
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 0c5df93..34d58a4 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -1554,7 +1554,7 @@ cp_binding_level_debug (cp_binding_level *scope, int line, const char *action)
 {
   const char *desc = cp_binding_level_descriptor (scope);
   if (scope->this_entity)
-    verbatim ("%s %s(%E) %p %d\n", action, desc,
+    verbatim ("%s %<%s(%E)%> %p %d\n", action, desc,
 	      scope->this_entity, (void *) scope, line);
   else
     verbatim ("%s %s %p %d\n", action, desc, (void *) scope, line);
@@ -3638,8 +3638,9 @@ set_decl_namespace (tree decl, tree scope, bool friendp)
 	  if (DECL_HIDDEN_FRIEND_P (found))
 	    {
 	      pedwarn (DECL_SOURCE_LOCATION (decl), 0,
-		       "%qD has not been declared within %D", decl, scope);
-	      inform (DECL_SOURCE_LOCATION (found), "only here as a friend");
+		       "%qD has not been declared within %qD", decl, scope);
+	      inform (DECL_SOURCE_LOCATION (found),
+		      "only here as a %<friend%>");
 	    }
 	  DECL_CONTEXT (decl) = DECL_CONTEXT (found);
 	  return;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 3917893..94d54d5 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -20370,7 +20370,7 @@ cp_parser_tx_qualifier_opt (cp_parser *parser)
 	      cp_lexer_consume_token (parser->lexer);
 	      if (!flag_tm)
 		{
-		  error ("%E requires %<-fgnu-tm%>", name);
+		  error ("%qE requires %<-fgnu-tm%>", name);
 		  return NULL_TREE;
 		}
 	      else
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index cf6ba6d..90ef69c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1943,14 +1943,14 @@ print_candidates_1 (tree fns, bool more, const char **str)
             if (!more && !OVL_NEXT (fns))
               {
                 inform (DECL_SOURCE_LOCATION (cand),
-			"candidate is: %#D", cand);
+			"candidate is: %#qD", cand);
                 continue;
               }
 
             *str = _("candidates are:");
             spaces = get_spaces (*str);
           }
-        inform (DECL_SOURCE_LOCATION (cand), "%s %#D", *str, cand);
+        inform (DECL_SOURCE_LOCATION (cand), "%s %#qD", *str, cand);
         *str = spaces ? spaces : *str;
       }
 
@@ -2583,7 +2583,8 @@ check_template_variable (tree decl)
   if (template_header_count > wanted)
     {
       bool warned = pedwarn (DECL_SOURCE_LOCATION (decl), 0,
-			     "too many template headers for %D (should be %d)",
+			     "too many template headers for %qD "
+                             "(should be %d)",
 			     decl, wanted);
       if (warned && CLASS_TYPE_P (ctx)
 	  && CLASSTYPE_TEMPLATE_SPECIALIZATION (ctx))
@@ -11978,7 +11979,7 @@ tsubst_default_argument (tree fn, tree type, tree arg, tsubst_flags_t complain)
   if (errorcount+sorrycount > errs
       && (complain & tf_warning_or_error))
     inform (input_location,
-	    "  when instantiating default argument for call to %D", fn);
+	    "  when instantiating default argument for call to %qD", fn);
 
   /* Make sure the default argument is reasonable.  */
   arg = check_default_argument (type, arg, complain);
@@ -21895,7 +21896,7 @@ most_specialized_partial_spec (tree target, tsubst_flags_t complain)
         {
 	  tree subst = build_tree_list (TREE_VALUE (t), TREE_PURPOSE (t));
           inform (DECL_SOURCE_LOCATION (TREE_VALUE (t)),
-		  "%s %#S", spaces ? spaces : str, subst);
+		  "%s %#qS", spaces ? spaces : str, subst);
           spaces = spaces ? spaces : get_spaces (str);
         }
       free (spaces);
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 0a69500..c3d9393 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5253,7 +5253,7 @@ omp_reduction_lookup (location_t loc, tree id, tree type, tree *baselinkp,
 	  error_at (loc, "user defined reduction lookup is ambiguous");
 	  FOR_EACH_VEC_ELT (ambiguous, idx, udr)
 	    {
-	      inform (DECL_SOURCE_LOCATION (udr), "%s %#D", str, udr);
+	      inform (DECL_SOURCE_LOCATION (udr), "%s %#qD", str, udr);
 	      if (idx == 0)
 		str = get_spaces (str);
 	    }
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 15b3ad9..ba1cb33 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -4027,7 +4027,7 @@ check_abi_tag_redeclaration (const_tree decl, const_tree old, const_tree new_)
 	  if (cp_tree_equal (str, ostr))
 	    goto found;
 	}
-      error ("redeclaration of %qD adds abi tag %E", decl, str);
+      error ("redeclaration of %qD adds abi tag %qE", decl, str);
       err = true;
     found:;
     }
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 7aee0d6..916cd49 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1430,14 +1430,14 @@ comptypes (tree t1, tree t2, int strict)
 	       canonical types were different. This is a failure of the
 	       canonical type propagation code.*/
 	    internal_error 
-	      ("canonical types differ for identical types %T and %T", 
+	      ("canonical types differ for identical types %qT and %qT", 
 	       t1, t2);
 	  else if (!result && TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2))
 	    /* Two types are structurally different, but the canonical
 	       types are the same. This means we were over-eager in
 	       assigning canonical types. */
 	    internal_error 
-	      ("same canonical type node for different types %T and %T",
+	      ("same canonical type node for different types %qT and %qT",
 	       t1, t2);
 	  
 	  return result;
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 1f0eb45..216736d 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -384,7 +384,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, abstract_class_use use,
       FOR_EACH_VEC_ELT (*pure, ix, fn)
 	if (! DECL_CLONED_FUNCTION_P (fn)
 	    || DECL_COMPLETE_DESTRUCTOR_P (fn))
-	  inform (DECL_SOURCE_LOCATION (fn), "\t%#D", fn);
+	  inform (DECL_SOURCE_LOCATION (fn), "\t%#qD", 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

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