From: David Malcolm <dmalcolm@redhat.com>
To: Austin Morton <austinpmorton@gmail.com>, Jeff Law <law@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v2] c: Silently ignore pragma region [PR85487]
Date: Fri, 13 Nov 2020 10:22:29 -0500 [thread overview]
Message-ID: <7f56b383637c481da4cd9fb9b83714445907431b.camel@redhat.com> (raw)
In-Reply-To: <CAPWKHJRB2OeUCYxARHBxmsfRQ7QPWSam1wDE15OyRx56LSpigw@mail.gmail.com>
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 <FOO>..." messages,
rather like we emit "In function <FOO>..." 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 <law@redhat.com> 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
> >
next prev parent reply other threads:[~2020-11-13 15:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-03 0:59 Austin Morton
2020-11-13 4:25 ` Jeff Law
2020-11-13 14:57 ` Austin Morton
2020-11-13 15:22 ` David Malcolm [this message]
2020-11-13 17:50 ` Austin Morton
2020-11-13 15:35 ` Jakub Jelinek
2020-11-13 17:37 ` Austin Morton
2020-11-13 23:29 ` Jeff Law
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=7f56b383637c481da4cd9fb9b83714445907431b.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=austinpmorton@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=law@redhat.com \
/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: link
Be 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).