gcc-patches@gcc.gnu.org
[Top] [All Lists]

[gomp] Don't ICE on orphaned #pragma omp section (PR c++/24613)

Subject: [gomp] Don't ICE on orphaned #pragma omp section PR c++/24613
From: Jakub Jelinek
Date: Wed, 2 Nov 2005 04:03:42 -0500
Hi!

The attached (invalid) testcases caused ICEs, this patch turns them into
diagnostics.
Ok for gomp?

2005-11-02  Jakub Jelinek  <jakub@xxxxxxxxxx>

        PR c++/24613
        * c-parser.c (c_parser_pragma): Diagnose PRAGMA_OMP_SECTION outside
        of PRAGMA_OMP_SECTIONS construct.
cp/
        * parser.c (cp_parser_pragma): Diagnose PRAGMA_OMP_SECTION outside
        of PRAGMA_OMP_SECTIONS construct.
testsuite/
        * gcc.dg/gomp/sections-4.c: New test.
        * g++.dg/gomp/sections-4.C: New test.

--- gcc/cp/parser.c.jj  2005-11-02 08:38:00.000000000 +0100
+++ gcc/cp/parser.c     2005-11-02 09:54:04.000000000 +0100
@@ -18787,6 +18787,11 @@ cp_parser_pragma (cp_parser *parser, enu
       cp_parser_omp_construct (parser, pragma_tok);
       return true;
 
+    case PRAGMA_OMP_SECTION:
+      error ("%<#pragma omp section%> may only be used in "
+            "%<#pragma omp sections%> construct");
+      break;
+
     default:
       gcc_assert (id >= PRAGMA_FIRST_EXTERNAL);
       c_invoke_pragma_handler (id);
--- gcc/c-parser.c.jj   2005-11-02 09:06:49.000000000 +0100
+++ gcc/c-parser.c      2005-11-02 09:48:32.000000000 +0100
@@ -6438,6 +6438,12 @@ c_parser_pragma (c_parser *parser, enum 
       c_parser_omp_threadprivate (parser);
       return false;
 
+    case PRAGMA_OMP_SECTION:
+      error ("%<#pragma omp section%> may only be used in "
+            "%<#pragma omp sections%> construct");
+      c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
+      return false;
+
     case PRAGMA_GCC_PCH_PREPROCESS:
       c_parser_error (parser, "%<#pragma GCC pch_preprocess%> must be first");
       c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
--- gcc/testsuite/gcc.dg/gomp/sections-4.c.jj   2005-11-02 09:54:53.000000000 
+0100
+++ gcc/testsuite/gcc.dg/gomp/sections-4.c      2005-11-02 09:50:19.000000000 
+0100
@@ -0,0 +1,13 @@
+/* PR c++/24613 */
+/* { dg-compile } */
+
+#pragma omp section    /* { dg-error "may only be used in" } */
+
+int i;
+
+void
+foo (void)
+{
+  #pragma omp section  /* { dg-error "may only be used in" } */
+    i++;
+}
--- gcc/testsuite/g++.dg/gomp/sections-4.C.jj   2005-11-02 09:54:53.000000000 
+0100
+++ gcc/testsuite/g++.dg/gomp/sections-4.C      2005-11-02 09:50:19.000000000 
+0100
@@ -0,0 +1,13 @@
+/* PR c++/24613 */
+/* { dg-compile } */
+
+#pragma omp section    /* { dg-error "may only be used in" } */
+
+int i;
+
+void
+foo (void)
+{
+  #pragma omp section  /* { dg-error "may only be used in" } */
+    i++;
+}

        Jakub

<Prev in Thread] Current Thread [Next in Thread>