On Mon, May 20, 2019 at 01:44:47PM -0400, Jason Merrill wrote: > On 5/20/19 11:56 AM, Marek Polacek wrote: > > This patch fixes a naked inform call that can be seen with -w. > > > > While at it, I added missing quotes; I'm surprisesd this wasn't fixed by the > > recent patch Martin submitted. > > > > Bootstrapped/regtested on x86_64-linux, ok for trunk? > > OK. We might also change "may" to "can" in the inform.
Done in the following, thanks. Bootstrapped/regtested on x86_64-linux, applying to trunk. 2019-05-20 Marek Polacek <pola...@redhat.com> * name-lookup.c (finish_using_directive): Don't issue inform() if the warning didn't trigger. Add quoting. Tweak the inform message. * g++.dg/lookup/strong-using2.C: New test. diff --git gcc/cp/name-lookup.c gcc/cp/name-lookup.c index f7952eebe0c..476ba509231 100644 --- gcc/cp/name-lookup.c +++ gcc/cp/name-lookup.c @@ -7258,10 +7258,10 @@ finish_using_directive (tree target, tree attribs) if (current_binding_level->kind == sk_namespace && is_attribute_p ("strong", name)) { - warning (0, "strong using directive no longer supported"); - if (CP_DECL_CONTEXT (target) == current_namespace) + if (warning (0, "%<strong%> using directive no longer supported") + && CP_DECL_CONTEXT (target) == current_namespace) inform (DECL_SOURCE_LOCATION (target), - "you may use an inline namespace instead"); + "you can use an inline namespace instead"); } else warning (OPT_Wattributes, "%qD attribute directive ignored", name); diff --git gcc/testsuite/g++.dg/lookup/strong-using2.C gcc/testsuite/g++.dg/lookup/strong-using2.C new file mode 100644 index 00000000000..17284949645 --- /dev/null +++ gcc/testsuite/g++.dg/lookup/strong-using2.C @@ -0,0 +1,11 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-w" } + +namespace A +{ + namespace B // { dg-bogus "inline namespace" } + { + } + + using namespace B __attribute__ ((strong)); // { dg-bogus "no longer supported" } +}