From: Jonathan Wakely Date: Wed, 7 Jun 2017 11:34:36 +0000 (+0100) Subject: PR c++/80990 use cv-qualifiers in class template argument deduction X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83059741a0a58b6cccb105522bf7f07813a55c23;p=gcc.git PR c++/80990 use cv-qualifiers in class template argument deduction 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8375ceedd49..e47c4299748 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-06-07 Jonathan Wakely + + PR c++/80990 + * pt.c (do_class_deduction): Build qualified type. + 2017-06-06 Nathan Sidwell * name-lookup.c (suggest_alternatives_for): Use qualified lookup diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a04f2e0a762..ada94bd65ed 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 990e10ac327..e5a4dbd229b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-06-07 Jonathan Wakely + + PR c++/80990 + * g++.dg/cpp1z/class-deduction39.C: New. + 2017-06-07 Marek Polacek 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 index 00000000000..98a3664f5b2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction39.C @@ -0,0 +1,15 @@ +// { dg-options -std=c++1z } + +template struct A { }; + +A a; +const A c = a; +volatile A v = a; +const volatile A cv = a; + +template struct same; +template struct same {}; + +same> s1; +same> s2; +same> s3;