diff --git a/flang/test/Semantics/OpenACC/acc-symbols01.f90 b/flang/test/Semantics/OpenACC/acc-symbols01.f90 --- a/flang/test/Semantics/OpenACC/acc-symbols01.f90 +++ b/flang/test/Semantics/OpenACC/acc-symbols01.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenacc +! RUN: %python %S/../test_symbols.py %s %t %flang_fc1 -fopenacc !DEF: /mm MainProgram program mm diff --git a/flang/test/Semantics/kinds01.f90 b/flang/test/Semantics/kinds01.f90 --- a/flang/test/Semantics/kinds01.f90 +++ b/flang/test/Semantics/kinds01.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 !DEF: /MainProgram1/jk1 ObjectEntity INTEGER(1) integer(kind=1) jk1 !DEF: /MainProgram1/js1 ObjectEntity INTEGER(1) diff --git a/flang/test/Semantics/kinds03.f90 b/flang/test/Semantics/kinds03.f90 --- a/flang/test/Semantics/kinds03.f90 +++ b/flang/test/Semantics/kinds03.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 !DEF: /MainProgram1/ipdt DerivedType !DEF: /MainProgram1/ipdt/k TypeParam INTEGER(4) type :: ipdt(k) diff --git a/flang/test/Semantics/omp-do-schedule03.f90 b/flang/test/Semantics/omp-do-schedule03.f90 --- a/flang/test/Semantics/omp-do-schedule03.f90 +++ b/flang/test/Semantics/omp-do-schedule03.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Schedule Clause ! Test that does not catch non constant integer expressions like xx - xx. diff --git a/flang/test/Semantics/omp-do-schedule04.f90 b/flang/test/Semantics/omp-do-schedule04.f90 --- a/flang/test/Semantics/omp-do-schedule04.f90 +++ b/flang/test/Semantics/omp-do-schedule04.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Schedule Clause ! Test that does not catch non constant integer expressions like xx - yy. diff --git a/flang/test/Semantics/omp-do01-positivecase.f90 b/flang/test/Semantics/omp-do01-positivecase.f90 --- a/flang/test/Semantics/omp-do01-positivecase.f90 +++ b/flang/test/Semantics/omp-do01-positivecase.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Loop Construct ! The loop iteration variable may not appear in a firstprivate directive. diff --git a/flang/test/Semantics/omp-do04-positivecase.f90 b/flang/test/Semantics/omp-do04-positivecase.f90 --- a/flang/test/Semantics/omp-do04-positivecase.f90 +++ b/flang/test/Semantics/omp-do04-positivecase.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Do Loop Constructs diff --git a/flang/test/Semantics/omp-do05-positivecase.f90 b/flang/test/Semantics/omp-do05-positivecase.f90 --- a/flang/test/Semantics/omp-do05-positivecase.f90 +++ b/flang/test/Semantics/omp-do05-positivecase.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Loop Construct restrictions on single directive. ! A positive case diff --git a/flang/test/Semantics/omp-do06-positivecases.f90 b/flang/test/Semantics/omp-do06-positivecases.f90 --- a/flang/test/Semantics/omp-do06-positivecases.f90 +++ b/flang/test/Semantics/omp-do06-positivecases.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Loop Construct ! The ordered clause must be present on the loop construct if any ordered diff --git a/flang/test/Semantics/omp-do11.f90 b/flang/test/Semantics/omp-do11.f90 --- a/flang/test/Semantics/omp-do11.f90 +++ b/flang/test/Semantics/omp-do11.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Do Loop Constructs diff --git a/flang/test/Semantics/omp-do12.f90 b/flang/test/Semantics/omp-do12.f90 --- a/flang/test/Semantics/omp-do12.f90 +++ b/flang/test/Semantics/omp-do12.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Do Loop constructs. diff --git a/flang/test/Semantics/omp-do14.f90 b/flang/test/Semantics/omp-do14.f90 --- a/flang/test/Semantics/omp-do14.f90 +++ b/flang/test/Semantics/omp-do14.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Do Loop constructs. diff --git a/flang/test/Semantics/omp-do17.f90 b/flang/test/Semantics/omp-do17.f90 --- a/flang/test/Semantics/omp-do17.f90 +++ b/flang/test/Semantics/omp-do17.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.7.1 Do Loop constructs. diff --git a/flang/test/Semantics/omp-reduction08.f90 b/flang/test/Semantics/omp-reduction08.f90 --- a/flang/test/Semantics/omp-reduction08.f90 +++ b/flang/test/Semantics/omp-reduction08.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.15.3.6 Reduction Clause Positive cases diff --git a/flang/test/Semantics/omp-reduction09.f90 b/flang/test/Semantics/omp-reduction09.f90 --- a/flang/test/Semantics/omp-reduction09.f90 +++ b/flang/test/Semantics/omp-reduction09.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! OpenMP Version 4.5 ! 2.15.3.6 Reduction Clause Positive cases. !DEF: /omp_reduction MainProgram diff --git a/flang/test/Semantics/omp-symbol01.f90 b/flang/test/Semantics/omp-symbol01.f90 --- a/flang/test/Semantics/omp-symbol01.f90 +++ b/flang/test/Semantics/omp-symbol01.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! Test clauses that accept list. ! 2.1 Directive Format diff --git a/flang/test/Semantics/omp-symbol02.f90 b/flang/test/Semantics/omp-symbol02.f90 --- a/flang/test/Semantics/omp-symbol02.f90 +++ b/flang/test/Semantics/omp-symbol02.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! 1.4.1 Structure of the OpenMP Memory Model diff --git a/flang/test/Semantics/omp-symbol03.f90 b/flang/test/Semantics/omp-symbol03.f90 --- a/flang/test/Semantics/omp-symbol03.f90 +++ b/flang/test/Semantics/omp-symbol03.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! 1.4.1 Structure of the OpenMP Memory Model ! In the inner OpenMP region, SHARED `a` refers to the `a` in the outer OpenMP diff --git a/flang/test/Semantics/omp-symbol04.f90 b/flang/test/Semantics/omp-symbol04.f90 --- a/flang/test/Semantics/omp-symbol04.f90 +++ b/flang/test/Semantics/omp-symbol04.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! 2.15.3 Data-Sharing Attribute Clauses ! Both PARALLEL and DO (worksharing) directives need to create new scope, diff --git a/flang/test/Semantics/omp-symbol05.f90 b/flang/test/Semantics/omp-symbol05.f90 --- a/flang/test/Semantics/omp-symbol05.f90 +++ b/flang/test/Semantics/omp-symbol05.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! 2.15.2 threadprivate Directive ! The threadprivate directive specifies that variables are replicated, diff --git a/flang/test/Semantics/omp-symbol06.f90 b/flang/test/Semantics/omp-symbol06.f90 --- a/flang/test/Semantics/omp-symbol06.f90 +++ b/flang/test/Semantics/omp-symbol06.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! 2.15.3 Data-Sharing Attribute Clauses ! A list item that specifies a given variable may not appear in more than diff --git a/flang/test/Semantics/omp-symbol07.f90 b/flang/test/Semantics/omp-symbol07.f90 --- a/flang/test/Semantics/omp-symbol07.f90 +++ b/flang/test/Semantics/omp-symbol07.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! Generic tests ! 1. subroutine or function calls should not be fixed for DSA or DMA diff --git a/flang/test/Semantics/omp-symbol08.f90 b/flang/test/Semantics/omp-symbol08.f90 --- a/flang/test/Semantics/omp-symbol08.f90 +++ b/flang/test/Semantics/omp-symbol08.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 -fopenmp +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 -fopenmp ! 2.15.1.1 Predetermined rules for associated do-loops index variable ! a) The loop iteration variable(s) in the associated do-loop(s) of a do, diff --git a/flang/test/Semantics/procinterface01.f90 b/flang/test/Semantics/procinterface01.f90 --- a/flang/test/Semantics/procinterface01.f90 +++ b/flang/test/Semantics/procinterface01.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Tests for "proc-interface" semantics. ! These cases are all valid. diff --git a/flang/test/Semantics/symbol01.f90 b/flang/test/Semantics/symbol01.f90 --- a/flang/test/Semantics/symbol01.f90 +++ b/flang/test/Semantics/symbol01.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Test that intent-stmt and subprogram prefix and suffix are resolved. !DEF: /m Module diff --git a/flang/test/Semantics/symbol02.f90 b/flang/test/Semantics/symbol02.f90 --- a/flang/test/Semantics/symbol02.f90 +++ b/flang/test/Semantics/symbol02.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Test host association in module subroutine and internal subroutine. !DEF: /m Module diff --git a/flang/test/Semantics/symbol03.f90 b/flang/test/Semantics/symbol03.f90 --- a/flang/test/Semantics/symbol03.f90 +++ b/flang/test/Semantics/symbol03.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Test host association in internal subroutine of main program. !DEF: /main MainProgram diff --git a/flang/test/Semantics/symbol05.f90 b/flang/test/Semantics/symbol05.f90 --- a/flang/test/Semantics/symbol05.f90 +++ b/flang/test/Semantics/symbol05.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Explicit and implicit entities in blocks !DEF: /s1 (Subroutine) Subprogram diff --git a/flang/test/Semantics/symbol06.f90 b/flang/test/Semantics/symbol06.f90 --- a/flang/test/Semantics/symbol06.f90 +++ b/flang/test/Semantics/symbol06.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 !DEF: /main MainProgram program main !DEF: /main/t1 DerivedType diff --git a/flang/test/Semantics/symbol07.f90 b/flang/test/Semantics/symbol07.f90 --- a/flang/test/Semantics/symbol07.f90 +++ b/flang/test/Semantics/symbol07.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 !DEF: /main MainProgram program main implicit complex(z) diff --git a/flang/test/Semantics/symbol08.f90 b/flang/test/Semantics/symbol08.f90 --- a/flang/test/Semantics/symbol08.f90 +++ b/flang/test/Semantics/symbol08.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 !DEF: /main MainProgram program main !DEF: /main/x POINTER ObjectEntity REAL(4) diff --git a/flang/test/Semantics/symbol09.f90 b/flang/test/Semantics/symbol09.f90 --- a/flang/test/Semantics/symbol09.f90 +++ b/flang/test/Semantics/symbol09.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 !DEF: /s1 (Subroutine) Subprogram subroutine s1 !DEF: /s1/a ObjectEntity REAL(4) diff --git a/flang/test/Semantics/symbol10.f90 b/flang/test/Semantics/symbol10.f90 --- a/flang/test/Semantics/symbol10.f90 +++ b/flang/test/Semantics/symbol10.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 !DEF: /m1 Module module m1 contains diff --git a/flang/test/Semantics/symbol11.f90 b/flang/test/Semantics/symbol11.f90 --- a/flang/test/Semantics/symbol11.f90 +++ b/flang/test/Semantics/symbol11.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 !DEF: /s1 (Subroutine) Subprogram subroutine s1 implicit none diff --git a/flang/test/Semantics/symbol12.f90 b/flang/test/Semantics/symbol12.f90 --- a/flang/test/Semantics/symbol12.f90 +++ b/flang/test/Semantics/symbol12.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Verify that SAVE attribute is propagated by EQUIVALENCE !DEF: /s1 (Subroutine) Subprogram diff --git a/flang/test/Semantics/symbol13.f90 b/flang/test/Semantics/symbol13.f90 --- a/flang/test/Semantics/symbol13.f90 +++ b/flang/test/Semantics/symbol13.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Old-style "*length" specifiers (R723) !DEF: /f1 (Function) Subprogram CHARACTER(1_8,1) diff --git a/flang/test/Semantics/symbol14.f90 b/flang/test/Semantics/symbol14.f90 --- a/flang/test/Semantics/symbol14.f90 +++ b/flang/test/Semantics/symbol14.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! "Bare" uses of type parameters and components !DEF: /MainProgram1/t1 DerivedType diff --git a/flang/test/Semantics/symbol15.f90 b/flang/test/Semantics/symbol15.f90 --- a/flang/test/Semantics/symbol15.f90 +++ b/flang/test/Semantics/symbol15.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Forward references in pointer initializers and TBP bindings. !DEF: /m Module diff --git a/flang/test/Semantics/symbol16.f90 b/flang/test/Semantics/symbol16.f90 --- a/flang/test/Semantics/symbol16.f90 +++ b/flang/test/Semantics/symbol16.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Statement functions !DEF: /p1 MainProgram diff --git a/flang/test/Semantics/symbol17.f90 b/flang/test/Semantics/symbol17.f90 --- a/flang/test/Semantics/symbol17.f90 +++ b/flang/test/Semantics/symbol17.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Forward references to derived types (non-error cases) !DEF: /main MainProgram diff --git a/flang/test/Semantics/symbol18.f90 b/flang/test/Semantics/symbol18.f90 --- a/flang/test/Semantics/symbol18.f90 +++ b/flang/test/Semantics/symbol18.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Intrinsic function in type declaration statement: type is ignored diff --git a/flang/test/Semantics/symbol19.f90 b/flang/test/Semantics/symbol19.f90 --- a/flang/test/Semantics/symbol19.f90 +++ b/flang/test/Semantics/symbol19.f90 @@ -1,4 +1,4 @@ -! RUN: %python %S/test_symbols.py %s %flang_fc1 +! RUN: %python %S/test_symbols.py %s %t %flang_fc1 ! Test that a procedure is only implicitly resolved as an intrinsic function ! (resp. subroutine) if this is a function (resp. subroutine) diff --git a/flang/test/Semantics/test_symbols.py b/flang/test/Semantics/test_symbols.py --- a/flang/test/Semantics/test_symbols.py +++ b/flang/test/Semantics/test_symbols.py @@ -4,22 +4,26 @@ we get the right symbols in the output, i.e. the output should be the same as the input, except for the copyright comment. Expects a source file passed as the first argument; -Expects the Flang frontdriver with options as second argument.""" +Expects a temporary directory as the second argument; +Expects the Flang frontend driver with options as third argument.""" import sys +import os import re import subprocess import common as cm from difflib import unified_diff -cm.check_args(sys.argv) +cm.check_args_long(sys.argv) src = cm.set_source(sys.argv[1]) +tmp = cm.set_temp(sys.argv[2]) +cwd = os.getcwd() diff1 = "" diff2 = "" -flang_fc1 = cm.set_executable(sys.argv[2]) -flang_fc1_args = sys.argv[3:] +flang_fc1 = cm.set_executable(sys.argv[3]) +flang_fc1_args = sys.argv[4:] flang_fc1_options = "-fdebug-unparse-with-symbols" # Strips out blank lines and all comments except for "!DEF:", "!REF:", "!$acc" and "!$omp" @@ -36,7 +40,17 @@ # Compiles, inserting comments for symbols: cmd = [flang_fc1, *flang_fc1_args, flang_fc1_options] -diff3 = subprocess.check_output(cmd, input=diff2, universal_newlines=True) +try: + os.chdir(tmp) + diff3 = subprocess.check_output(cmd, input=diff2, universal_newlines=True) +except subprocess.CalledProcessError as e: + print(e.stderr) + sys.exit(1) +except OSError as e: + print(e) + sys.exit(1) +finally: + os.chdir(cwd) # Removes all whitespace to compare differences in files diff1 = diff1.replace(" ", "")