=?utf-8?q?Iñaki?= Amatria Barral <inaki.amat...@appentra.com> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/130...@github.com>
================ @@ -0,0 +1,35 @@ +program main + print *, __FILE__, __LINE__ +end + +! This test verifies that `flang`'s `-x` options behave like `gfortran`'s. +! Specifically: +! - `-x f95` should process the file based on its extension unless overridden. +! - `-x f95-cpp-input` should behave like `-x f95` but with preprocessing +! (`-cpp`) enabled unless overridden. + +! --- +! Ensure the file is treated as fixed-form unless explicitly set otherwise +! --- +! RUN: not %flang -Werror -x f95 -cpp %s 2>&1 | FileCheck --check-prefix=SCAN-ERROR %s +! RUN: not %flang -Werror -x f95-cpp-input %s 2>&1 | FileCheck --check-prefix=SCAN-ERROR %s + +! SCAN-ERROR: error + +! RUN: %flang -Werror -x f95 -cpp -ffree-form %s 2>&1 | FileCheck --check-prefix=NO-SCAN-ERROR --allow-empty %s +! RUN: %flang -Werror -x f95-cpp-input -ffree-form %s 2>&1 | FileCheck --check-prefix=NO-SCAN-ERROR --allow-empty %s + +! NO-SCAN-ERROR-NOT: error + +! --- +! Ensure `-cpp` is not enabled by default unless explicitly requested +! --- +! RUN: not %flang -Werror -x f95 -ffree-form %s 2>&1 | FileCheck --check-prefix=SEMA-ERROR %s +! RUN: not %flang -Werror -x f95-cpp-input -nocpp -ffree-form %s 2>&1 | FileCheck --check-prefix=SEMA-ERROR %s + +! SEMA-ERROR: error ---------------- tarunprabhu wrote: It's always a balancing act. In this case, you are checking that the compiler parses the file in a specific way. In that case, you expect to see a specific category of error, so you might as well check for that. That way, if a change elsewhere in the compiler results in a different error, the test failure will alert the developer. It may be that this "new" error is expected. Or, it could indicate that the change had an effect on a seemingly unrelated part of the code. In either case, it forces the developer to take a closer look. That's just my opinion, though. https://github.com/llvm/llvm-project/pull/130268 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits