PR c++/80990 use cv-qualifiers in class template argument deduction
authorJonathan Wakely <jwakely@redhat.com>
Wed, 7 Jun 2017 11:34:36 +0000 (12:34 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 7 Jun 2017 11:34:36 +0000 (12:34 +0100)
gcc/cp:

PR c++/80990
* pt.c (do_class_deduction): Build qualified type.

gcc/testsuite:

PR c++/80990
* g++.dg/cpp1z/class-deduction39.C: New.

From-SVN: r248966

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/class-deduction39.C [new file with mode: 0644]

index 8375ceedd4961184f5ad16c7312b2b08969a9de6..e47c4299748186563e0b699172d7b69dd936d3b7 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-07  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR c++/80990
+       * pt.c (do_class_deduction): Build qualified type.
+
 2017-06-06  Nathan Sidwell  <nathan@acm.org>
 
        * name-lookup.c (suggest_alternatives_for): Use qualified lookup
index a04f2e0a762cb193f5ee44245d31a77b17c76d2a..ada94bd65ed14ae16569cdfe5d9b12dc1c6ca2be 100644 (file)
@@ -25367,7 +25367,7 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
   --cp_unevaluated_operand;
   release_tree_vector (args);
 
-  return TREE_TYPE (t);
+  return cp_build_qualified_type (TREE_TYPE (t), cp_type_quals (ptype));
 }
 
 /* Replace occurrences of 'auto' in TYPE with the appropriate type deduced
index 990e10ac327993629dd00a04b788723586daf6bd..e5a4dbd229ba89620cbddf09b216c4df76816b07 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-07  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR c++/80990
+       * g++.dg/cpp1z/class-deduction39.C: New.
+
 2017-06-07  Marek Polacek  <polacek@redhat.com>
 
        PR sanitizer/80932
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction39.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction39.C
new file mode 100644 (file)
index 0000000..98a3664
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-options -std=c++1z }
+
+template <class T> struct A { };
+
+A<int> a;
+const A c = a;
+volatile A v = a;
+const volatile A cv = a;
+
+template <class,class> struct same;
+template <class T> struct same<T,T> {};
+
+same<decltype(c), const A<int>> s1;
+same<decltype(v), volatile A<int>> s2;
+same<decltype(cv), const volatile A<int>> s3;