This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch,openacc] C, C++ OpenACC wait diagnostic change


On Fri, 30 Nov 2018 16:25:42 +0100
Thomas Schwinge <thomas@codesourcery.com> wrote:

> In addition to your "(1" token sequence (and similar ones), I suppose
> what these code paths in C and C++ are supposed to catch the "wait ()"
> case (see line 149 of gcc/testsuite/c-c++-common/goacc/asyncwait-1.c).
> 
> I suppose in C, we do diagnose an "error: expected expression before
> ')' token" in "c_parser_expr_list"/"c_parser_expr_no_commas", and
> then return a list with an "error_mark_node", right?  (I have not
> verified that.)
> 
> > So, we can elide the
> > diagnostic with no change to compiler behaviour.  
> 
> In that case, yes.

[...]

> Right, one single error diagnostic is enough.
> 
> But please make sure that the "wait ()" case continues to be diagnosed
> correctly -- similarly to C, I suggest "expected expression before ')'
> token" (or whatever is natural to the C++ parser), and then
> accordingly tidy up that "dg-error" regular expression on line 149 of
> gcc/testsuite/c-c++-common/goacc/asyncwait-1.c.
> 
> In C++, this is the case that: "args != NULL && args->length () ==
> 0", I suppose?  (I have not verified that.)
> 
> Oh, and next to "wait ()" please also add test coverage for "wait (".

I've made those changes in the attached, thank you. OK?

Julian

ChangeLog

2018-XX-YY  James Norris  <jnorris@codesourcery.com>
            Cesar Philippidis  <cesar@codesourcery.com>
            Julian Brown  <julian@codesourcery.com>

        gcc/c/
        * c-parser.c (c_parser_oacc_wait_list): Remove dead diagnostic
        code.

        gcc/cp/
        * parser.c (cp_parser_oacc_wait_list): Fix error message and avoid
        duplicate diagnostic.

        gcc/testsuite/
        * c-c++-common/goacc/asyncwait-1: Update expected errors and add a
        test for "wait (".

Reviewed-by: Thomas Schwinge  <thomas@codesourcery.com>
Reviewed-by: Joseph Myers  <joseph@codesourcery.com>
commit e3f9a5935e9ec3062017602a580139a0bccf1f4c
Author: Julian Brown <julian@codesourcery.com>
Date:   Fri Sep 28 05:52:55 2018 -0700

    OpenACC wait list diagnostic change
    
    2018-XX-YY  James Norris  <jnorris@codesourcery.com>
    	    Cesar Philippidis  <cesar@codesourcery.com>
    	    Julian Brown  <julian@codesourcery.com>
    
    	gcc/c/
    	* c-parser.c (c_parser_oacc_wait_list): Remove dead diagnostic
    	code.
    
    	gcc/cp/
    	* parser.c (cp_parser_oacc_wait_list): Fix error message and avoid
    	duplicate diagnostic.
    
    	gcc/testsuite/
    	* c-c++-common/goacc/asyncwait-1: Update expected errors and add a
    	test for "wait (".

diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index afc4071..0d7fcc0 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -11801,14 +11801,6 @@ c_parser_oacc_wait_list (c_parser *parser, location_t clause_loc, tree list)
     return list;
 
   args = c_parser_expr_list (parser, false, true, NULL, NULL, NULL, NULL);
-
-  if (args->length () == 0)
-    {
-      c_parser_error (parser, "expected integer expression before ')'");
-      release_tree_vector (args);
-      return list;
-    }
-
   args_tree = build_tree_list_vec (args);
 
   for (t = args_tree; t; t = TREE_CHAIN (t))
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index ab6d237..ac19cb4 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -32605,9 +32605,11 @@ cp_parser_oacc_wait_list (cp_parser *parser, location_t clause_loc, tree list)
 
   if (args == NULL || args->length () == 0)
     {
-      cp_parser_error (parser, "expected integer expression before ')'");
       if (args != NULL)
-	release_tree_vector (args);
+	{
+	  cp_parser_error (parser, "expected integer expression list");
+	  release_tree_vector (args);
+	}
       return list;
     }
 
diff --git a/gcc/testsuite/c-c++-common/goacc/asyncwait-1.c b/gcc/testsuite/c-c++-common/goacc/asyncwait-1.c
index e1840af..2f5d476 100644
--- a/gcc/testsuite/c-c++-common/goacc/asyncwait-1.c
+++ b/gcc/testsuite/c-c++-common/goacc/asyncwait-1.c
@@ -116,7 +116,6 @@ f (int N, float *a, float *b)
     }
 
 #pragma acc parallel copyin (a[0:N]) copy (b[0:N]) wait (1 /* { dg-error "expected '\\\)' before end of line" } */
-    /* { dg-error "expected integer expression before '\\\)'" "" { target c++ } .-1 } */
     {
         for (ii = 0; ii < N; ii++)
             b[ii] = a[ii];
@@ -152,6 +151,12 @@ f (int N, float *a, float *b)
             b[ii] = a[ii];
     }
 
+#pragma acc parallel copyin (a[0:N]) copy (b[0:N]) wait ( /* { dg-error "expected (primary-|)expression before" } */
+    {
+        for (ii = 0; ii < N; ii++)
+            b[ii] = a[ii];
+    }
+
 #pragma acc parallel copyin (a[0:N]) copy (b[0:N]) wait
     {
         for (ii = 0; ii < N; ii++)
@@ -171,7 +176,6 @@ f (int N, float *a, float *b)
 #pragma acc wait (1,2,,) /* { dg-error "expected (primary-|)expression before" } */
 
 #pragma acc wait (1 /* { dg-error "expected '\\\)' before end of line" } */
-    /* { dg-error "expected integer expression before '\\\)'" "" { target c++ } .-1 } */
 
 #pragma acc wait (1,*) /* { dg-error "expected (primary-|)expression before" } */
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]