diff options
-rw-r--r-- | gcc/cp/pt.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr7.C | 14 |
2 files changed, 21 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); } diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr7.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr7.C new file mode 100644 index 0000000..3505a8c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-aggr7.C @@ -0,0 +1,14 @@ +// { dg-do compile { target c++20 } } + +template <class T, int N> +struct A +{ + T ar[N]; +}; + +A a = { "foo" }; + +template<class, class> struct same; +template<class T> struct same<T,T> {}; +same<decltype (a.ar), char[4]> s; + |