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.

Austin

On Thu, Nov 12, 2020 at 11:25 PM Jeff Law <l...@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
>

Reply via email to