From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id B9A923858D1E for ; Tue, 30 Apr 2024 19:04:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9A923858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B9A923858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::631 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714503900; cv=none; b=cNssobZvZNODb4CgFNi04jeW5ZDWyUN2C5jBQS3t0z3gETlZa/dz3j0WJYtso5SxYCylYy+0HZ9NpmDGuNBcp7sJH/HQ9JqZZwQ4yXPVlxEwKue3je7Q3kFoLnrL9bXE3Zy2YfGj7+6FO3wZ/4utCXKWckf6jiTKopP0VmJLLQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714503900; c=relaxed/simple; bh=tv2JQeUjkk7a47M9DhsPIEcSV9SmWbRBr0F5Q9AahlM=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=xQsGb/hDG4ZTsEBDR7i29lH3tEwTbgN32plIPLNCoq399uGwXouR7ARHO8iravFuY6lZKcnEGcOy3FeeeHTcXUB9ii0/Di4/24e3ZGssyMF34EF5UthNAmXrb84SoMM293mycjrO1bOiRrsUDKsUI3xuK38dhdN0tqCxss2R0PE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1e4266673bbso55196305ad.2 for ; Tue, 30 Apr 2024 12:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714503895; x=1715108695; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rp101ZS7MPhVjE9goax14IUlvpnyU5Uk83eA3dL+65Q=; b=Mz3Q8gyE82a9eftWHhaFFYR6Cz1gVyxS+ZdK4Pky8Y0hLNi7L5oacxKLZi60o+G6Sk xIaV50+fFXhO5rR814WA6LBMaOrravZsbCHMBT13H+B5BuuNAJWrffmmk0E/BenoFviU RPoTAaEUDIezNkfbA6BJBGO3SyTXOoxCzCmbAxuLOrFILEePML1yVGhVKj21n11zBlJw qizId/N4BdNjQeHNx4ppZBj+6+dRdeRBe4pw3V3lMUtyMmAbln3uzlIiGrOyQldgZsbx lbY87fVHLcFfx3Ujbrsvd+YXlZCV9pm5/76XOWkzGP3oB20BpzN7pNS+ulUFaEQqFT00 7gXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714503895; x=1715108695; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rp101ZS7MPhVjE9goax14IUlvpnyU5Uk83eA3dL+65Q=; b=o3UFj9sJb07Xj179CImQ8WJoZpfo9dVmUF5IzjLlkxo970P+oRHp13w8eI7Zb0rnM0 3X3Q+fGsksofhjxa0w3Bc4SzyFbDGB+mrMFO7myfsWkqIj3lxqoYlTLndqVgjMiJ512O OOGJnnB7IqyFxOWoX9sm2p/BBqXzOEBO9DOBvINf5NXaHpsMizh15Bk33sYMh8GcrmGZ t+hLd4iWLqWSF0j97DzTTr2LKSIkwnK5teQknyEdVvQCzPS++VkDax9614p7runvnte2 djq9KnuqQkDI3U+v5fqTXFAFBUznStCPRqDY2G10P3M8L4oGnUhfBTjAL/QVkALkTkXr mWYQ== X-Forwarded-Encrypted: i=1; AJvYcCXVFCKa0OfTQeWVH6zaX8/cpEVso6KgymXZRXs4HVKlGSVWY1GSFWJm5DMwqKJO4iv7c5m/gbRjuDAnYUEsGLnX1jDh3BShNA== X-Gm-Message-State: AOJu0Yw3p/LcgmCpH0Mb+4IyTpOfWWeCs5YqYwDZsZfcLRWkUaMg0FBi 3QVbZ4aElxd8bi0Ox+1ML4lxfv3uaxHhvhJt+5wDSTaBtvFUkiVzRCYui3zDqBb5A+ydCrVkZo4 AgVS3EA47zJEncAGU6CnDpWUc32A= X-Google-Smtp-Source: AGHT+IG5rAaspqk8yCFyArTK8FF0jc62V3HNEIQnmyz8pUx7QgU2Gpf7SOG67Mvx0eiUrJmXM0XYXlmu/xIlbSnhPeY= X-Received: by 2002:a17:902:6545:b0:1ec:4054:9f47 with SMTP id d5-20020a170902654500b001ec40549f47mr356761pln.26.1714503895290; Tue, 30 Apr 2024 12:04:55 -0700 (PDT) MIME-Version: 1.0 References: <20240221030627.2311446-1-quic_apinski@quicinc.com> In-Reply-To: From: Andrew Pinski Date: Tue, 30 Apr 2024 12:04:42 -0700 Message-ID: Subject: Re: [PATCH] c++/c-common: Fix convert_vector_to_array_for_subscript for qualified vector types [PR89224] To: Jason Merrill Cc: Andrew Pinski , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Apr 30, 2024 at 11:54=E2=80=AFAM Jason Merrill w= rote: > > On 2/20/24 19:06, Andrew Pinski wrote: > > After r7-987-gf17a223de829cb, the access for the elements of a vector t= ype would lose the qualifiers. > > So if we had `constvector[0]`, the type of the element of the array wou= ld not have const on it. > > This was due to a missing build_qualified_type for the inner type of th= e 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 in= correctly 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 > > --- > > gcc/c-family/c-common.cc | 7 +++++- > > gcc/cp/constexpr.cc | 3 ++- > > .../g++.dg/torture/vector-subaccess-1.C | 23 ++++++++++++++++++= + > > gcc/testsuite/gcc.dg/pr83415.c | 2 +- > > 4 files changed, 32 insertions(+), 3 deletions(-) > > create mode 100644 gcc/testsuite/g++.dg/torture/vector-subaccess-1.C > > > > diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc > > index e15eff698df..884dd9043f9 100644 > > --- a/gcc/c-family/c-common.cc > > +++ b/gcc/c-family/c-common.cc > > @@ -8936,6 +8936,7 @@ convert_vector_to_array_for_subscript (location_t= loc, > > if (gnu_vector_type_p (TREE_TYPE (*vecp))) > > { > > tree type =3D TREE_TYPE (*vecp); > > + tree newitype; > > > > ret =3D !lvalue_p (*vecp); > > > > @@ -8950,8 +8951,12 @@ convert_vector_to_array_for_subscript (location_= t loc, > > for function parameters. */ > > c_common_mark_addressable_vec (*vecp); > > > > + /* Make sure qualifiers are copied from the vector type to the n= ew element > > + of the array type. */ > > + newitype =3D build_qualified_type (TREE_TYPE (type), TYPE_QUALS = (type)); > > + > > *vecp =3D build1 (VIEW_CONVERT_EXPR, > > - build_array_type_nelts (TREE_TYPE (type), > > + build_array_type_nelts (newitype, > > TYPE_VECTOR_SUBPARTS (type)= ), > > *vecp); > > } > > diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc > > index fa346fe01c9..1fe91d16e8e 100644 > > --- a/gcc/cp/constexpr.cc > > +++ b/gcc/cp/constexpr.cc > > @@ -4421,7 +4421,8 @@ cxx_eval_array_reference (const constexpr_ctx *ct= x, tree t, > > if (!lval > > && TREE_CODE (ary) =3D=3D VIEW_CONVERT_EXPR > > && VECTOR_TYPE_P (TREE_TYPE (TREE_OPERAND (ary, 0))) > > - && TREE_TYPE (t) =3D=3D TREE_TYPE (TREE_TYPE (TREE_OPERAND (ary,= 0)))) > > + && TYPE_MAIN_VARIANT (TREE_TYPE (t)) > > + =3D=3D TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (TREE_OPERAND (a= ry, 0))))) > > Please add parens around the =3D=3D expression so the formatting is stabl= e. ok, I will make that change. > > With that change, OK for trunk and release branches. For the GCC 14 branch, should I wait until after the release due to RC1 going out today and I am not sure this counts as a show stopper issue. Thanks, Andrew > > Jason >