From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id B403E398D033 for ; Mon, 18 Jan 2021 21:48:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B403E398D033 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=joseph_myers@mentor.com IronPort-SDR: XAHgUHhTXplO9bWcSAnVxenPzD00hmCJyJS42HawpqQrsLP5sME9Ys0Ak3fYayZi1T4HH8EOre rEm0Wn9E3OXWaw7TKXlDuqIKo0oOwErycuRwpHqAzdHeKsxXZPECeAc397zC6weHPTSYGU/uwS EFm2CpLdpArzTE7YyxON0mdzUERG99ofO0gJ6ULXlVreuZi6E/kOCfHpyvK3GmxZHaxL9v08pp iQ5AsLCIktPhJ46y46xmuhwY4s25x2sABmy7kRz98RTvcefg0dbzkLaquIVxPG/bIgRbey9xyO SAc= X-IronPort-AV: E=Sophos;i="5.79,357,1602576000"; d="scan'208";a="59475611" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 18 Jan 2021 13:48:57 -0800 IronPort-SDR: 7EfBI/VDimbWqjHkXYaDMJuLkTzK5al8crIj90gAQ7qT+qyLT81L6n5MdlouRcdhFDEOAZ5mFP SB+C9ntpnKCPwptaOWTeWx3WnngJbfTcrl6vDcjkbJx73+6vyV+DmA0DZsFdsZe6oSk6dvxKmG 8dQcihMDKUoxmwUDksgrrVFycRe5a/XoBxg+rr+GyFqKK3K+O8qm4qk0D+xP+adePrAw3rNPKa hZ4F6syPWFggNMDOPKzlQrfbhhcIKsQ13uZsukXor5KCVMTPNlYoRJVfyguGtQ2OJnHBLz6zCn V1k= Date: Mon, 18 Jan 2021 21:48:52 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: "Uecker, Martin" CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C PATCH] qualifiers of pointers to arrays in C2X [PR 98397] In-Reply-To: <1610914708.3311.2.camel@med.uni-goettingen.de> Message-ID: References: <1608546487.5427.1.camel@med.uni-goettingen.de> <1610914708.3311.2.camel@med.uni-goettingen.de> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3129.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2021 21:49:00 -0000 On Sun, 17 Jan 2021, Uecker, Martin wrote: > I did not add tests for c11 for warnings because we already > had warnings before and the tests for these exist. (I removed  > -Wdiscarded-array-qualifiers from the old tests as this flag > is not needed.) Or should there be additional warnings > with -Wc11-c2x-compat for c11? But warning twice about > the same issue does not seem ideal... If something is already warned about by default in C11 mode, -Wc11-c2x-compat doesn't need to produce extra warnings. > + int (*x)[3]; > + const int (*p)[3] = x; /* { dg-warning "pointers to arrays with different qualifiers are > incompatible in ISO C before C2X"  } */ "incompatible" doesn't seem the right wording for the diagnostic. The types are incompatible (i.e. not compatible types) regardless of standard version; the issue in this case is the rules for assignment. > diff --git a/gcc/testsuite/gcc.dg/c2x-qual-6.c b/gcc/testsuite/gcc.dg/c2x-qual-6.c > new file mode 100644 > index 00000000000..dca50ac014f > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/c2x-qual-6.c > @@ -0,0 +1,9 @@ > +/* Test related to qualifiers and pointers to arrays in C2X, PR98397 */ > +/* { dg-do compile } */ > +/* { dg-options "-std=c2x -pedantic-errors -Wc11-c2x-compat" } */ > + > +void f(void) > +{ > + const void* x; > + const int (*p)[3] = x; /* { dg-error "array with qualifier on the element is not qualified > before C2X" } */ This is showing a bug in the compiler implementation. In C2X mode, this message should be a warning not a pedwarn because the code is not a constraint violation. -Wc11-c2x-compat should produce a warning (independent of -pedantic), but -pedantic-errors should not turn it into an error. -- Joseph S. Myers joseph@codesourcery.com