aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2020-07-08 01:11:44 -0400
committerJason Merrill <jason@redhat.com>2020-07-20 17:53:43 -0400
commitd0ffe9d5dc83092e6de996483c4c08b439a316c0 (patch)
tree57564f18d4d629bfd20083c216e2e3f1997a514a /gcc/cp
parent87891d5eafe8d1de90b9d9b056eca81c508d1c77 (diff)
downloadgcc-d0ffe9d5dc83092e6de996483c4c08b439a316c0.zip
gcc-d0ffe9d5dc83092e6de996483c4c08b439a316c0.tar.gz
gcc-d0ffe9d5dc83092e6de996483c4c08b439a316c0.tar.bz2
c++: Aggregate CTAD and string constants.
In CWG discussion, it was suggested that deduction from a string literal should be to reference-to-const, so that we deduce 'char' rather than 'const char' for T. gcc/cp/ChangeLog: * pt.c (collect_ctor_idx_types): Add 'const' when deducing from a string constant. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/class-deduction-aggr7.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/pt.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index defc2a9..5f43e9c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -28357,8 +28357,13 @@ collect_ctor_idx_types (tree ctor, tree list, tree elt = NULL_TREE)
if (TREE_CODE (ftype) == ARRAY_TYPE
&& (BRACE_ENCLOSED_INITIALIZER_P (val)
|| TREE_CODE (val) == STRING_CST))
- ftype = (cp_build_reference_type
- (ftype, BRACE_ENCLOSED_INITIALIZER_P (val)));
+ {
+ if (TREE_CODE (val) == STRING_CST)
+ ftype = cp_build_qualified_type
+ (ftype, cp_type_quals (ftype) | TYPE_QUAL_CONST);
+ ftype = (cp_build_reference_type
+ (ftype, BRACE_ENCLOSED_INITIALIZER_P (val)));
+ }
list = tree_cons (arg, ftype, list);
}