From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 87B873894C12 for ; Fri, 28 Aug 2020 01:25:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 87B873894C12 Received: by mail-ot1-x331.google.com with SMTP id a65so6099895otc.8 for ; Thu, 27 Aug 2020 18:25:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=BuFeydWn9ZqcqhBXWS6v/xpYsOytOK+0Plhmz3CwTwU=; b=kQIu7Rf7l47AKmrjzgC0rH7ssOgG/oCcrmP38zxIa3wqLUANhhZwN7aSaX4tq5ef+Z YD5QyIIRxmubaqyxO3IUJKXD7/e7s6/o6mT0SGUoBMALjMqDHxNv5MuPu26AGW6eudtY mktUj10Nfn/xhSeGZSzuiofXQLFoBm05ImXP3tfW5v0Dqlq9LIXnLw+N1sfsTq7oh1ql Ee763AgNMxmS3mS72PllAr8GJ1v7eccdwszsVN1e+CQ2z55Pz5q/T0LmAJ52Gc6Gkyes Bi6tzCy0NETJEup1hvFNnpJVUiROBnl2sHAigHqY96TciQsNfPNCbvw3QQA3IzDVt3aa S0sw== X-Gm-Message-State: AOAM530HtlE9foy3IHoQ2xEqmaYAfajpeG3bkab5VvOXG+v/77zhYiRQ 03Qh36X8LCqDW1L0M238wPgXo6gSUNWYRHy7kD9m3sOAHexOxZqo X-Google-Smtp-Source: ABdhPJxWPc8gJUOV6hFoDtpmpZqQ3ndV2kUP/kAZpLru7GWVbyQpMlxDhJsCXHc3M+bJZK40EU15rd6gXR2PltlwYUs= X-Received: by 2002:a9d:2aa6:: with SMTP id e35mr12696924otb.246.1598577931610; Thu, 27 Aug 2020 18:25:31 -0700 (PDT) MIME-Version: 1.0 From: Austin Morton Date: Thu, 27 Aug 2020 21:25:20 -0400 Message-ID: Subject: [PATCH] c: Silently ignore pragma region [PR85487] To: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-10.1 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.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, 28 Aug 2020 01:25:34 -0000 #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 3 months ago. 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/c-family/ChangeLog | 5 +++++ gcc/c-family/c-pragma.c | 10 ++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pragma-region.c | 21 +++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/pragma-region.c diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 1eaa99f31..97ba259cd 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2020-08-27 Austin Morton + + PR c/85487 + * c-pragma.c (handle_pragma_region): Declare. + 2020-08-11 Jakub Jelinek PR c/96545 diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index e3169e68f..de0411d07 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1166,6 +1166,13 @@ handle_pragma_message (cpp_reader *ARG_UNUSED(dummy)) TREE_STRING_POINTER (message)); } +/* Silently ignore region pragmas. */ + +static void +handle_pragma_region (cpp_reader *ARG_UNUSED(dummy)) +{ +} + /* Mark whether the current location is valid for a STDC pragma. */ static bool valid_location_for_stdc_pragma; @@ -1584,6 +1591,9 @@ init_pragma (void) c_register_pragma_with_expansion (0, "message", handle_pragma_message); + c_register_pragma (0, "region", handle_pragma_region); + c_register_pragma (0, "endregion", handle_pragma_region); + #ifdef REGISTER_TARGET_PRAGMAS REGISTER_TARGET_PRAGMAS (); #endif diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5c1a45716..4033c111c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-08-27 Austin Morton + + PR c/85487 + * gcc.dg/pragma-region.c: New test. + 2020-08-26 Jeff Law * gcc.target/i386/387-7.c: Add dg-require-effective-target c99_runtime. diff --git a/gcc/testsuite/gcc.dg/pragma-region.c b/gcc/testsuite/gcc.dg/pragma-region.c new file mode 100644 index 000000000..72cc2c144 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pragma-region.c @@ -0,0 +1,21 @@ +/* Verify #pragma region and #pragma endregion do not emit warnings. */ + +/* { dg-options "-Wunknown-pragmas" } */ + +#pragma region + +#pragma region name + +#pragma region "name" + +#pragma region() + +#pragma region("name") + +#pragma endregion + +#pragma endregion garbage + +#pragma endregion() + +#pragma endregion("garbage") -- 2.17.1