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 2/3] Correct the reported line number in c++ combined OpenACC directives


Hi!

On Wed, 25 Jul 2018 08:29:18 -0700, Cesar Philippidis <cesar@codesourcery.com> wrote:
> Like the fortran FE, the C++ FE doesn't set the expr_location of the
> split acc loop in combined acc parallel/kernels loop directives. This
> only happens for with combined directives, otherwise
> cp_parser_omp_construct would be responsible for setting the
> location. After fixing this bug, I was able to resolve a couple of
> long standing diagnostics discrepancies between the c/c++ FEs in the
> test suite.
> 
> Is this patch OK for trunk? I bootstrapped and regtested using x86_64
> with nvptx offloading.

Thanks, committed to trunk in r266923:

commit 21fb940c5d500a1a8e850b59412fb506aa51181a
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sun Dec 9 12:48:26 2018 +0000

    Correct the reported line number in C++ combined OpenACC directives
    
    The C++ FE doesn't set the expr_location of the split acc loop in combined acc
    parallel/kernels loop directives. This only happens for with combined
    directives, otherwise cp_parser_omp_construct would be responsible for setting
    the location. After fixing this bug, I was able to resolve a couple of long
    standing diagnostics discrepancies between the C/C++ FEs in the test suite.
    
            gcc/cp/
            * parser.c (cp_parser_oacc_kernels_parallel): Adjust EXPR_LOCATION
            on the combined acc loop.
            gcc/testsuite/
            * c-c++-common/goacc/combined-directives-3.c: New test.
            * c-c++-common/goacc/loop-2-kernels.c (void K): Adjust test.
            * c-c++-common/goacc/loop-2-parallel.c (void P): Adjust test.
            * c-c++-common/goacc/loop-3.c (void p2): Adjust test.
    
    Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@266923 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/cp/ChangeLog                                   |  5 ++++
 gcc/cp/parser.c                                    |  5 ++--
 gcc/testsuite/ChangeLog                            |  7 ++++++
 .../c-c++-common/goacc/combined-directives-3.c     | 24 +++++++++++++++++++
 gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c  | 24 +++++++++----------
 gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c | 28 +++++++++++-----------
 gcc/testsuite/c-c++-common/goacc/loop-3.c          | 24 +++++++++----------
 7 files changed, 77 insertions(+), 40 deletions(-)

diff --git gcc/cp/ChangeLog gcc/cp/ChangeLog
index fc22f206606b..672be2d072db 100644
--- gcc/cp/ChangeLog
+++ gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2018-12-09  Cesar Philippidis  <cesar@codesourcery.com>
+
+	* parser.c (cp_parser_oacc_kernels_parallel): Adjust EXPR_LOCATION
+	on the combined acc loop.
+
 2018-12-07  Paolo Carlini  <paolo.carlini@oracle.com>
 
 	* decl2.c (grokbitfield): Use DECL_SOURCE_LOCATION in error messages
diff --git gcc/cp/parser.c gcc/cp/parser.c
index adfe09e494dc..8b669a82b147 100644
--- gcc/cp/parser.c
+++ gcc/cp/parser.c
@@ -38742,8 +38742,9 @@ cp_parser_oacc_kernels_parallel (cp_parser *parser, cp_token *pragma_tok,
 	  cp_lexer_consume_token (parser->lexer);
 	  tree block = begin_omp_parallel ();
 	  tree clauses;
-	  cp_parser_oacc_loop (parser, pragma_tok, p_name, mask, &clauses,
-			       if_p);
+	  tree stmt = cp_parser_oacc_loop (parser, pragma_tok, p_name, mask,
+					   &clauses, if_p);
+	  protected_set_expr_location (stmt, pragma_tok->location);
 	  return finish_omp_construct (code, block, clauses);
 	}
     }
diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog
index 192a29ee971c..6b26f6f510db 100644
--- gcc/testsuite/ChangeLog
+++ gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2018-12-09  Cesar Philippidis  <cesar@codesourcery.com>
+
+	* c-c++-common/goacc/combined-directives-3.c: New test.
+	* c-c++-common/goacc/loop-2-kernels.c (void K): Adjust test.
+	* c-c++-common/goacc/loop-2-parallel.c (void P): Adjust test.
+	* c-c++-common/goacc/loop-3.c (void p2): Adjust test.
+
 2018-12-09  Thomas Schwinge  <thomas@codesourcery.com>
 
 	* gfortran.dg/goacc/loop-2-kernels.f95: Update.
diff --git gcc/testsuite/c-c++-common/goacc/combined-directives-3.c gcc/testsuite/c-c++-common/goacc/combined-directives-3.c
new file mode 100644
index 000000000000..77d418262eac
--- /dev/null
+++ gcc/testsuite/c-c++-common/goacc/combined-directives-3.c
@@ -0,0 +1,24 @@
+/* Verify the accuracy of the line number associated with combined
+   constructs.  */
+
+int
+main ()
+{
+  int x, y, z;
+
+#pragma acc parallel loop seq auto /* { dg-error "'seq' overrides other OpenACC loop specifiers" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop
+    for (y = 0; y < 10; y++)
+      ;
+
+#pragma acc parallel loop gang auto /* { dg-error "'auto' conflicts with other OpenACC loop specifiers" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop worker auto /* { dg-error "'auto' conflicts with other OpenACC loop specifiers" } */
+    for (y = 0; y < 10; y++)
+#pragma acc loop vector
+      for (z = 0; z < 10; z++)
+	;
+
+  return 0;
+}
diff --git gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c
index 93e1cece26b4..01515089a7d8 100644
--- gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c
+++ gcc/testsuite/c-c++-common/goacc/loop-2-kernels.c
@@ -147,8 +147,8 @@ void K(void)
 #pragma acc kernels loop worker(num:5)
   for (i = 0; i < 10; i++)
     { }
