From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 233063838008; Tue, 10 May 2022 08:25:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 233063838008 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10699] c++: Fix up __builtin_convertvector parsing X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 125234a3b78138e22112bb3f207df987817b6818 X-Git-Newrev: 91cc882245d7d93876d34f4d4c2e425acf48c8bb Message-Id: <20220510082536.233063838008@sourceware.org> Date: Tue, 10 May 2022 08:25:36 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 08:25:36 -0000 https://gcc.gnu.org/g:91cc882245d7d93876d34f4d4c2e425acf48c8bb commit r10-10699-g91cc882245d7d93876d34f4d4c2e425acf48c8bb Author: Jakub Jelinek Date: Sat Mar 26 08:11:58 2022 +0100 c++: Fix up __builtin_convertvector parsing Jonathan reported on IRC that we don't parse __builtin_bit_cast (type, val).field etc. The problem is that for these 2 builtins we return from cp_parser_postfix_expression instead of setting postfix_expression to the cp_build_* value and falling through into the postfix regression suffix handling loop. 2022-03-26 Jakub Jelinek * parser.c (cp_parser_postfix_expression) : Don't return cp_build_vec_convert result right away, instead set postfix_expression to it and break. * c-c++-common/builtin-convertvector-3.c: New test. (cherry picked from commit 1806829e08f14e4cacacec43d7845cc2dad2ddc8) Diff: --- gcc/cp/parser.c | 6 ++++-- gcc/testsuite/c-c++-common/builtin-convertvector-3.c | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f48c856fa94..61f2af34688 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -7162,8 +7162,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p, } /* Look for the closing `)'. */ parens.require_close (parser); - return cp_build_vec_convert (expression, type_location, type, - tf_warning_or_error); + postfix_expression + = cp_build_vec_convert (expression, type_location, type, + tf_warning_or_error); + break; } default: diff --git a/gcc/testsuite/c-c++-common/builtin-convertvector-3.c b/gcc/testsuite/c-c++-common/builtin-convertvector-3.c new file mode 100644 index 00000000000..882cd551ef8 --- /dev/null +++ b/gcc/testsuite/c-c++-common/builtin-convertvector-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +typedef int v4si __attribute__((vector_size (4 * sizeof (int)))); +typedef double v4df __attribute__((vector_size (4 * sizeof (double)))); +double +foo (void) +{ + v4si a = { 1, 2, 3, 4 }; + return __builtin_convertvector (a, v4df)[1]; +}