From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id E37F73857021 for ; Fri, 13 Nov 2020 15:22:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E37F73857021 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-88-wGJ3pyOAMbeL8hCty6buWA-1; Fri, 13 Nov 2020 10:22:32 -0500 X-MC-Unique: wGJ3pyOAMbeL8hCty6buWA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F1A584BA67; Fri, 13 Nov 2020 15:22:31 +0000 (UTC) Received: from ovpn-112-135.phx2.redhat.com (ovpn-112-135.phx2.redhat.com [10.3.112.135]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F4235B4C3; Fri, 13 Nov 2020 15:22:30 +0000 (UTC) Message-ID: <7f56b383637c481da4cd9fb9b83714445907431b.camel@redhat.com> Subject: Re: [PATCH v2] c: Silently ignore pragma region [PR85487] From: David Malcolm To: Austin Morton , Jeff Law Cc: GCC Patches Date: Fri, 13 Nov 2020 10:22:29 -0500 In-Reply-To: References: <98207018-7512-c842-94d9-cc3125b0b2c8@redhat.com> User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.5 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_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, 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 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: Fri, 13 Nov 2020 15:22:36 -0000 On Fri, 2020-11-13 at 09:57 -0500, Austin Morton via Gcc-patches wrote: > On the contrary, as a user of GCC I would much prefer a consistent > behavior for #pragma region based purely on GCC version. > > IE, so you can tell people: > "just update to GCC X.Y and those warnings will go away" > rather than: > "update to GCC X.Y and pass some new flags - but make sure > not to pass them to old GCC versions, since that will generate > a new warning" > > I do agree it may be generally useful to have a configurable way to > specify pragmas to ignore at runtime, but that is not what I was > trying > to accomplish here. > > Both clang and MSVC handle this pragma without any runtime > configuration, and I think GCC should as well. FWIW I like the patch (but I don't think I can approve it). How much does this pragma get used "in the wild"? Thinking aloud, I wonder if it would be useful to capture regions in the diagnostic subsystem, and emit "In region ..." messages, rather like we emit "In function ..." when first emitting a diagnostic within a region? (not sure if good idea, just brainstorming) Dave > Austin > > On Thu, Nov 12, 2020 at 11:25 PM Jeff Law wrote: > > > > On 9/2/20 6:59 PM, Austin Morton via Gcc-patches wrote: > > > #pragma region is a feature introduced by Microsoft in order to > > > allow > > > manual grouping and folding of code within Visual Studio. It is > > > entirely ignored by the compiler. Clang has supported this > > > feature > > > since 2012 when in MSVC compatibility mode, and enabled it across > > > the > > > board in 2018. > > > > > > As it stands, you cannot use #pragma region within GCC without > > > disabling unknown pragma warnings, which is not advisable. > > > > > > I propose GCC adopt "#pragma region" and "#pragma endregion" in > > > order > > > to alleviate these issues. Because the pragma has no purpose at > > > compile time, the implementation is trivial. > > > > > > > > > Microsoft Documentation on the feature: > > > https://docs.microsoft.com/en-us/cpp/preprocessor/region-endregion > > > > > > LLVM change which enabled pragma region across the board: > > > https://reviews.llvm.org/D42248 > > > --- > > > gcc/ChangeLog | 5 +++++ > > > gcc/c-family/ChangeLog | 5 +++++ > > > gcc/c-family/c-pragma.c | 10 ++++++++++ > > > gcc/doc/cpp.texi | 6 ++++++ > > > gcc/testsuite/ChangeLog | 5 +++++ > > > gcc/testsuite/gcc.dg/pragma-region.c | 21 +++++++++++++++++++++ > > > 6 files changed, 52 insertions(+) > > > create mode 100644 gcc/testsuite/gcc.dg/pragma-region.c > > > > I'm not sure that this is really the way we want to handle this > > stuff. > > I understand the problem you're trying to solve, but embedding a > > list of > > pragmas to ignore into the compiler itself just seems like the > > wrong > > approach -- it bakes that set of pragmas to ignore into the > > compiler. > > > > > > ISTM that we'd be better off either having a command line option to > > list > > the set of pragmas to ignore, or they should be pulled from a file > > specified on the command line. That would seem to be a lot more > > friendly to downstream users since each project could set the list > > of > > pragmas to ignore on their own and have that set updated > > dynamically > > over time without having to patch and update GCC. > > > > > > Any chance you would be willing to work on that? > > > > Jeff > >