-#pragma acc kernels loop seq worker // { dg-error "'seq' overrides" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+#pragma acc kernels loop seq worker // { dg-error "'seq' overrides" }
+  for (i = 0; i < 10; i++)
     { }
 #pragma acc kernels loop gang worker
   for (i = 0; i < 10; i++)
@@ -163,8 +163,8 @@ void K(void)
 #pragma acc kernels loop vector(length:5)
   for (i = 0; i < 10; i++)
     { }
-#pragma acc kernels loop seq vector // { dg-error "'seq' overrides" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+#pragma acc kernels loop seq vector // { dg-error "'seq' overrides" }
+  for (i = 0; i < 10; i++)
     { }
 #pragma acc kernels loop gang vector
   for (i = 0; i < 10; i++)
@@ -176,16 +176,16 @@ void K(void)
 #pragma acc kernels loop auto
   for (i = 0; i < 10; i++)
     { }
-#pragma acc kernels loop seq auto // { dg-error "'seq' overrides" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+#pragma acc kernels loop seq auto // { dg-error "'seq' overrides" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc kernels loop gang auto // { dg-error "'auto' conflicts" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+#pragma acc kernels loop gang auto // { dg-error "'auto' conflicts" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc kernels loop worker auto // { dg-error "'auto' conflicts" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+#pragma acc kernels loop worker auto // { dg-error "'auto' conflicts" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc kernels loop vector auto // { dg-error "'auto' conflicts" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+#pragma acc kernels loop vector auto // { dg-error "'auto' conflicts" }
+  for (i = 0; i < 10; i++)
     { }
 }
diff --git gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c
index 5b1e9d7ce87f..e3e6786e572c 100644
--- gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c
+++ gcc/testsuite/c-c++-common/goacc/loop-2-parallel.c
@@ -117,16 +117,16 @@ void P(void)
   for (i = 0; i < 10; i++)
     { }
 
-#pragma acc parallel loop seq gang // { dg-error "'seq' overrides" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+#pragma acc parallel loop seq gang // { dg-error "'seq' overrides" }
+  for (i = 0; i < 10; i++)
     { }
 
 #pragma acc parallel loop worker
   for (i = 0; i < 10; i++)
     { }
 
-#pragma acc parallel loop seq worker // { dg-error "'seq' overrides" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+#pragma acc parallel loop seq worker // { dg-error "'seq' overrides" }
+  for (i = 0; i < 10; i++)
     { }
 #pragma acc parallel loop gang worker
   for (i = 0; i < 10; i++)
@@ -136,8 +136,8 @@ void P(void)
   for (i = 0; i < 10; i++)
     { }
 
-#pragma acc parallel loop seq vector // { dg-error "'seq' overrides" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+#pragma acc parallel loop seq vector // { dg-error "'seq' overrides" }
+  for (i = 0; i < 10; i++)
     { }
 #pragma acc parallel loop gang vector
   for (i = 0; i < 10; i++)
@@ -149,16 +149,16 @@ void P(void)
 #pragma acc parallel loop auto
   for (i = 0; i < 10; i++)
     { }
-#pragma acc parallel loop seq auto // { dg-error "'seq' overrides" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'seq' overrides" "" { target c++ } }
+#pragma acc parallel loop seq auto // { dg-error "'seq' overrides" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc parallel loop gang auto // { dg-error "'auto' conflicts" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+#pragma acc parallel loop gang auto // { dg-error "'auto' conflicts" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc parallel loop worker auto // { dg-error "'auto' conflicts" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+#pragma acc parallel loop worker auto // { dg-error "'auto' conflicts" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc parallel loop vector auto // { dg-error "'auto' conflicts" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "'auto' conflicts" "" { target c++ } }
+#pragma acc parallel loop vector auto // { dg-error "'auto' conflicts" }
+  for (i = 0; i < 10; i++)
     { }
 }
diff --git gcc/testsuite/c-c++-common/goacc/loop-3.c gcc/testsuite/c-c++-common/goacc/loop-3.c
index e6c3f18042e6..ad5a4bd5aa9a 100644
--- gcc/testsuite/c-c++-common/goacc/loop-3.c
+++ gcc/testsuite/c-c++-common/goacc/loop-3.c
@@ -37,24 +37,24 @@ void p2 (void)
 {
   int i, j;
 
-#pragma acc parallel loop gang(5) // { dg-error "argument not permitted" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+#pragma acc parallel loop gang(5) // { dg-error "argument not permitted" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc parallel loop gang(num:5) // { dg-error "argument not permitted" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+#pragma acc parallel loop gang(num:5) // { dg-error "argument not permitted" }
+  for (i = 0; i < 10; i++)
     { }
 
-#pragma acc parallel loop worker(5) // { dg-error "argument not permitted" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+#pragma acc parallel loop worker(5) // { dg-error "argument not permitted" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc parallel loop worker(num:5) // { dg-error "argument not permitted" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+#pragma acc parallel loop worker(num:5) // { dg-error "argument not permitted" }
+  for (i = 0; i < 10; i++)
     { }
 
-#pragma acc parallel loop vector(5) // { dg-error "argument not permitted" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+#pragma acc parallel loop vector(5) // { dg-error "argument not permitted" }
+  for (i = 0; i < 10; i++)
     { }
-#pragma acc parallel loop vector(length:5) // { dg-error "argument not permitted" "" { target c } }
-  for (i = 0; i < 10; i++) // { dg-error "argument not permitted" "" { target c++ } }
+#pragma acc parallel loop vector(length:5) // { dg-error "argument not permitted" }
+  for (i = 0; i < 10; i++)
     { }
 }


Grüße
 Thomas


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