From bcf587f0d5f1592e4678e4cdd52ad834ec8b83ca Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 28 Feb 2018 18:56:36 +0000 Subject: [PATCH] PR c++/83871 PR c++/83503 * pt.c (INCLUDE_STRING): Remove define. (warn_spec_missing_attributes): Use pretty_printer instead of std::string. Fix up inform call so that the list of attributes is in %s argument. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258079 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 9 +++++++++ gcc/cp/pt.c | 27 +++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 457bfc2a4c7..5d8a6dba227 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2018-02-28 Jakub Jelinek + + PR c++/83871 + PR c++/83503 + * pt.c (INCLUDE_STRING): Remove define. + (warn_spec_missing_attributes): Use pretty_printer instead of + std::string. Fix up inform call so that the list of attributes + is in %s argument. + 2018-02-28 Martin Sebor PR testsuite/84617 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 23eb2db1a5d..507675b4aae 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -25,7 +25,6 @@ along with GCC; see the file COPYING3. If not see file that contains only the method templates and "just win". */ #include "config.h" -#define INCLUDE_STRING #include "system.h" #include "coretypes.h" #include "cp-tree.h" @@ -2681,7 +2680,7 @@ warn_spec_missing_attributes (tree tmpl, tree spec, tree attrlist) template is declared with that the specialization is not, in case it's not apparent from the most recent declaration of the primary. */ unsigned nattrs = 0; - std::string str; + pretty_printer str; for (unsigned i = 0; i != sizeof blacklist / sizeof *blacklist; ++i) { @@ -2695,11 +2694,11 @@ warn_spec_missing_attributes (tree tmpl, tree spec, tree attrlist) if (lookup_attribute (blacklist[i], spec_attrs[k])) break; - if (str.size ()) - str += ", "; - str += "%<"; - str += blacklist[i]; - str += "%>"; + if (nattrs) + pp_string (&str, ", "); + pp_begin_quote (&str, pp_show_color (global_dc->printer)); + pp_string (&str, blacklist[i]); + pp_end_quote (&str, pp_show_color (global_dc->printer)); ++nattrs; } } @@ -2711,15 +2710,11 @@ warn_spec_missing_attributes (tree tmpl, tree spec, tree attrlist) if (warning_at (DECL_SOURCE_LOCATION (spec), OPT_Wmissing_attributes, "explicit specialization %q#D may be missing attributes", spec)) - { - if (nattrs > 1) - str = G_("missing primary template attributes ") + str; - else - str = G_("missing primary template attribute ") + str; - - inform (DECL_SOURCE_LOCATION (tmpl), str.c_str ()); - } - + inform (DECL_SOURCE_LOCATION (tmpl), + nattrs > 1 + ? G_("missing primary template attributes %s") + : G_("missing primary template attribute %s"), + pp_formatted_text (&str)); } /* Check to see if the function just declared, as indicated in -- 2.11.4.GIT