diff mbox

[PING] Remove incorrect warning for kernels copy clause

Message ID 57077197.4060405@mentor.com
State New
Headers show

Commit Message

Tom de Vries April 8, 2016, 8:53 a.m. UTC
On 05/04/16 12:16, Tom de Vries wrote:
> On 24/03/16 17:59, Tom de Vries wrote:
>> Hi,
>>
>> This patch fixes an incorrect warning for the oacc copy clause.
>>
>> Consider this test-case:
>> ...
>> void
>> foo (void)
>> {
>>    int i;
>>
>> #pragma acc kernels
>>    {
>>      i = 1;
>>    }
>> }
>> ...
>>
>>
>> When compiling with -fopenacc -Wuninitialized, we get an 'is used
>> uninitialized' warning for variable 'i', which is confusing given that
>> 'i' is not used, but only set in the kernels region.
>>
>> The warning occurs because there's an implicit copy(i) clause on the
>> kernels region, and that copy generates a read of i before the region,
>> and a write to i in region.
>>
>> The patch silences the warning by marking the variable in the copy
>> clause with TREE_NO_WARNING.
>>
>> Build and reg-tested with goacc.exp, gomp.exp and target-libgomp.
>>
>> OK for trunk if bootstrap and reg-test succeeds?
>>
>
> Ping.
>

Committed as attached, with only the testcases. The code change has been 
committed as part of the fix for PR70550.

Thanks,
- TOm
diff mbox

Patch

Add goacc/uninit-copy-clause.{c,f95} testcases

2016-03-24  Tom de Vries  <tom@codesourcery.com>

	* c-c++-common/goacc/uninit-copy-clause.c: New test.
	* gfortran.dg/goacc/uninit-copy-clause.f95: New test.

---
 .../c-c++-common/goacc/uninit-copy-clause.c        | 38 ++++++++++++++++++++++
 .../gfortran.dg/goacc/uninit-copy-clause.f95       | 29 +++++++++++++++++
 2 files changed, 67 insertions(+)

diff --git a/gcc/testsuite/c-c++-common/goacc/uninit-copy-clause.c b/gcc/testsuite/c-c++-common/goacc/uninit-copy-clause.c
new file mode 100644
index 0000000..b3cc445
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/uninit-copy-clause.c
@@ -0,0 +1,38 @@ 
+/* { dg-do compile } */
+/* { dg-additional-options "-Wuninitialized" } */
+
+void
+foo (void)
+{
+  int i;
+
+#pragma acc kernels
+  {
+    i = 1;
+  }
+
+}
+
+void
+foo2 (void)
+{
+  int i;
+
+#pragma acc kernels copy (i)
+  {
+    i = 1;
+  }
+
+}
+
+void
+foo3 (void)
+{
+  int i;
+
+#pragma acc kernels copyin(i)
+  {
+    i = 1;
+  }
+
+}
diff --git a/gcc/testsuite/gfortran.dg/goacc/uninit-copy-clause.f95 b/gcc/testsuite/gfortran.dg/goacc/uninit-copy-clause.f95
new file mode 100644
index 0000000..b2aae1d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/uninit-copy-clause.f95
@@ -0,0 +1,29 @@ 
+! { dg-do compile }
+! { dg-additional-options "-Wuninitialized" }
+
+subroutine foo
+  integer :: i
+
+  !$acc kernels
+  i = 1
+  !$acc end kernels
+
+end subroutine foo
+
+subroutine foo2
+  integer :: i
+
+  !$acc kernels copy (i)
+  i = 1
+  !$acc end kernels
+
+end subroutine foo2
+
+subroutine foo3
+  integer :: i
+
+  !$acc kernels copyin (i)
+  i = 1
+  !$acc end kernels
+
+end subroutine foo3