From 7731b8e6f4bb44d2d1ec33072db65f2ccbf94121 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 21 Dec 2019 00:21:21 +0100 Subject: [PATCH] re PR c++/92965 ("note: 'x' is not public" emitted even when no error is emitted) PR c++/92965 * pt.c (invalid_nontype_parm_type_p): Call structural_type_p with explain=true only if emitting error. * g++.dg/cpp2a/nontype-class27.C: New test. From-SVN: r279684 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 10 ++++++---- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp2a/nontype-class27.C | 15 +++++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/nontype-class27.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4ccee73cc39..b72121c460b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2019-12-20 Jakub Jelinek + PR c++/92965 + * pt.c (invalid_nontype_parm_type_p): Call structural_type_p with + explain=true only if emitting error. + PR c++/92966 * method.c (early_check_defaulted_comparison): Don't set DECL_MAYBE_DELETED when returning false. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e9cf46c174a..dc01774d203 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -25838,11 +25838,13 @@ invalid_nontype_parm_type_p (tree type, tsubst_flags_t complain) return true; if (!structural_type_p (type)) { - auto_diagnostic_group d; if (complain & tf_error) - error ("%qT is not a valid type for a template non-type parameter " - "because it is not structural", type); - structural_type_p (type, true); + { + auto_diagnostic_group d; + error ("%qT is not a valid type for a template non-type " + "parameter because it is not structural", type); + structural_type_p (type, true); + } return true; } return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b357e1e8fcb..9913e8abd0a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-12-20 Jakub Jelinek + PR c++/92965 + * g++.dg/cpp2a/nontype-class27.C: New test. + PR c++/92966 * g++.dg/cpp2a/spaceship-eq8.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class27.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class27.C new file mode 100644 index 00000000000..23eae64c64b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class27.C @@ -0,0 +1,15 @@ +// PR c++/92965 +// { dg-do compile { target c++2a } } + +template +class TS { + int x; // { dg-bogus "is not public" } +public: + constexpr TS(int) {} +}; +TS(int) -> TS<1>; + +template void foo() {} +template void foo() {} + +void test() { foo<2>(); } -- 2.30.2