From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D7BAF3858D20; Tue, 15 Feb 2022 13:17:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7BAF3858D20 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/85487] Support '#pragma region' and '#pragma endregion' to allow code folding with Visual Studio Date: Tue, 15 Feb 2022 13:17:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 8.0.1 X-Bugzilla-Keywords: easyhack X-Bugzilla-Severity: enhancement X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2022 13:17:25 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D85487 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |easyhack --- Comment #3 from Jonathan Wakely --- The docs raise some questions. They say that a #pragma region must be ended by a #pragma endregion. Should= the compiler check that and issue a diagnostic otherwise? What is the form of the optional "name" that follows #pragma region? What if #pragma endregion is followed by preprocessor tokens, not just a comment? If we don't care about validating anything, it's easy to make GCC completely ignore those pragmas: --- a/gcc/c-family/c-pragma.cc +++ b/gcc/c-family/c-pragma.cc @@ -1218,6 +1218,15 @@ handle_pragma_message (cpp_reader *ARG_UNUSED(dummy)) TREE_STRING_POINTER (message)); } +/* Ignore a no-op pragma that GCC recognizes, but which has no effect. */ +static void +handle_pragma_ignore (cpp_reader *) +{ + tree x; + while (pragma_lex (&x) !=3D CPP_EOF) + /* Ignore the rest of the line. */; +} + /* Mark whether the current location is valid for a STDC pragma. */ static bool valid_location_for_stdc_pragma; @@ -1633,6 +1642,9 @@ init_pragma (void) c_register_pragma ("GCC", "pop_options", handle_pragma_pop_options); c_register_pragma ("GCC", "reset_options", handle_pragma_reset_options); + c_register_pragma (0, "region", handle_pragma_ignore); + c_register_pragma (0, "endregion", handle_pragma_ignore); + c_register_pragma ("STDC", "FLOAT_CONST_DECIMAL64", handle_pragma_float_const_decimal64); This needs tests though.=