public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3887] c-family: Support #pragma region/endregion [PR85487] Date: Fri, 11 Nov 2022 04:28:09 +0000 (GMT) [thread overview] Message-ID: <20221111042809.421633858D1E@sourceware.org> (raw) https://gcc.gnu.org/g:d3fe767c16e7c528e4fc71c8a68ac14b4573d880 commit r13-3887-gd3fe767c16e7c528e4fc71c8a68ac14b4573d880 Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Nov 9 21:49:52 2022 +0000 c-family: Support #pragma region/endregion [PR85487] These pragmas are used by some editors to mark regions of code for grouping and folding. GCC should silently ignore them, rather than giving -Wunknown-pragmas warnings. PR c/85487 gcc/ChangeLog: * doc/cpp/pragmas.rst (Pragmas): Document region pragmas. gcc/c-family/ChangeLog: * c-pragma.cc (handle_pragma_ignore): New function. (init_pragma): Register region and endregion pragmas. gcc/testsuite/ChangeLog: * c-c++-common/pragma-region.c: New test. Diff: --- gcc/c-family/c-pragma.cc | 9 +++++++++ gcc/doc/cpp/pragmas.rst | 3 +++ gcc/testsuite/c-c++-common/pragma-region.c | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc index b5a4b3c970f..142a46441ac 100644 --- a/gcc/c-family/c-pragma.cc +++ b/gcc/c-family/c-pragma.cc @@ -1403,6 +1403,12 @@ handle_pragma_message (cpp_reader *) TREE_STRING_POINTER (message)); } +/* Ignore a no-op pragma that GCC recognizes, but which has no effect. */ +static void +handle_pragma_ignore (cpp_reader *) +{ +} + /* Mark whether the current location is valid for a STDC pragma. */ static bool valid_location_for_stdc_pragma; @@ -1870,6 +1876,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); diff --git a/gcc/doc/cpp/pragmas.rst b/gcc/doc/cpp/pragmas.rst index da07cebf4a1..78277d7b623 100644 --- a/gcc/doc/cpp/pragmas.rst +++ b/gcc/doc/cpp/pragmas.rst @@ -119,3 +119,6 @@ GCC plugins may provide their own pragmas. file will never be read again, no matter what. It is a less-portable alternative to using :samp:`#ifndef` to guard the contents of header files against multiple inclusions. + +``#pragma region {tokens}...``, ``#pragma endregion {tokens}...`` + These pragmas are accepted, but have no effect. diff --git a/gcc/testsuite/c-c++-common/pragma-region.c b/gcc/testsuite/c-c++-common/pragma-region.c new file mode 100644 index 00000000000..8e0cbe1f16f --- /dev/null +++ b/gcc/testsuite/c-c++-common/pragma-region.c @@ -0,0 +1,11 @@ +/* { dg-options "-Wunknown-pragmas" } */ +/* { dg-final { scan-assembler "code_within_region" } } */ +/* { dg-final { scan-assembler "code_within_named_region" } } */ + +#pragma region +void code_within_region() { } +#pragma endregion + +#pragma region ignored name +void code_within_named_region() { } +#pragma endregion // ignored comment
reply other threads:[~2022-11-11 4:28 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20221111042809.421633858D1E@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@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).