[gomp] Support Fortran OpenMP conditional inclusion
Jakub Jelinek
jakub@redhat.com
Tue Sep 19 09:38:00 GMT 2006
Hi!
Although the OpenMP 2.5 standard is quite unclear about this (it only talks
about conditional initial and continuation lines, while include lines are
separate category in the Fortran standard), at least Intel ifort supports it
and it doesn't sound like a bad thing.
BTW, ifort for fixed form requires at least 6 spaces before include (and similarly
for !$ at least 4 spaces between include and !$), so
program
include 'foo.inc'
end
fixed form emits diagnostics (similarly g77), while gfortran accepts it. J3/97-007R2,
3.4 wording suggests that gfortran is right, is that something that should
be differentiated between -std=f77 and -std=f95?
2006-09-19 Jakub Jelinek <jakub@redhat.com>
PR fortran/29097
* scanner.c (include_line): Handle conditional include.
* testsuite/libgomp.fortran/condinc1.f: New test.
* testsuite/libgomp.fortran/condinc2.f: New test.
* testsuite/libgomp.fortran/condinc3.f90: New test.
* testsuite/libgomp.fortran/condinc4.f90: New test.
* testsuite/libgomp.fortran/condinc1.inc: New file.
--- gcc/fortran/scanner.c.jj 2006-06-09 14:59:02.000000000 +0200
+++ gcc/fortran/scanner.c 2006-09-19 10:58:31.000000000 +0200
@@ -1212,8 +1212,26 @@ static bool
include_line (char *line)
{
char quote, *c, *begin, *stop;
-
+
c = line;
+
+ if (gfc_option.flag_openmp)
+ {
+ if (gfc_current_form == FORM_FREE)
+ {
+ while (*c == ' ' || *c == '\t')
+ c++;
+ if (*c == '!' && c[1] == '$' && (c[2] == ' ' || c[2] == '\t'))
+ c += 3;
+ }
+ else
+ {
+ if ((*c == '!' || *c == 'c' || *c == 'C' || *c == '*')
+ && c[1] == '$' && (c[2] == ' ' || c[2] == '\t'))
+ c += 3;
+ }
+ }
+
while (*c == ' ' || *c == '\t')
c++;
--- libgomp/testsuite/libgomp.fortran/condinc1.f.jj 2006-09-19 11:01:22.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/condinc1.f 2006-09-19 11:09:18.000000000 +0200
@@ -0,0 +1,7 @@
+! { dg-options "-fopenmp" }
+ program condinc1
+ logical l
+ l = .false.
+!$ include 'condinc1.inc'
+ stop 2
+ end
--- libgomp/testsuite/libgomp.fortran/condinc1.inc.jj 2006-09-19 11:05:30.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/condinc1.inc 2006-09-19 11:08:17.000000000 +0200
@@ -0,0 +1,2 @@
+ if (l) stop 3
+ return
--- libgomp/testsuite/libgomp.fortran/condinc2.f.jj 2006-09-19 11:01:22.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/condinc2.f 2006-09-19 11:09:09.000000000 +0200
@@ -0,0 +1,7 @@
+! { dg-options "-fno-openmp" }
+ program condinc2
+ logical l
+ l = .true.
+C$ include 'condinc1.inc'
+ return
+ end
--- libgomp/testsuite/libgomp.fortran/condinc3.f90.jj 2006-09-19 11:01:22.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/condinc3.f90 2006-09-19 11:10:23.000000000 +0200
@@ -0,0 +1,7 @@
+ ! { dg-options "-fopenmp" }
+program condinc3
+ logical l
+ l = .false.
+ !$ include 'condinc1.inc'
+ stop 2
+end
--- libgomp/testsuite/libgomp.fortran/condinc4.f90.jj 2006-09-19 11:01:22.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/condinc4.f90 2006-09-19 11:10:51.000000000 +0200
@@ -0,0 +1,7 @@
+! { dg-options "-fno-openmp" }
+ program condinc4
+ logical l
+ l = .true.
+!$ include 'condinc1.inc'
+ return
+ end
Jakub
More information about the Fortran
mailing list