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