class.c (resolve_address_of_overloaded_function): Don't emit an inform if the matchin...
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 16 Jul 2018 17:36:43 +0000 (17:36 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 16 Jul 2018 17:36:43 +0000 (17:36 +0000)
/cp
2018-07-16  Paolo Carlini  <paolo.carlini@oracle.com>

* class.c (resolve_address_of_overloaded_function): Don't emit an
inform if the matching permerror returns false.
* pt.c (check_specialization_namespace): Likewise.

/testsuite
2018-07-16  Paolo Carlini  <paolo.carlini@oracle.com>

* g++.dg/template/spec40.C: New.
* g++.dg/parse/ptrmem8.C: Likewise.

From-SVN: r262740

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/ptrmem8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/spec40.C [new file with mode: 0644]

index a8bd6b2f7178d27da4802466e59cdcb3e9c365a5..6c1384a074f0ee9ba8491b3afe7e2dd4ac7313e3 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-16  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * class.c (resolve_address_of_overloaded_function): Don't emit an
+       inform if the matching permerror returns false.
+       * pt.c (check_specialization_namespace): Likewise.
+
 2018-07-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/3698
index 8d8339c9951f66530fd2af3cc5ea5a3d3af35906..3d155a55500f6e1cd046b5e4d1460cd6bf638c1f 100644 (file)
@@ -7919,10 +7919,11 @@ resolve_address_of_overloaded_function (tree target_type,
       if (!(complain & tf_error))
        return error_mark_node;
 
-      permerror (input_location, "assuming pointer to member %qD", fn);
-      if (!explained)
+      if (permerror (input_location, "assuming pointer to member %qD", fn)
+         && !explained)
        {
-         inform (input_location, "(a pointer to member can only be formed with %<&%E%>)", fn);
+         inform (input_location, "(a pointer to member can only be "
+                 "formed with %<&%E%>)", fn);
          explained = 1;
        }
     }
index 9de9f500e2a81a4b840144d6c3babdc42ac00e78..b49dce08206859dd8294b158a7cb62e08c0a867d 100644 (file)
@@ -800,10 +800,10 @@ check_specialization_namespace (tree tmpl)
     return true;
   else
     {
-      permerror (input_location,
-                "specialization of %qD in different namespace", tmpl);
-      inform (DECL_SOURCE_LOCATION (tmpl),
-             "  from definition of %q#D", tmpl);
+      if (permerror (input_location,
+                    "specialization of %qD in different namespace", tmpl))
+       inform (DECL_SOURCE_LOCATION (tmpl),
+               "  from definition of %q#D", tmpl);
       return false;
     }
 }
index de2d36980175d1b86ad68113400bc4967475c9ea..4abf54158720469e61c35ba2049db3b5cf25b9b0 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-16  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * g++.dg/template/spec40.C: New.
+       * g++.dg/parse/ptrmem8.C: Likewise.
+
 2018-07-16  Ilya Leoshkevich  <iii@linux.ibm.com>
 
        * gcc.target/s390/mnop-mcount-m31-fpic.c: New testcase.
diff --git a/gcc/testsuite/g++.dg/parse/ptrmem8.C b/gcc/testsuite/g++.dg/parse/ptrmem8.C
new file mode 100644 (file)
index 0000000..00be3df
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-options "-fpermissive -w" }
+
+struct A
+{
+  template<int> void foo()
+  {
+    void (A::* fp)();
+    fp = A::foo<0>;  // { dg-bogus "pointer to member" }
+  }
+};
+
+void bar()
+{
+  A().foo<0>();
+}
diff --git a/gcc/testsuite/g++.dg/template/spec40.C b/gcc/testsuite/g++.dg/template/spec40.C
new file mode 100644 (file)
index 0000000..4e29944
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-options "-fpermissive -w" }
+
+namespace N {
+  template <typename T>
+  struct S {
+    void f() {}  // { dg-bogus "from definition" }
+  };
+}
+
+namespace K {
+  template <> void N::S<char>::f() {}
+}