From 99422caabd1d46992de8e373f3131efe84e03bcc Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 16 Jul 2018 17:36:43 +0000 Subject: [PATCH] class.c (resolve_address_of_overloaded_function): Don't emit an inform if the matching permerror returns false. /cp 2018-07-16 Paolo Carlini * 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 * g++.dg/template/spec40.C: New. * g++.dg/parse/ptrmem8.C: Likewise. From-SVN: r262740 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/class.c | 7 ++++--- gcc/cp/pt.c | 8 ++++---- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/ptrmem8.C | 15 +++++++++++++++ gcc/testsuite/g++.dg/template/spec40.C | 12 ++++++++++++ 6 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/ptrmem8.C create mode 100644 gcc/testsuite/g++.dg/template/spec40.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a8bd6b2f717..6c1384a074f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-07-16 Paolo Carlini + + * 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 PR c++/3698 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 8d8339c9951..3d155a55500 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -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; } } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 9de9f500e2a..b49dce08206 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index de2d3698017..4abf5415872 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-16 Paolo Carlini + + * g++.dg/template/spec40.C: New. + * g++.dg/parse/ptrmem8.C: Likewise. + 2018-07-16 Ilya Leoshkevich * 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 index 00000000000..00be3df37bb --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/ptrmem8.C @@ -0,0 +1,15 @@ +// { dg-options "-fpermissive -w" } + +struct A +{ + template 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 index 00000000000..4e29944514f --- /dev/null +++ b/gcc/testsuite/g++.dg/template/spec40.C @@ -0,0 +1,12 @@ +// { dg-options "-fpermissive -w" } + +namespace N { + template + struct S { + void f() {} // { dg-bogus "from definition" } + }; +} + +namespace K { + template <> void N::S::f() {} +} -- 2.30.2