From 471e6a941df96bf3da593ae659572633e72095ed Mon Sep 17 00:00:00 2001 From: Paul Osmialowski Date: Wed, 8 Mar 2017 22:34:02 +0000 Subject: [PATCH 1/2] test: no testing gfortran Signed-off-by: Paul Osmialowski --- test/Driver/fortran.f95 | 9 -- test/Driver/gfortran.f90 | 260 --------------------------------------- 2 files changed, 269 deletions(-) delete mode 100644 test/Driver/gfortran.f90 diff --git a/test/Driver/fortran.f95 b/test/Driver/fortran.f95 index 47c6e7b50c..d765162d4d 100644 --- a/test/Driver/fortran.f95 +++ b/test/Driver/fortran.f95 @@ -2,20 +2,11 @@ // RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -c %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-OBJECT %s -// CHECK-OBJECT: gcc -// CHECK-OBJECT: "-c" -// CHECK-OBJECT: "-x" "f95" // CHECK-OBJECT-NOT: cc1as // RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -S %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-ASM %s -// CHECK-ASM: gcc // CHECK-ASM: "-S" -// CHECK-ASM: "-x" "f95" -// CHECK-ASM-NOT: cc1 // RUN: %clang -Wall -target x86_64-unknown-linux-gnu -integrated-as %s -o %t -### 2>&1 | FileCheck --check-prefix=CHECK-WARN %s -// CHECK-WARN: gcc -// CHECK-WARN-NOT: "-Wall" // CHECK-WARN: ld -// CHECK-WARN-NOT: "-Wall" diff --git a/test/Driver/gfortran.f90 b/test/Driver/gfortran.f90 deleted file mode 100644 index e687e51b4d..0000000000 --- a/test/Driver/gfortran.f90 +++ /dev/null @@ -1,260 +0,0 @@ -! Test that Clang can forward all of the flags which are documented as -! being supported by gfortran to GCC when falling back to GCC for -! a fortran input file. -! -! RUN: %clang -no-canonical-prefixes -target i386-linux -### %s -o %t 2>&1 \ -! RUN: -Aquestion=answer \ -! RUN: -A-question=answer \ -! RUN: -C \ -! RUN: -CC \ -! RUN: -Dmacro \ -! RUN: -Dmacro=value \ -! RUN: -H \ -! RUN: -Isome/directory \ -! RUN: -Jsome/other/directory \ -! RUN: -P \ -! RUN: -Umacro \ -! RUN: -Waliasing \ -! RUN: -Walign-commons \ -! RUN: -Wall \ -! RUN: -Wampersand \ -! RUN: -Warray-bounds \ -! RUN: -Wc-binding-type \ -! RUN: -Wcharacter-truncation \ -! RUN: -Wconversion \ -! RUN: -Wfunction-elimination \ -! RUN: -Wimplicit-interface \ -! RUN: -Wimplicit-procedure \ -! RUN: -Wintrinsic-shadow \ -! RUN: -Wintrinsics-std \ -! RUN: -Wline-truncation \ -! RUN: -Wreal-q-constant \ -! RUN: -Wrealloc-lhs \ -! RUN: -Wsurprising \ -! RUN: -Wtabs \ -! RUN: -Wtarget-lifetime \ -! RUN: -Wunderflow \ -! RUN: -Wunused-parameter \ -! RUN: -cpp \ -! RUN: -dD \ -! RUN: -dI \ -! RUN: -dM \ -! RUN: -dN \ -! RUN: -dU \ -! RUN: -faggressive-function-elimination \ -! RUN: -falign-commons \ -! RUN: -fall-intrinsics \ -! RUN: -fautomatic \ -! RUN: -fbackslash \ -! RUN: -fbacktrace \ -! RUN: -fblas-matmul-limit=42 \ -! RUN: -fbounds-check \ -! RUN: -fcheck-array-temporaries \ -! RUN: -fcheck=all \ -! RUN: -fcoarray=none \ -! RUN: -fconvert=foobar \ -! RUN: -fcray-pointer \ -! RUN: -fd-lines-as-code \ -! RUN: -fd-lines-as-comments \ -! RUN: -fdefault-double-8 \ -! RUN: -fdefault-integer-8 \ -! RUN: -fdefault-real-8 \ -! RUN: -fdollar-ok \ -! RUN: -fdump-fortran-optimized \ -! RUN: -fdump-fortran-original \ -! RUN: -fdump-parse-tree \ -! RUN: -fexternal-blas \ -! RUN: -ff2c \ -! RUN: -ffixed-form \ -! RUN: -ffixed-line-length-42 \ -! RUN: -ffpe-trap=list \ -! RUN: -ffree-form \ -! RUN: -ffree-line-length-42 \ -! RUN: -ffrontend-optimize \ -! RUN: -fimplicit-none \ -! RUN: -finit-character=n \ -! RUN: -finit-integer=n \ -! RUN: -finit-local-zero \ -! RUN: -finit-logical=false \ -! RUN: -finit-real=zero \ -! RUN: -finteger-4-integer-8 \ -! RUN: -fintrinsic-modules-path \ -! RUN: -fmax-array-constructor=42 \ -! RUN: -fmax-errors=42 \ -! RUN: -fmax-identifier-length \ -! RUN: -fmax-stack-var-size=42 \ -! RUN: -fmax-subrecord-length=42 \ -! RUN: -fmodule-private \ -! RUN: -fopenmp \ -! RUN: -fpack-derived \ -! RUN: -fprotect-parens \ -! RUN: -frange-check \ -! RUN: -freal-4-real-10 \ -! RUN: -freal-4-real-16 \ -! RUN: -freal-4-real-8 \ -! RUN: -freal-8-real-10 \ -! RUN: -freal-8-real-16 \ -! RUN: -freal-8-real-4 \ -! RUN: -frealloc-lhs \ -! RUN: -frecord-marker=42 \ -! RUN: -frecursive \ -! RUN: -frepack-arrays \ -! RUN: -fsecond-underscore \ -! RUN: -fshort-enums \ -! RUN: -fsign-zero \ -! RUN: -fstack-arrays \ -! RUN: -fsyntax-only \ -! RUN: -funderscoring \ -! RUN: -fwhole-file \ -! RUN: -fworking-directory \ -! RUN: -imultilib \ -! RUN: -iprefix \ -! RUN: -iquote \ -! RUN: -isysroot \ -! RUN: -isystem \ -! RUN: -nocpp \ -! RUN: -nostdinc \ -! RUN: -pedantic \ -! RUN: -pedantic-errors \ -! RUN: -static-libgfortran \ -! RUN: -std=f90 \ -! RUN: -undef \ -! RUN: | FileCheck %s -! -! FIXME: Several of these shouldn't necessarily be rendered separately -! when passing to GCC... Hopefully their driver handles this. -! -! CHECK: "-Aquestion=answer" -! CHECK: "-A-question=answer" -! CHECK: "-C" -! CHECK: "-CC" -! CHECK: "-D" "macro" -! CHECK: "-D" "macro=value" -! CHECK: "-H" -! CHECK: "-I" "some/directory" -! CHECK: "-Jsome/other/directory" -! CHECK: "-P" -! CHECK: "-U" "macro" -! CHECK: "-Waliasing" -! CHECK: "-Walign-commons" -! CHECK: "-Wall" -! CHECK: "-Wampersand" -! CHECK: "-Warray-bounds" -! CHECK: "-Wc-binding-type" -! CHECK: "-Wcharacter-truncation" -! CHECK: "-Wconversion" -! CHECK: "-Wfunction-elimination" -! CHECK: "-Wimplicit-interface" -! CHECK: "-Wimplicit-procedure" -! CHECK: "-Wintrinsic-shadow" -! CHECK: "-Wintrinsics-std" -! CHECK: "-Wline-truncation" -! CHECK: "-Wreal-q-constant" -! CHECK: "-Wrealloc-lhs" -! CHECK: "-Wsurprising" -! CHECK: "-Wtabs" -! CHECK: "-Wtarget-lifetime" -! CHECK: "-Wunderflow" -! CHECK: "-Wunused-parameter" -! CHECK: "-cpp" -! CHECK: "-dD" -! CHECK: "-dI" -! CHECK: "-dM" -! CHECK: "-dN" -! CHECK: "-dU" -! CHECK: "-faggressive-function-elimination" -! CHECK: "-falign-commons" -! CHECK: "-fall-intrinsics" -! CHECK: "-fautomatic" -! CHECK: "-fbackslash" -! CHECK: "-fbacktrace" -! CHECK: "-fblas-matmul-limit=42" -! CHECK: "-fbounds-check" -! CHECK: "-fcheck-array-temporaries" -! CHECK: "-fcheck=all" -! CHECK: "-fcoarray=none" -! CHECK: "-fconvert=foobar" -! CHECK: "-fcray-pointer" -! CHECK: "-fd-lines-as-code" -! CHECK: "-fd-lines-as-comments" -! CHECK: "-fdefault-double-8" -! CHECK: "-fdefault-integer-8" -! CHECK: "-fdefault-real-8" -! CHECK: "-fdollar-ok" -! CHECK: "-fdump-fortran-optimized" -! CHECK: "-fdump-fortran-original" -! CHECK: "-fdump-parse-tree" -! CHECK: "-fexternal-blas" -! CHECK: "-ff2c" -! CHECK: "-ffixed-form" -! CHECK: "-ffixed-line-length-42" -! CHECK: "-ffpe-trap=list" -! CHECK: "-ffree-form" -! CHECK: "-ffree-line-length-42" -! CHECK: "-ffrontend-optimize" -! CHECK: "-fimplicit-none" -! CHECK: "-finit-character=n" -! CHECK: "-finit-integer=n" -! CHECK: "-finit-local-zero" -! CHECK: "-finit-logical=false" -! CHECK: "-finit-real=zero" -! CHECK: "-finteger-4-integer-8" -! CHECK: "-fintrinsic-modules-path" -! CHECK: "-fmax-array-constructor=42" -! CHECK: "-fmax-errors=42" -! CHECK: "-fmax-identifier-length" -! CHECK: "-fmax-stack-var-size=42" -! CHECK: "-fmax-subrecord-length=42" -! CHECK: "-fmodule-private" -! CHECK: "-fopenmp" -! CHECK: "-fpack-derived" -! CHECK: "-fprotect-parens" -! CHECK: "-frange-check" -! CHECK: "-freal-4-real-10" -! CHECK: "-freal-4-real-16" -! CHECK: "-freal-4-real-8" -! CHECK: "-freal-8-real-10" -! CHECK: "-freal-8-real-16" -! CHECK: "-freal-8-real-4" -! CHECK: "-frealloc-lhs" -! CHECK: "-frecord-marker=42" -! CHECK: "-frecursive" -! CHECK: "-frepack-arrays" -! CHECK: "-fsecond-underscore" -! CHECK: "-fshort-enums" -! CHECK: "-fsign-zero" -! CHECK: "-fstack-arrays" -! CHECK: "-funderscoring" -! CHECK: "-fwhole-file" -! CHECK: "-fworking-directory" -! CHECK: "-imultilib" -! CHECK: "-iprefix" -! CHECK: "-iquote" -! CHECK: "-isysroot" -! CHECK: "-isystem" -! CHECK: "-nocpp" -! CHECK: "-nostdinc" -! CHECK: "-pedantic" -! CHECK: "-pedantic-errors" -! CHECK: "-static-libgfortran" -! CHECK: "-std=f90" -! CHECK: "-undef" -! -! Clang understands this one and orders it weirdly. -! CHECK: "-fsyntax-only" -! -! PR22234: Ensure that -fsyntax-only doesn't complain about output types and -! passes along correctly. -! RUN: %clang -no-canonical-prefixes -target i386-linux -fsyntax-only -### %s -o %t 2>&1 | \ -! grep for error message and command-line -! RUN: grep -e error: -e -fsyntax-only | FileCheck %s --check-prefix=CHECK-PR22234 -! -! CHECK-PR22234-NOT: clang: error: invalid output type -! CHECK-PR22234: "-fsyntax-only" -! -! Regression test for the bug introduced with PR22234 fix. -! Make sure -fsyntax-only is not passed to gfortran during normal compilation. -! -! RUN: %clang -no-canonical-prefixes -target i386-linux -### %s -o %t 2>&1 \ -! RUN: | FileCheck %s --check-prefix=CHECK-PR22234-R -! CHECK-PR22234-R-NOT: "-fsyntax-only" From c4db4c111a99c4e9be37d71d10ace530e98898ed Mon Sep 17 00:00:00 2001 From: Paul Osmialowski Date: Tue, 27 Jun 2017 13:24:36 +0100 Subject: [PATCH 2/2] test: use Flang for testing Fortran codes Signed-off-by: Paul Osmialowski --- test/Parser/empty.f95 | 3 +++ test/lit.cfg | 30 ++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/Parser/empty.f95 diff --git a/test/Parser/empty.f95 b/test/Parser/empty.f95 new file mode 100644 index 0000000000..c5de19aeb6 --- /dev/null +++ b/test/Parser/empty.f95 @@ -0,0 +1,3 @@ +! RUN: %flang -O0 -fsyntax-only %s +PROGRAM test +END PROGRAM test diff --git a/test/lit.cfg b/test/lit.cfg index 7d8bebf57f..99f2be665a 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -44,7 +44,7 @@ else: config.test_format = lit.formats.ShTest(execute_external) # suffixes: A list of file extensions to treat as test files. -config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs'] +config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu', '.f', '.f95', '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs'] # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent @@ -173,7 +173,7 @@ if config.test_exec_root is None: ### -# Discover the 'clang' and 'clangcc' to use. +# Discover the 'clang', 'clangcc' and 'flang' to use. import os @@ -195,10 +195,33 @@ def inferClang(PATH): return clang + config.clang = inferClang(config.environment['PATH']).replace('\\', '/') if not lit_config.quiet: lit_config.note('using clang: %r' % config.clang) +def inferFlang(PATH): + # Determine which flang to use. + flang = os.getenv('FLANG') + + # If the user set flang in the environment, definitely use that and don't + # try to validate. + if flang: + return flang + + # Otherwise look in the path. + flang = lit.util.which('flang', PATH) + + if not flang: + lit_config.fatal("couldn't find 'flang' program, try setting " + "FLANG in your environment") + + return flang + +config.flang = inferFlang(config.environment['PATH']).replace('\\', '/') +if not lit_config.quiet: + lit_config.note('using flang: %r' % config.flang) + # Plugins (loadable modules) # TODO: This should be supplied by Makefile or autoconf. if sys.platform in ['win32', 'cygwin']: @@ -270,6 +293,7 @@ config.substitutions.append( ('%clang_cl', ' ' + config.clang + config.substitutions.append( ('%clangxx', ' ' + config.clang + ' --driver-mode=g++ ')) config.substitutions.append( ('%clang', ' ' + config.clang + ' ') ) +config.substitutions.append( ('%flang', ' ' + config.flang + ' ') ) config.substitutions.append( ('%test_debuginfo', ' ' + config.llvm_src_root + '/utils/test_debuginfo.pl ') ) config.substitutions.append( ('%itanium_abi_triple', makeItaniumABITriple(config.target_triple)) ) config.substitutions.append( ('%ms_abi_triple', makeMSABITriple(config.target_triple)) ) @@ -302,6 +326,8 @@ config.substitutions.append( config.substitutions.append( (' %clang-cl ', """*** invalid substitution, use '%clang_cl'. ***""") ) +config.substitutions.append( + (' flang ', """*** Do not use 'flang' in tests, use '%flang'. ***""") ) # For each occurrence of a clang tool name as its own word, replace it # with the full path to the build directory holding that tool. This