From patchwork Fri Jan 10 09:45:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 104462 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B99B23858415 for ; Fri, 10 Jan 2025 09:48:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 605053858C3A for ; Fri, 10 Jan 2025 09:45:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 605053858C3A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 605053858C3A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736502329; cv=none; b=hfe3dI4rsMITxiIoYUrf/+uXA/P7pMo6WtU+AIxsDtF7bTvVl2pCVCvrpeG7ngkr7jW86nWwXx+Oju2Ql3Fy1a/YanboATqOcwnfhtFu8KPRb9l21IWK0kOYVUD9tFjT9XheVJhPIu2yQTxAuhpszsalNu9G7QBQthy3aNWOoWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736502329; c=relaxed/simple; bh=5htxhM6uxhIcH5/mKjw24ais4s8A3wIwhymEfCK+eKA=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=ppBEthLY8mwbtAWISPLt+Hjn9H28yUr94tUERf6/SnPJY1sWRywEmim7323/MLbXRdk+5cGAAo57x8EiHw81DrpX+Urpv30GEx7xVpBs2nnQK9b5DzjAQAFdARTEQedZNkEs23byXcy8pIvqdsLDSHNKJ/6Ba3/jICeM7nPfrgE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736502325; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=4JHQMoPCt/+gJ16dphw+y/3ELJy9FZtzikFglbBwJUM=; b=QHREdNIDtQVKoD/9QGO0qEdPCWZfUn5GsohpYxX0TX2KOF/F1lO0WfV30pMrgDqTLijGke WO+i1w4VC6QQ6yZztxsNiCsjJJqDKRAbXoetnqr1dQOKO83zJrZscjrifc3147LKDLoiqf SKf9O6AGpUqPSrOj8vRhy7mFMmnHW/8= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-Ey-qtTInPEe7a3_nTjFqzQ-1; Fri, 10 Jan 2025 04:45:23 -0500 X-MC-Unique: Ey-qtTInPEe7a3_nTjFqzQ-1 X-Mimecast-MFC-AGG-ID: Ey-qtTInPEe7a3_nTjFqzQ Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 52DD7195608A for ; Fri, 10 Jan 2025 09:45:22 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.5]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7FFC03003E7F; Fri, 10 Jan 2025 09:45:21 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 50A9jICc245120 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 10 Jan 2025 10:45:18 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 50A9jIgA245119; Fri, 10 Jan 2025 10:45:18 +0100 Date: Fri, 10 Jan 2025 10:45:18 +0100 From: Jakub Jelinek To: "Joseph S. Myers" , Marek Polacek Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c: Fix up expr location for __builtin_stdc_rotate_* [PR118376] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: Zrvc1AGP7ZAWNRntqJEq0SuGgE3LbwluMyVKdZz863k_1736502322 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Hi! Seems I forgot to set_c_expr_source_range for the __builtin_stdc_rotate_* case (the other __builtin_stdc_* cases already have it), which means the locations in expr are uninitialized, sometimes causing ICEs in linemap code, at other times just valgrind errors about uninitialized var uses. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2025-01-10 Jakub Jelinek PR c/118376 * c-parser.cc (c_parser_postfix_expression): Call set_c_expr_source_range before break in the __builtin_stdc_rotate_* case. * gcc.dg/pr118376.c: New test. Jakub --- gcc/c/c-parser.cc.jj 2025-01-06 10:07:33.585493775 +0100 +++ gcc/c/c-parser.cc 2025-01-09 16:12:07.761005082 +0100 @@ -12906,6 +12906,7 @@ c_parser_postfix_expression (c_parser *p expr.value = build2_loc (loc, COMPOUND_EXPR, TREE_TYPE (expr.value), instrument_expr, expr.value); + set_c_expr_source_range (&expr, loc, close_paren_loc); break; } tree barg1 = arg; --- gcc/testsuite/gcc.dg/pr118376.c.jj 2025-01-09 16:26:19.621072359 +0100 +++ gcc/testsuite/gcc.dg/pr118376.c 2025-01-09 16:26:04.608283459 +0100 @@ -0,0 +1,11 @@ +/* PR c/118376 */ +/* { dg-do compile } */ +/* { dg-options "-Wsign-conversion" } */ + +unsigned x; + +void +foo () +{ + __builtin_memset (&x, (long long) __builtin_stdc_rotate_right (x, 0), 1); +} /* { dg-warning "conversion to 'int' from 'long long int' may change the sign of the result" "" { target *-*-* } .-1 } */