From patchwork Thu Oct 19 15:37:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 1851868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fktyUnMQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SBBgn6fb8z20cx for ; Fri, 20 Oct 2023 02:38:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F19703856DD5 for ; Thu, 19 Oct 2023 15:38:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by sourceware.org (Postfix) with ESMTPS id B67523857017 for ; Thu, 19 Oct 2023 15:37:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B67523857017 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 B67523857017 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::629 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697729858; cv=none; b=NC0JLk6Nlo5pA3GZ/iyc7MG+1tjWq/RUr0pjpVTuMjH3WLAUYROjbcTTdgI/hiBvb0iKqxnF7lw+NiTPnZTSogw7vJr+hl1Ny7EjRPAcUlwDObSJPDe5J/Y8V6LjBu4ge119mHe0EUDCwEUaLz3STWcNvKPg8vcXLGmPTDsmd8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697729858; c=relaxed/simple; bh=4jdfKKvOWv1Ovr1FCBAouq7U71SUnKxI+/M5NNYX6uM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=MiPO8/ukDAHKxa+EQ8FiBSrwF2LqBoJPKXuSMMsP/dk4wOYXv/Ix0VfM2YOTc5E3nL6VMGxJBQnUFP5HMRJXK8ryemRovckF5i8peLl0koC1ghma/10lqG+86KgfUfVE37npx0XKyGRoq1S48plLnx3+9cNhz+iJhQBwVbHud04= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1ca215cc713so38269175ad.3 for ; Thu, 19 Oct 2023 08:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697729855; x=1698334655; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=W2BTdbrO3hC1Tj70mPOP9Ww3zYJ4qWC4tKeAx1jhwW8=; b=fktyUnMQKp7/lt0L51fZZyIBSLBeVca9vJmGlbJGnctB2Sxtr9JKF1aKTvvrRjoJ7i 2I6DO4yfX7H7fW5sSj5dXJ0xeed192HcmScxS9A0wTqSUhQ1uZxZlhyyNX4P6RTWP5tw ufQlLdjJdC1RvZJt/r7z7sCImhMM6VsfhyrePL6dKr4h0L5bPw+qPLqy8KXKb+iNBjGb 3BsTg4Fek9va/n02u1huvnsUXUyma4GDAt3l/d1JRNQhxrdm2NYqEjDwJaq2PP4fL3hy t71zBVnRF9XAMqteog2A3Wj6ShTw+OhkGbV8/XC5re4dRtzUZJuPBgqwGpOqfbNElwF3 ArDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697729855; x=1698334655; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W2BTdbrO3hC1Tj70mPOP9Ww3zYJ4qWC4tKeAx1jhwW8=; b=YwtkLLpKVuaeRLqAQLgfYdzkTQt0AP3VFfUd5uKCGMdKyBjEooqpECi7F+vUOSAs4g R4WICpKfKPPGF2/OJswD/051iqf67r1LG0XS1Caq/wa3a0Lvj1sPFxJbrtTpaWsQzVls qkfhcVbkg03ricUPbZ9W5DT39NasunyGWT184SO5lkzenJDcMb/5yyrcUsKJaMUsAd38 57rJO80zt4URZPrTtgqF06Kx2hjMLOvYHBJOeduSpRKP+TKPx/+nOyKeRzhmezD3s2Mb gqxm/tbU22Da9CGMQVu9rXm7EY8UbGmR+Ckt/TZdjjCKhPlNcHe3nSl3Slt6ThhqA7Tk i7Ng== X-Gm-Message-State: AOJu0YxEgn518PBMUE3FeXg1sh2QXRglX8zVC1ckj8fK/umn4Ff/8QSu mAzooC09dldKvTZUb9Z1hT22kV2x+gY+kQ== X-Google-Smtp-Source: AGHT+IHcLdvmOs/RyNTfJ793F4WjKm+KHAzzlQp7zoBLvwvp4CbQ8KCQ4ILnGy8JB6ZqV0RUM6f0gA== X-Received: by 2002:a17:902:e884:b0:1ca:9934:d014 with SMTP id w4-20020a170902e88400b001ca9934d014mr3252520plg.10.1697729854948; Thu, 19 Oct 2023 08:37:34 -0700 (PDT) Received: from xeond2.wrightpinski.org ([98.97.114.173]) by smtp.gmail.com with ESMTPSA id u3-20020a170902b28300b001c60a548331sm2057530plr.304.2023.10.19.08.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 08:37:34 -0700 (PDT) From: Andrew Pinski To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski Subject: [PATCH] c: [PR104822] Don't warn about converting NULL to different sso endian Date: Thu, 19 Oct 2023 08:37:31 -0700 Message-Id: <20231019153731.1394423-1-pinskia@gmail.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 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 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org In a similar way we don't warn about NULL pointer constant conversion to a different named address we should not warn to a different sso endian either. This adds the simple check. Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR c/104822 gcc/c/ChangeLog: * c-typeck.cc (convert_for_assignment): Check for null pointer before warning about an incompatible scalar storage order. gcc/testsuite/ChangeLog: * gcc.dg/sso-18.c: New test. --- gcc/c/c-typeck.cc | 1 + gcc/testsuite/gcc.dg/sso-18.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/sso-18.c diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 6e044b4afbc..f39dc71d593 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -7449,6 +7449,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, /* See if the pointers point to incompatible scalar storage orders. */ if (warn_scalar_storage_order + && !null_pointer_constant_p (rhs) && (AGGREGATE_TYPE_P (ttl) && TYPE_REVERSE_STORAGE_ORDER (ttl)) != (AGGREGATE_TYPE_P (ttr) && TYPE_REVERSE_STORAGE_ORDER (ttr))) { diff --git a/gcc/testsuite/gcc.dg/sso-18.c b/gcc/testsuite/gcc.dg/sso-18.c new file mode 100644 index 00000000000..799a0c858f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/sso-18.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* PR c/104822 */ + +#include + +struct Sb { + int i; +} __attribute__((scalar_storage_order("big-endian"))); +struct Sl { + int i; +} __attribute__((scalar_storage_order("little-endian"))); + +/* Neither of these should warn about incompatible scalar storage order + as NULL pointers are compatiable with both endian. */ +struct Sb *pb = NULL; /* { dg-bogus "" } */ +struct Sl *pl = NULL; /* { dg-bogus "" } */