aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/concepts
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-04-29 09:04:58 -0400
committerPatrick Palka <ppalka@redhat.com>2020-04-29 09:06:24 -0400
commita7201a085cc30f89944931d8fb1d7936f02a169f (patch)
tree9750ea9e5fb0d2340797252b21442d7029fc973a /gcc/testsuite/g++.dg/concepts
parent3bce790414afaaba10e03f7bb41e4aa3279694f5 (diff)
downloadgcc-a7201a085cc30f89944931d8fb1d7936f02a169f.zip
gcc-a7201a085cc30f89944931d8fb1d7936f02a169f.tar.gz
gcc-a7201a085cc30f89944931d8fb1d7936f02a169f.tar.bz2
c++: Nondeterministic concepts diagnostics [PR94830]
This patch makes the order in which template parameters appear in the TREE_LIST returned by find_template_parameters deterministic between runs. The current nondeterminism is semantically harmless, but it has the undesirable effect of causing some concepts diagnostics which print a constraint's parameter mapping via pp_cxx_parameter_mapping to also be nondeterministic, as in the testcases below. gcc/cp/ChangeLog: PR c++/94830 * pt.c (find_template_parameter_info::parm_list): New field. (keep_template_parm): Use the new field to build up the parameter list here instead of ... (find_template_parameters): ... here. Return ftpi.parm_list. gcc/testsuite/ChangeLog: PR c++/94830 * g++.dg/concepts/diagnostics12.C: Clarify the dg-message now that the corresponding diagnostic is deterministic. * g++.dg/concepts/diagnostics13.C: New test.
Diffstat (limited to 'gcc/testsuite/g++.dg/concepts')
-rw-r--r--gcc/testsuite/g++.dg/concepts/diagnostic12.C2
-rw-r--r--gcc/testsuite/g++.dg/concepts/diagnostic13.C14
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic12.C b/gcc/testsuite/g++.dg/concepts/diagnostic12.C
index a757342..548ba9c 100644
--- a/gcc/testsuite/g++.dg/concepts/diagnostic12.C
+++ b/gcc/testsuite/g++.dg/concepts/diagnostic12.C
@@ -3,7 +3,7 @@
template<typename T, typename... Args>
concept c1 = requires (T t, Args... args) { *t; };
-// { dg-message "in requirements with .T t., .Args ... args. .with.* Args = \{\}" "" { target *-*-* } .-1 }
+// { dg-message "in requirements with .T t., .Args ... args. .with Args = \{\}; T = int" "" { target *-*-* } .-1 }
static_assert(c1<int>); // { dg-error "failed" }
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic13.C b/gcc/testsuite/g++.dg/concepts/diagnostic13.C
new file mode 100644
index 0000000..accd8a6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/diagnostic13.C
@@ -0,0 +1,14 @@
+// PR c++/94830
+// { dg-do compile { target concepts } }
+
+template<typename T, typename R>
+ concept c = __is_same(T, R); // { dg-message "with T = int; R = char" }
+
+template<typename T, typename R>
+ requires c<T,R>
+void foo() { }
+
+void bar()
+{
+ foo<int, char>(); // { dg-error "unsatisfied constraints" }
+}