Hi!

This is something the C++ FE has been diagnosing but C FE only
complained if there wasn't an identifier right after opening (

Bootstrapped/regtested on x86_64-linux and i686-linux, commited to trunk.

2025-01-25  Jakub Jelinek  <ja...@redhat.com>

        PR c/118639
        * c-parser.cc (c_parser_omp_variable_list): Remove first variable
        and emit "expected identifier" error regardless of it.

        * c-c++-common/gomp/pr118639.c: New test.
        * c-c++-common/goacc/cache-2.c: Remove one xfail for c.

--- gcc/c/c-parser.cc.jj        2025-01-23 11:13:49.296155562 +0100
+++ gcc/c/c-parser.cc   2025-01-24 12:36:39.166489327 +0100
@@ -16307,7 +16307,6 @@ c_parser_omp_variable_list (c_parser *pa
   auto_vec<c_token> tokens;
   unsigned int tokens_avail = 0;
   c_token *saved_tokens = NULL;
-  bool first = true;
 
   while (1)
     {
@@ -16343,7 +16342,6 @@ c_parser_omp_variable_list (c_parser *pa
                break;
 
              c_parser_consume_token (parser);
-             first = false;
              continue;
            }
 
@@ -16507,8 +16505,7 @@ c_parser_omp_variable_list (c_parser *pa
        t = c_parser_predefined_identifier (parser).value;
       else
        {
-         if (first)
-           c_parser_error (parser, "expected identifier");
+         c_parser_error (parser, "expected identifier");
          break;
        }
 
@@ -16702,7 +16699,6 @@ c_parser_omp_variable_list (c_parser *pa
        break;
 
       c_parser_consume_token (parser);
-      first = false;
     }
 
   return list;
--- gcc/testsuite/c-c++-common/gomp/pr118639.c.jj       2025-01-24 
12:43:57.152533403 +0100
+++ gcc/testsuite/c-c++-common/gomp/pr118639.c  2025-01-24 12:43:40.343770597 
+0100
@@ -0,0 +1,14 @@
+/* PR c/118639 */
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+  int a = 0, b = 0, c = 0;
+#ifndef __cplusplus
+  #pragma omp allocate (a, )                   /* { dg-error "expected" "" { 
target c } } */
+#endif
+  #pragma omp flush (b, )                      /* { dg-error "expected" } */
+  #pragma omp parallel firstprivate (c, )      /* { dg-error "expected" } */
+  ;
+}
--- gcc/testsuite/c-c++-common/goacc/cache-2.c.jj       2020-11-26 
01:14:47.568081548 +0100
+++ gcc/testsuite/c-c++-common/goacc/cache-2.c  2025-01-25 10:26:24.508606031 
+0100
@@ -33,7 +33,7 @@ test ()
 #pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) 
before '\\\)' token" } */
 #pragma acc cache (,) /* { dg-error "expected (identifier|unqualified-id) 
before '(,|\\\))' token" } */
 #pragma acc cache (a[0:N] /* { dg-error "expected '\\\)' before end of line" } 
*/
-#pragma acc cache (a[0:N],) /* { dg-error "expected 
(identifier|unqualified-id) before '(,|\\\))' token" "" { xfail c } } */
+#pragma acc cache (a[0:N],) /* { dg-error "expected 
(identifier|unqualified-id) before '(,|\\\))' token" } */
 #pragma acc cache (a[0:N]) copyin (a[0:N]) /* { dg-error "expected end of line 
before 'copyin'" } */
 #pragma acc cache () /* { dg-error "expected (identifier|unqualified-id) 
before '\\\)' token" } */
 #pragma acc cache (a[0:N] b[0:N]) /* { dg-error "expected '\\\)' before 'b'" } 
*/

        Jakub

Reply via email to