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?

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.

        * g++.dg/lookup/strong-using2.C: New test.

diff --git gcc/cp/name-lookup.c gcc/cp/name-lookup.c
index f7952eebe0c..fe3d5414e7c 100644
--- gcc/cp/name-lookup.c
+++ gcc/cp/name-lookup.c
@@ -7258,8 +7258,8 @@ 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");
          }
diff --git gcc/testsuite/g++.dg/lookup/strong-using2.C 
gcc/testsuite/g++.dg/lookup/strong-using2.C
new file mode 100644
index 00000000000..0c497245df0
--- /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" }
+}

Reply via email to