diff options
author | Jason Merrill <jason@redhat.com> | 2024-02-05 13:54:22 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2024-02-05 16:32:15 -0500 |
commit | c7e8381748f78335e9fef23f363b6a9e4463ce7e (patch) | |
tree | 3d7efefb78d0e2b044eac99a3c157166882bd810 /gcc/cp/tree.cc | |
parent | f1412546ac8999b7f6eeeee8cf967ce3f31794c2 (diff) | |
download | gcc-c7e8381748f78335e9fef23f363b6a9e4463ce7e.zip gcc-c7e8381748f78335e9fef23f363b6a9e4463ce7e.tar.gz gcc-c7e8381748f78335e9fef23f363b6a9e4463ce7e.tar.bz2 |
c++: prvalue of array type [PR111286]
Here we want to build a prvalue array to bind to the T reference, but we
were wrongly trying to strip cv-quals from the array prvalue, which should
be treated the same as a class prvalue.
PR c++/111286
gcc/cp/ChangeLog:
* tree.cc (rvalue): Don't drop cv-quals from an array.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist-array22.C: New test.
Diffstat (limited to 'gcc/cp/tree.cc')
-rw-r--r-- | gcc/cp/tree.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc index 5c8c05d..50dc345 100644 --- a/gcc/cp/tree.cc +++ b/gcc/cp/tree.cc @@ -977,11 +977,12 @@ rvalue (tree expr) expr = mark_rvalue_use (expr); - /* [basic.lval] - - Non-class rvalues always have cv-unqualified types. */ + /* [expr.type]: "If a prvalue initially has the type "cv T", where T is a + cv-unqualified non-class, non-array type, the type of the expression is + adjusted to T prior to any further analysis. */ type = TREE_TYPE (expr); - if (!CLASS_TYPE_P (type) && cv_qualified_p (type)) + if (!CLASS_TYPE_P (type) && TREE_CODE (type) != ARRAY_TYPE + && cv_qualified_p (type)) type = cv_unqualified (type); /* We need to do this for rvalue refs as well to get the right answer |