aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-11-30 15:30:51 +0100
committerTobias Burnus <tobias@codesourcery.com>2020-11-30 15:31:22 +0100
commit1d6f6ac693a8601bef9fe4ba72eb6fbf7b60b5cd (patch)
treebec2e4d4f4cfceba9cf8a2293efb0bd04496eae0 /gcc
parentf4e7ea81d1369d4d6cb6d8e440aefb3407142e05 (diff)
downloadgcc-1d6f6ac693a8601bef9fe4ba72eb6fbf7b60b5cd.zip
gcc-1d6f6ac693a8601bef9fe4ba72eb6fbf7b60b5cd.tar.gz
gcc-1d6f6ac693a8601bef9fe4ba72eb6fbf7b60b5cd.tar.bz2
Fortran: With OpenACC, ignore OpenMP's cond comp sentinels
gcc/fortran/ChangeLog: PR fortran/98011 * scanner.c (skip_free_comments, skip_fixed_comments): If only -fopenacc but not -fopenmp is used, ignore OpenMP's conditional compilation sentinels. Fix indentation, use 'else if' for readability. gcc/testsuite/ChangeLog: PR fortran/98011 * gfortran.dg/goacc/sentinel-free-form.f95: * gfortran.dg/goacc-gomp/fixed-1.f: New test. * gfortran.dg/goacc-gomp/free-1.f90: New test. * gfortran.dg/goacc/fixed-5.f: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/scanner.c32
-rw-r--r--gcc/testsuite/gfortran.dg/goacc-gomp/fixed-1.f81
-rw-r--r--gcc/testsuite/gfortran.dg/goacc-gomp/free-1.f9034
-rw-r--r--gcc/testsuite/gfortran.dg/goacc/fixed-5.f30
-rw-r--r--gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f957
5 files changed, 161 insertions, 23 deletions
diff --git a/gcc/fortran/scanner.c b/gcc/fortran/scanner.c
index fd11f5a..304ae2d 100644
--- a/gcc/fortran/scanner.c
+++ b/gcc/fortran/scanner.c
@@ -899,21 +899,14 @@ skip_free_comments (void)
if (next_char () == '$')
{
c = next_char ();
- if (c == 'a' || c == 'A')
- {
- if (skip_free_oacc_sentinel (start, old_loc))
- return false;
- gfc_current_locus = old_loc;
- next_char();
- c = next_char();
- }
- if (continue_flag || c == ' ' || c == '\t')
- {
- gfc_current_locus = old_loc;
- next_char();
- openacc_flag = 0;
- return true;
- }
+ if (c == 'a' || c == 'A')
+ {
+ if (skip_free_oacc_sentinel (start, old_loc))
+ return false;
+ gfc_current_locus = old_loc;
+ next_char();
+ c = next_char();
+ }
}
gfc_current_locus = old_loc;
}
@@ -1076,8 +1069,7 @@ skip_fixed_comments (void)
}
gfc_current_locus = start;
}
-
- if (flag_openacc && !(flag_openmp || flag_openmp_simd))
+ else if (flag_openacc && !(flag_openmp || flag_openmp_simd))
{
if (next_char () == '$')
{
@@ -1087,13 +1079,10 @@ skip_fixed_comments (void)
if (skip_fixed_oacc_sentinel (&start))
return;
}
- else
- goto check_for_digits;
}
gfc_current_locus = start;
}
-
- if (flag_openacc || flag_openmp || flag_openmp_simd)
+ else if (flag_openacc || flag_openmp || flag_openmp_simd)
{
if (next_char () == '$')
{
@@ -1120,6 +1109,7 @@ skip_fixed_comments (void)
gcc_unreachable ();
check_for_digits:
{
+ /* Required for OpenMP's conditional compilation sentinel. */
int digit_seen = 0;
for (col = 3; col < 6; col++, c = next_char ())
diff --git a/gcc/testsuite/gfortran.dg/goacc-gomp/fixed-1.f b/gcc/testsuite/gfortran.dg/goacc-gomp/fixed-1.f
new file mode 100644
index 0000000..b6bab4c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc-gomp/fixed-1.f
@@ -0,0 +1,81 @@
+! { dg-additional-options "-fdump-tree-original -Wunused-variable" }
+ implicit none
+ integer :: a,b,c,d,e,f,g,h,i,j,k,ll
+
+c$bogus
+!$bogus
+*$bogus
+
+c$ bogus
+!$ bogus
+*$ bogus
+
+c$a23 bogus
+!$ a bogus
+*$12a bogus
+
+! The following should be parsed as OpenMP conditional sentinel
+! If not, expect a unused-variable warning
+
+c$ a = 1
+!$ b = 2
+*$ c = 3
+
+c$ 1 d = 4
+!$ 22 e = 5
+*$34 f = 6
+
+c$ g =
+c$ *7
+!$ 2 h =
+*$ & 8
+*$ 3 i
+!$ & = 9
+
+c$ j
+*$ &=
+c$ *10
+!$ 5 k
+*$ * =
+c$ & 1
+*$ & 1
+*$9 9 ll
+!$ & =
+!$ * 12
+
+c$ bogus
+!$ bogus
+*$ bogus
+
+c$bogus
+!$bogus
+*$bogus
+
+c$ acc bogus
+!$ acc bogus
+*$ acc bogus
+
+c$ omp bogus
+!$ omp bogus
+*$ omp bogus
+ end
+
+!{ dg-final { scan-tree-dump-times "a = 1;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "b = 2;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "c = 3;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "d = 4;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "e = 5;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "f = 6;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "g = 7;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "h = 8;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "i = 9;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "j = 10;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "k = 11;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "ll = 12;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "__label_000001:;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "__label_000022:;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "__label_000034:;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "__label_000002:;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "__label_000003:;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "__label_000005:;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "__label_000099:;" 1 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/goacc-gomp/free-1.f90 b/gcc/testsuite/gfortran.dg/goacc-gomp/free-1.f90
new file mode 100644
index 0000000..0d6f2b2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc-gomp/free-1.f90
@@ -0,0 +1,34 @@
+! { dg-additional-options "-fdump-tree-original -Wunused-variable" }
+implicit none
+integer :: a,b,c,d,e,f,g,h
+
+!$bogus
+
+ !$bogus
+!$& bogus
+ !$& bogus
+
+!$ a = 1
+!$ b = 2
+!$ c = &
+!$3
+
+!$ d = &
+!$&4
+
+ !$ e = 5
+ !$ f = 6
+ !$ g = &
+ !$7
+
+ !$ h = &
+!$&8
+ end
+
+!{ dg-final { scan-tree-dump-times "a = 1;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "b = 2;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "c = 3;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "d = 4;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "e = 5;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "f = 6;" 1 "original" } }
+!{ dg-final { scan-tree-dump-times "g = 7;" 1 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/goacc/fixed-5.f b/gcc/testsuite/gfortran.dg/goacc/fixed-5.f
new file mode 100644
index 0000000..ab51b21
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/fixed-5.f
@@ -0,0 +1,30 @@
+! Check that OpenMP conditional compilations sentinels ('!$ ') are ignored
+
+c$ bogus
+!$ bogus
+*$ bogus
+c$ bogus
+!$ bogus
+*$ bogus
+
+c$a23 bogus
+!$ a bogus
+*$12a bogus
+
+c$ 1 bogus
+!$ 22 bogus
+*$34 bogus
+
+c$bogus
+!$bogus
+*$bogus
+
+c$ acc bogus
+!$ acc bogus
+*$ acc bogus
+
+c$ acc bogus
+!$ acc bogus
+*$ acc bogus
+
+ end
diff --git a/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95 b/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95
index 1a3189c..00dac66 100644
--- a/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95
+++ b/gcc/testsuite/gfortran.dg/goacc/sentinel-free-form.f95
@@ -10,7 +10,10 @@ program test
x = 0.0 !$acc parallel ! comment
! sentinel must appear as a single word
! $acc parallel ! comment
- !$ acc parallel ! { dg-error "Unclassifiable statement" }
+
+ ! note that '!$ ' is OpenMP's conditional compilation sentinel
+ !$ acc ignored_due_to_space ! comment
+
! directive lines must have space after sentinel
!$accparallel ! { dg-warning "followed by a space" }
do i = 1,10
@@ -18,4 +21,4 @@ program test
enddo
!$acc end parallel ! { dg-error "Unexpected" }
print *, x
-end \ No newline at end of file
+end