From: Thomas Schwinge Date: Fri, 19 May 2017 13:32:19 +0000 (+0200) Subject: OpenACC default clause maintenance X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9740ed54a6daf89d224a169d93412e6d821fad3c;p=gcc.git OpenACC default clause maintenance gcc/cp/ * parser.c (cp_parser_omp_clause_default): Avoid printing more than one syntax error message. gcc/testsuite/ * c-c++-common/goacc/default-1.c: New file. * c-c++-common/goacc/default-2.c: Likewise. * c-c++-common/goacc/data-default-1.c: Remove file, including its test cases in... * c-c++-common/goacc/default-3.c: ... this new file, and... * c-c++-common/goacc/default-4.c: ... this new file. * gfortran.dg/goacc/default.f95: Remove file, including its test cases in... * gfortran.dg/goacc/default-1.f95: ... this new file, and... * gfortran.dg/goacc/default-2.f: ... this new file. * gfortran.dg/goacc/default-3.f95: New file. * gfortran.dg/goacc/default-4.f: Likewise. From-SVN: r248278 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 09c82699b46..c89f71981e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-05-19 Thomas Schwinge + + * parser.c (cp_parser_omp_clause_default): Avoid printing more + than one syntax error message. + 2017-05-19 Nathan Sidwell * class.c (class_dump_id): Define. diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7a87a5e623d..6453397b530 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -31504,7 +31504,8 @@ cp_parser_omp_clause_default (cp_parser *parser, tree list, cp_parser_error (parser, "expected % or %"); } - if (!cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) + if (kind == OMP_CLAUSE_DEFAULT_UNSPECIFIED + || !cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN)) cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true, /*or_comma=*/false, /*consume_paren=*/true); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5f0fe80684e..ca901c29a66 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,18 @@ +2017-05-19 Thomas Schwinge + + * c-c++-common/goacc/default-1.c: New file. + * c-c++-common/goacc/default-2.c: Likewise. + * c-c++-common/goacc/data-default-1.c: Remove file, including its + test cases in... + * c-c++-common/goacc/default-3.c: ... this new file, and... + * c-c++-common/goacc/default-4.c: ... this new file. + * gfortran.dg/goacc/default.f95: Remove file, including its test + cases in... + * gfortran.dg/goacc/default-1.f95: ... this new file, and... + * gfortran.dg/goacc/default-2.f: ... this new file. + * gfortran.dg/goacc/default-3.f95: New file. + * gfortran.dg/goacc/default-4.f: Likewise. + 2017-05-19 Nathan Sidwell * g++.dg/inherit/covariant7.C: Adjust. diff --git a/gcc/testsuite/c-c++-common/goacc/data-default-1.c b/gcc/testsuite/c-c++-common/goacc/data-default-1.c deleted file mode 100644 index ec53cbed517..00000000000 --- a/gcc/testsuite/c-c++-common/goacc/data-default-1.c +++ /dev/null @@ -1,37 +0,0 @@ -/* { dg-do compile } */ - - -int main () -{ - int n = 2; - int ary[2]; - -#pragma acc parallel default (none) /* { dg-message "'parallel' construct" "2" } */ - { - ary[0] /* { dg-error "not specified in enclosing" } */ - = n; /* { dg-error "not specified in enclosing" } */ - } - -#pragma acc kernels default (none) /* { dg-message "'kernels' construct" "2" } */ - { - ary[0] /* { dg-error "not specified in enclosing" } */ - = n; /* { dg-error "not specified in enclosing" } */ - } - -#pragma acc data copy (ary, n) - { -#pragma acc parallel default (none) - { - ary[0] - = n; - } - -#pragma acc kernels default (none) - { - ary[0] - = n; - } - } - - return 0; -} diff --git a/gcc/testsuite/c-c++-common/goacc/default-1.c b/gcc/testsuite/c-c++-common/goacc/default-1.c new file mode 100644 index 00000000000..4d31dbc981b --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/default-1.c @@ -0,0 +1,9 @@ +/* OpenACC default clause: valid syntax. */ + +void f1 () +{ +#pragma acc kernels default (none) + ; +#pragma acc parallel default (none) + ; +} diff --git a/gcc/testsuite/c-c++-common/goacc/default-2.c b/gcc/testsuite/c-c++-common/goacc/default-2.c new file mode 100644 index 00000000000..d6b6cdce4d7 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/default-2.c @@ -0,0 +1,59 @@ +/* OpenACC default clause: invalid syntax. */ + +void f1 () +{ +#pragma acc kernels default /* { dg-error "expected .\\(. before end of line" } */ + ; +#pragma acc parallel default /* { dg-error "expected .\\(. before end of line" } */ + ; + +#pragma acc kernels default ( /* { dg-error "expected .none. before end of line" } */ + ; +#pragma acc parallel default ( /* { dg-error "expected .none. before end of line" } */ + ; + +#pragma acc kernels default (, /* { dg-error "expected .none. before .,. token" } */ + ; +#pragma acc parallel default (, /* { dg-error "expected .none. before .,. token" } */ + ; + +#pragma acc kernels default () /* { dg-error "expected .none. before .\\). token" } */ + ; +#pragma acc parallel default () /* { dg-error "expected .none. before .\\). token" } */ + ; + +#pragma acc kernels default (,) /* { dg-error "expected .none. before .,. token" } */ + ; +#pragma acc parallel default (,) /* { dg-error "expected .none. before .,. token" } */ + ; + +#pragma acc kernels default (firstprivate) /* { dg-error "expected .none. before .firstprivate." } */ + ; +#pragma acc parallel default (firstprivate) /* { dg-error "expected .none. before .firstprivate." } */ + ; + +#pragma acc kernels default (private) /* { dg-error "expected .none. before .private." } */ + ; +#pragma acc parallel default (private) /* { dg-error "expected .none. before .private." } */ + ; + +#pragma acc kernels default (shared) /* { dg-error "expected .none. before .shared." } */ + ; +#pragma acc parallel default (shared) /* { dg-error "expected .none. before .shared." } */ + ; + +#pragma acc kernels default (none /* { dg-error "expected .\\). before end of line" } */ + ; +#pragma acc parallel default (none /* { dg-error "expected .\\). before end of line" } */ + ; + +#pragma acc kernels default (none none) /* { dg-error "expected .\\). before .none." } */ + ; +#pragma acc parallel default (none none) /* { dg-error "expected .\\). before .none." } */ + ; + +#pragma acc kernels default (none, none) /* { dg-error "expected .\\). before .,. token" } */ + ; +#pragma acc parallel default (none, none) /* { dg-error "expected .\\). before .,. token" } */ + ; +} diff --git a/gcc/testsuite/c-c++-common/goacc/default-3.c b/gcc/testsuite/c-c++-common/goacc/default-3.c new file mode 100644 index 00000000000..ac169a903e9 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/default-3.c @@ -0,0 +1,18 @@ +/* OpenACC default (none) clause. */ + +void f1 () +{ + int f1_a = 2; + float f1_b[2]; + +#pragma acc kernels default (none) /* { dg-message "enclosing OpenACC .kernels. construct" } */ + { + f1_b[0] /* { dg-error ".f1_b. not specified in enclosing OpenACC .kernels. construct" } */ + = f1_a; /* { dg-error ".f1_a. not specified in enclosing OpenACC .kernels. construct" } */ + } +#pragma acc parallel default (none) /* { dg-message "enclosing OpenACC .parallel. construct" } */ + { + f1_b[0] /* { dg-error ".f1_b. not specified in enclosing OpenACC .parallel. construct" } */ + = f1_a; /* { dg-error ".f1_a. not specified in enclosing OpenACC .parallel. construct" } */ + } +} diff --git a/gcc/testsuite/c-c++-common/goacc/default-4.c b/gcc/testsuite/c-c++-common/goacc/default-4.c new file mode 100644 index 00000000000..787b35256db --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/default-4.c @@ -0,0 +1,45 @@ +/* OpenACC default clause inside data construct. */ + +/* { dg-additional-options "-fdump-tree-gimple" } */ + +void f1 () +{ + int f1_a = 2; + float f1_b[2]; + +#pragma acc data copyin (f1_a) copyout (f1_b) + /* { dg-final { scan-tree-dump-times "omp target oacc_data map\\(force_from:f1_b \[^\\)\]+\\) map\\(force_to:f1_a" 1 "gimple" } } */ + { +#pragma acc kernels + /* { dg-final { scan-tree-dump-times "omp target oacc_kernels map\\(tofrom:f1_b \[^\\)\]+\\) map\\(tofrom:f1_a" 1 "gimple" } } */ + { + f1_b[0] = f1_a; + } +#pragma acc parallel + /* { dg-final { scan-tree-dump-times "omp target oacc_parallel map\\(tofrom:f1_b \[^\\)\]+\\) map\\(tofrom:f1_a" 1 "gimple" } } */ + { + f1_b[0] = f1_a; + } + } +} + +void f2 () +{ + int f2_a = 2; + float f2_b[2]; + +#pragma acc data copyin (f2_a) copyout (f2_b) + /* { dg-final { scan-tree-dump-times "omp target oacc_data map\\(force_from:f2_b \[^\\)\]+\\) map\\(force_to:f2_a" 1 "gimple" } } */ + { +#pragma acc kernels default (none) + /* { dg-final { scan-tree-dump-times "omp target oacc_kernels default\\(none\\) map\\(tofrom:f2_b \[^\\)\]+\\) map\\(tofrom:f2_a" 1 "gimple" } } */ + { + f2_b[0] = f2_a; + } +#pragma acc parallel default (none) + /* { dg-final { scan-tree-dump-times "omp target oacc_parallel default\\(none\\) map\\(tofrom:f2_b \[^\\)\]+\\) map\\(tofrom:f2_a" 1 "gimple" } } */ + { + f2_b[0] = f2_a; + } + } +} diff --git a/gcc/testsuite/gfortran.dg/goacc/default-1.f95 b/gcc/testsuite/gfortran.dg/goacc/default-1.f95 new file mode 100644 index 00000000000..a79b444f6f4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/default-1.f95 @@ -0,0 +1,10 @@ +! OpenACC default clause: valid syntax. + +subroutine f1 + implicit none + + !$acc kernels default (none) + !$acc end kernels + !$acc parallel default (none) + !$acc end parallel +end subroutine f1 diff --git a/gcc/testsuite/gfortran.dg/goacc/default-2.f b/gcc/testsuite/gfortran.dg/goacc/default-2.f new file mode 100644 index 00000000000..8f886887f4b --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/default-2.f @@ -0,0 +1,60 @@ +! OpenACC default clause: invalid syntax. + + SUBROUTINE F1 + IMPLICIT NONE + +!$ACC KERNELS DEFAULT ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT ( ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT ( ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT (, ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT (, ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT () ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT () ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT (,) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT (,) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT (FIRSTPRIVATE) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT (FIRSTPRIVATE) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT (PRIVATE) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT (PRIVATE) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT (SHARED) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT (SHARED) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT (NONE ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT (NONE ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT (NONE NONE) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT (NONE NONE) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + +!$ACC KERNELS DEFAULT (NONE, NONE) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END KERNELS ! { dg-error "Unexpected" } +!$ACC PARALLEL DEFAULT (NONE, NONE) ! { dg-error "Unclassifiable OpenACC directive" } +!$ACC END PARALLEL ! { dg-error "Unexpected" } + END SUBROUTINE F1 diff --git a/gcc/testsuite/gfortran.dg/goacc/default-3.f95 b/gcc/testsuite/gfortran.dg/goacc/default-3.f95 new file mode 100644 index 00000000000..98ed34200c6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/default-3.f95 @@ -0,0 +1,18 @@ +! OpenACC default (none) clause. + +subroutine f1 + implicit none + integer :: f1_a = 2 + real, dimension (2) :: f1_b + + !$acc kernels default (none) ! { dg-message "enclosing OpenACC .kernels. construct" } + f1_b(1) & ! { dg-error ".f1_b. not specified in enclosing OpenACC .kernels. construct" "" { xfail *-*-* } } + = f1_a; ! { dg-error ".f1_a. not specified in enclosing OpenACC .kernels. construct" } + ! { dg-bogus ".f1_b. not specified in enclosing OpenACC .kernels. construct" "" { xfail *-*-* } .-1 } + !$acc end kernels + !$acc parallel default (none) ! { dg-message "enclosing OpenACC .parallel. construct" } + f1_b(1) & ! { dg-error ".f1_b. not specified in enclosing OpenACC .parallel. construct" "" { xfail *-*-* } } + = f1_a; ! { dg-error ".f1_a. not specified in enclosing OpenACC .parallel. construct" } + ! { dg-bogus ".f1_b. not specified in enclosing OpenACC .parallel. construct" "" { xfail *-*-* } .-1 } + !$acc end parallel +end subroutine f1 diff --git a/gcc/testsuite/gfortran.dg/goacc/default-4.f b/gcc/testsuite/gfortran.dg/goacc/default-4.f new file mode 100644 index 00000000000..b2f73c3bcfb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/default-4.f @@ -0,0 +1,39 @@ +! OpenACC default clause inside data construct. + +! { dg-additional-options "-fdump-tree-gimple" } + + SUBROUTINE F1 + IMPLICIT NONE + INTEGER :: F1_A = 2 + REAL, DIMENSION (2) :: F1_B + +!$ACC DATA COPYIN (F1_A) COPYOUT (F1_B) +! { dg-final { scan-tree-dump-times "omp target oacc_data map\\(force_to:f1_a \[^\\)\]+\\) map\\(force_from:f1_b" 1 "gimple" } } +!$ACC KERNELS +! { dg-final { scan-tree-dump-times "omp target oacc_kernels map\\(tofrom:f1_b \[^\\)\]+\\) map\\(tofrom:f1_a" 1 "gimple" } } + F1_B(1) = F1_A; +!$ACC END KERNELS +!$ACC PARALLEL +! { dg-final { scan-tree-dump-times "omp target oacc_parallel map\\(tofrom:f1_b \[^\\)\]+\\) map\\(tofrom:f1_a" 1 "gimple" } } + F1_B(1) = F1_A; +!$ACC END PARALLEL +!$ACC END DATA + END SUBROUTINE F1 + + SUBROUTINE F2 + IMPLICIT NONE + INTEGER :: F2_A = 2 + REAL, DIMENSION (2) :: F2_B + +!$ACC DATA COPYIN (F2_A) COPYOUT (F2_B) +! { dg-final { scan-tree-dump-times "omp target oacc_data map\\(force_to:f2_a \[^\\)\]+\\) map\\(force_from:f2_b" 1 "gimple" } } +!$ACC KERNELS DEFAULT (NONE) +! { dg-final { scan-tree-dump-times "omp target oacc_kernels default\\(none\\) map\\(tofrom:f2_b \[^\\)\]+\\) map\\(tofrom:f2_a" 1 "gimple" } } + F2_B(1) = F2_A; +!$ACC END KERNELS +!$ACC PARALLEL DEFAULT (NONE) +! { dg-final { scan-tree-dump-times "omp target oacc_parallel default\\(none\\) map\\(tofrom:f2_b \[^\\)\]+\\) map\\(tofrom:f2_a" 1 "gimple" } } + F2_B(1) = F2_A; +!$ACC END PARALLEL +!$ACC END DATA + END SUBROUTINE F2 diff --git a/gcc/testsuite/gfortran.dg/goacc/default.f95 b/gcc/testsuite/gfortran.dg/goacc/default.f95 deleted file mode 100644 index c1fc52e6014..00000000000 --- a/gcc/testsuite/gfortran.dg/goacc/default.f95 +++ /dev/null @@ -1,17 +0,0 @@ -! { dg-do compile } - -program tile - integer i, j, a - - !$acc parallel default (shared) ! { dg-error "Unclassifiable OpenACC directive" } - !$acc end parallel ! { dg-error "Unexpected" } - - !$acc parallel default (private) ! { dg-error "Unclassifiable OpenACC directive" } - !$acc end parallel ! { dg-error "Unexpected" } - - !$acc parallel default (none) - !$acc end parallel - - !$acc parallel default (firstprivate) ! { dg-error "Unclassifiable OpenACC directive" } - !$acc end parallel ! { dg-error "Unexpected" } -end program tile