re PR c++/92965 ("note: 'x' is not public" emitted even when no error is emitted)
authorJakub Jelinek <jakub@redhat.com>
Fri, 20 Dec 2019 23:21:21 +0000 (00:21 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 20 Dec 2019 23:21:21 +0000 (00:21 +0100)
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
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp2a/nontype-class27.C [new file with mode: 0644]

index 4ccee73cc39aa957a15897fdd08fc505ce9d8910..b72121c460b011901b614d049f91fc709abfaccb 100644 (file)
@@ -1,5 +1,9 @@
 2019-12-20  Jakub Jelinek  <jakub@redhat.com>
 
+       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.
index e9cf46c174a941d97718cee414ce4718fa340f6f..dc01774d203644a28dd23d90bfdd9ce4ed0f2f06 100644 (file)
@@ -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;
index b357e1e8fcbe4799f9ee244530809f43809eb630..9913e8abd0a8d9f12ec1ed2d3aac5c7428093d26 100644 (file)
@@ -1,5 +1,8 @@
 2019-12-20  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..23eae64
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/92965
+// { dg-do compile { target c++2a } }
+
+template<int>
+class TS {
+  int x;       // { dg-bogus "is not public" }
+public:
+  constexpr TS(int) {}
+};
+TS(int) -> TS<1>;
+
+template<TS> void foo() {}
+template<int> void foo() {}
+
+void test() { foo<2>(); }