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.

Reply via email to