Message ID | 20231019153731.1394423-1-pinskia@gmail.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp473127vqb; Thu, 19 Oct 2023 08:38:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFsa/Ydou7ikFAkh8Iuyqq8sz1ftvlh63eDcAsUEJ+wbVnaUFyxB5hobIdSJLdnMRwLyAJ8 X-Received: by 2002:a05:6808:138f:b0:3a7:1e3e:7f97 with SMTP id c15-20020a056808138f00b003a71e3e7f97mr3069485oiw.4.1697729904686; Thu, 19 Oct 2023 08:38:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697729904; cv=pass; d=google.com; s=arc-20160816; b=DlvICWdlYObdyks6+2K0LSVZKzuU5N42A7gl3Fu0RQHuP8rLRyaSTpZ8CBjM53TVK9 lb+/nycG5ENyf847+vX+3c9aYyAOWZD5Lu3yohMydJq6KN5XEXeQHW/pDyPVQ9CB3WGa +MuUHHIkBLR1gApsOm0NaWEYKNEem38RUHGlskC8aD5FI6jBbRIpCUEYCI7R+qi1/9rm ClaFcsMcn6z12C/cCHvqxjff1FbwJeMGCQwixiyAqS6tSLU7S0KIyVQyEcLPxq3PmGif jHk3J/EpvirxXMTCfOtYYGfZyF5e34POtVLeRzUey9p3KHcXlJPA+yjNHXqleHW0BGur XcUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=W2BTdbrO3hC1Tj70mPOP9Ww3zYJ4qWC4tKeAx1jhwW8=; fh=6xfd3IYC8Zt5CA4TsXZHhPmGMhO9cjo3oiHaQc5bSUI=; b=vYDB09BfnlUhFbWVAoQZo8gaEBYc+Q0PXDEDQzUbe4Vf5sliD1YJZrrofLi+JWxRBk 8fvJq5kDQa8DLr23wE4kklEj3qhX72Ty9+DHf9EnzP8h1cwT1OTVd90iYr9E0BttoQvd zTW4Uwir831CUAKP1YtYvjTEIFUc0LKt0R2KRksmtVPg2s6sSa0LbJfOVkCVlVA0q8r+ X2ujI0YfIGErRvCLRGtAvSB/G3ha37i53lxwiP+0q/97/TJqtLBOzhxXMpJCZFgLQLR0 vdMpNk+f7JrMZ18deNc8xgCtKpEL43EpV5+ETENTMGAct9FcDi8HiBzTSaVAcNGqMADN IkTg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fktyUnMQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id qf17-20020a0562144b9100b0066d7ec3340bsi1733271qvb.616.2023.10.19.08.38.24 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 08:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fktyUnMQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5773B3856948 for <ouuuleilei@gmail.com>; Thu, 19 Oct 2023 15:38:24 +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 <gcc-patches@gcc.gnu.org>; 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 <gcc-patches@gcc.gnu.org>; 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-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 <pinskia@gmail.com> To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski <pinskia@gmail.com> 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 Content-Transfer-Encoding: 8bit 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780198832827398421 X-GMAIL-MSGID: 1780198832827398421 |
Series |
c: [PR104822] Don't warn about converting NULL to different sso endian
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Andrew Pinski
Oct. 19, 2023, 3:37 p.m. UTC
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
Comments
On Thu, Oct 19, 2023 at 08:37:31AM -0700, Andrew Pinski wrote: > 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. Looks good, but please put "[PR104822]" at the end of the subject line. > 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 <stddef.h> > + > +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 "" } */ Maybe test nullptr as well? Marek
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 <stddef.h> + +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 "" } */