Hi!

This is similar to what has previously been addressed in
<https://gcc.gnu.org/PR51360>,
<http://news.gmane.org/find-root.php?message_id=%3C20111215173852.GT1957%40tyan-ft48-01.lab.bos.redhat.com%3E>:

    int f(int A, int B)
    {
      int r = 0;
      extern int *v;
      int a = 2;
      int b = 4;
      int n = 3;
    
      v[n] = 0;
    
    #pragma omp target map(to: v[a:b])
      r |= v[n];
    
    #pragma omp target map(to: v[A:B])
      r |= v[n];
    
      return r;
    }

    ../../openacc/w.c: In function 'f':
    ../../openacc/w.c:6:7: warning: variable 'b' set but not used 
[-Wunused-but-set-variable]
       int b = 4;
           ^
    ../../openacc/w.c:5:7: warning: variable 'a' set but not used 
[-Wunused-but-set-variable]
       int a = 2;
           ^
    ../../openacc/w.c:1:11: warning: parameter 'A' set but not used 
[-Wunused-but-set-parameter]
     int f(int A, int B)
               ^
    ../../openacc/w.c:1:18: warning: parameter 'B' set but not used 
[-Wunused-but-set-parameter]
     int f(int A, int B)
                      ^

The following patch fixes this for C:

diff --git gcc/c/c-parser.c gcc/c/c-parser.c
index 3f4a92b..bba6edb 100644
--- gcc/c/c-parser.c
+++ gcc/c/c-parser.c
@@ -9887,7 +9887,10 @@ c_parser_omp_variable_list (c_parser *parser,
 
                  c_parser_consume_token (parser);
                  if (!c_parser_next_token_is (parser, CPP_COLON))
-                   low_bound = c_parser_expression (parser).value;
+                   {
+                     low_bound = c_parser_expression (parser).value;
+                     mark_exp_read (low_bound);
+                   }
                  if (c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
                    length = integer_one_node;
                  else
@@ -9900,7 +9903,10 @@ c_parser_omp_variable_list (c_parser *parser,
                          break;
                        }
                      if (!c_parser_next_token_is (parser, CPP_CLOSE_SQUARE))
-                       length = c_parser_expression (parser).value;
+                       {
+                         length = c_parser_expression (parser).value;
+                         mark_exp_read (length);
+                       }
                    }
                  /* Look for the closing `]'.  */
                  if (!c_parser_require (parser, CPP_CLOSE_SQUARE,

How to fix it in C++?  In gcc/cp/parser.c:cp_parser_omp_var_list_no_open
similar to the C fix, or in gcc/cp/semantics.c:finish_omp_clauses as done
for PR51360?  I guess the latter is required for C++ templates?  This I
can't currently test due to
<http://news.gmane.org/find-root.php?message_id=%3C87zje7rdho.fsf%40schwinge.name%3E>.


I have not yet tested whether such an issue might also exist for Fortran.


Grüße,
 Thomas

Attachment: pgpNFODfwTtiL.pgp
Description: PGP signature

Reply via email to