]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/c-common: Fix convert_vector_to_array_for_subscript for qualified vector types...
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 20 Feb 2024 21:38:28 +0000 (13:38 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 8 May 2024 01:21:16 +0000 (18:21 -0700)
commit315f8a474eb1a9b2d213aa650bdb132c78546264
tree399d7542a0173700dcdd6deb8ad93274f88892cd
parentef10d72003f87ab2d88c852da75d407c0c990e99
c++/c-common: Fix convert_vector_to_array_for_subscript for qualified vector types [PR89224]

After r7-987-gf17a223de829cb, the access for the elements of a vector type would lose the qualifiers.
So if we had `constvector[0]`, the type of the element of the array would not have const on it.
This was due to a missing build_qualified_type for the inner type of the vector when building the array type.
We need to add back the call to build_qualified_type and now the access has the correct qualifiers. So the
overloads and even if it is a lvalue or rvalue is correctly done.

Note we correctly now reject the testcase gcc.dg/pr83415.c which was incorrectly accepted after r7-987-gf17a223de829cb.

Built and tested for aarch64-linux-gnu.

PR c++/89224

gcc/c-family/ChangeLog:

* c-common.cc (convert_vector_to_array_for_subscript): Call build_qualified_type
for the inner type.

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_array_reference): Compare main variants
for the vector/array types instead of the types directly.

gcc/testsuite/ChangeLog:

* g++.dg/torture/vector-subaccess-1.C: New test.
* gcc.dg/pr83415.c: Change warning to error.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
(cherry picked from commit 4421d35167b3083e0f2e4c84c91fded09a30cf22)
gcc/c-family/c-common.cc
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/torture/vector-subaccess-1.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr83415.c