public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-85487-4-TZn1VIBRxR@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-85487-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85487 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |easyhack --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- 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) != 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.
next prev parent reply other threads:[~2022-02-15 13:17 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-85487-4@http.gcc.gnu.org/bugzilla/> 2020-08-27 20:46 ` bmburstein at gmail dot com 2022-02-15 13:17 ` redi at gcc dot gnu.org [this message] 2022-02-15 13:31 ` jakub at gcc dot gnu.org 2022-02-15 14:02 ` austinpmorton at gmail dot com 2022-02-15 15:23 ` redi at gcc dot gnu.org 2022-02-15 15:26 ` jakub at gcc dot gnu.org 2022-02-15 15:32 ` redi at gcc dot gnu.org 2022-02-15 15:34 ` redi at gcc dot gnu.org 2022-02-17 11:45 ` egallager at gcc dot gnu.org 2022-02-21 17:11 ` fw at gcc dot gnu.org 2022-02-25 13:01 ` rsandifo at gcc dot gnu.org 2022-02-25 14:46 ` redi at gcc dot gnu.org 2022-02-25 14:49 ` redi at gcc dot gnu.org 2022-05-30 15:43 ` bmburstein at gmail dot com 2022-11-11 4:28 ` cvs-commit at gcc dot gnu.org 2022-11-11 4:28 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-85487-4-TZn1VIBRxR@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).