aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/pt.cc2
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/nontype-auto23.C22
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/nontype-auto24.C18
3 files changed, 42 insertions, 0 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 9a21467b..b6a450c 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -24706,6 +24706,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
/* Type INTEGER_CST can come from ordinary constant template args. */
case INTEGER_CST:
case REAL_CST:
+ if (!same_type_p (TREE_TYPE (parm), TREE_TYPE (arg)))
+ return unify_template_argument_mismatch (explain_p, parm, arg);
while (CONVERT_EXPR_P (arg))
arg = TREE_OPERAND (arg, 0);
diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto23.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto23.C
new file mode 100644
index 0000000..62a571e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto23.C
@@ -0,0 +1,22 @@
+// PR c++/99186
+// { dg-do compile { target c++17 } }
+
+template<int N, class T, class... U>
+struct tuple_impl : tuple_impl<N + 1, U...> { };
+
+template<int N, class T>
+struct tuple_impl<N, T> { };
+
+template<class T, class U>
+struct tuple : tuple_impl<0, T, U> { };
+
+template<class T, int N, class... U>
+void get(const tuple_impl<N, T, U...>&);
+
+template<auto> struct S;
+
+int main() {
+ tuple<S<1>,S<1U>> x;
+ get<S<1U>>(x);
+ get<S<1>>(x);
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype-auto24.C b/gcc/testsuite/g++.dg/cpp1z/nontype-auto24.C
new file mode 100644
index 0000000..52e4c13
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/nontype-auto24.C
@@ -0,0 +1,18 @@
+// PR c++/104867
+// { dg-do compile { target c++17 } }
+
+enum class Foo { A1 };
+
+enum class Bar { B1 };
+
+template<auto EnumVal> struct enum_;
+
+template<class...> struct list { };
+
+template<class V> void f(list<enum_<Bar::B1>, V>);
+
+struct enum_type_map : list<enum_<Foo::A1>, int>, list<enum_<Bar::B1>, double> { };
+
+int main() {
+ f(enum_type_map());
+}