[flang][f18] Make -fdebug-dump-{symbols|parse-tree} imply -fsyntax-only

The following _action_ options are always used with `-fsyntax-only`
(also an _action_ option):
  * -fdebug-dump-symbols
  * -fdebug-dump-parse-tree
This patch makes the above options imply `-fsyntax-only`.

From the perspective of `f18` this change saves typing and is otherwise
a non-functional change. But it will simplify things in the new driver,
`flang-new`, in which only the last action option is taken into account
and executed. In other words, the following would only run
`-fsyntax-only`:
```
flang-new -fdebug-dump-symbols -fsyntax-only <input>
```
whereas this would only run `-fdebug-dump-symbols`:
```
flang-new -fsyntax-only -fdebug-dump-symbols <input>
```

Differential Revision: https://reviews.llvm.org/D96528

GitOrigin-RevId: 548549e88ac4a1908206b888be24592e1dbcc38f
diff --git a/test/Evaluate/test_folding.sh b/test/Evaluate/test_folding.sh
index 951ef36..74ca9c8 100755
--- a/test/Evaluate/test_folding.sh
+++ b/test/Evaluate/test_folding.sh
@@ -32,7 +32,7 @@
 mkdir -p $temp
 shift
 
-CMD="$* -fdebug-dump-symbols -fsyntax-only"
+CMD="$* -fdebug-dump-symbols"
 
 # Check if tests should assume folding is using libpgmath
 if [[ $LIBPGMATH ]]; then
diff --git a/test/Semantics/data05.f90 b/test/Semantics/data05.f90
index f3c7aa9..31d68b3 100644
--- a/test/Semantics/data05.f90
+++ b/test/Semantics/data05.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols -fsyntax-only %s | FileCheck %s
+!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
 module m
   interface
     integer function ifunc(n)
diff --git a/test/Semantics/data08.f90 b/test/Semantics/data08.f90
index 4040ac8..e9f53c1 100644
--- a/test/Semantics/data08.f90
+++ b/test/Semantics/data08.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-dump-symbols -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %f18 -fdebug-dump-symbols %s 2>&1 | FileCheck %s
 ! CHECK: DATA statement value initializes 'jx' of type 'INTEGER(4)' with CHARACTER
 ! CHECK: DATA statement value initializes 'jy' of type 'INTEGER(4)' with CHARACTER
 ! CHECK: DATA statement value initializes 'jz' of type 'INTEGER(4)' with CHARACTER
diff --git a/test/Semantics/offsets01.f90 b/test/Semantics/offsets01.f90
index 78183d5..394f6a7 100644
--- a/test/Semantics/offsets01.f90
+++ b/test/Semantics/offsets01.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols -fsyntax-only %s | FileCheck %s
+!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment of intrinsic types
 subroutine s1
diff --git a/test/Semantics/offsets02.f90 b/test/Semantics/offsets02.f90
index b76572e..99a156e 100644
--- a/test/Semantics/offsets02.f90
+++ b/test/Semantics/offsets02.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols -fsyntax-only %s | FileCheck %s
+!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment of derived types
 
diff --git a/test/Semantics/offsets03.f90 b/test/Semantics/offsets03.f90
index c1c2de4..f578cb7 100644
--- a/test/Semantics/offsets03.f90
+++ b/test/Semantics/offsets03.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols -fsyntax-only %s | FileCheck %s
+!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment with EQUIVALENCE and COMMON
 
diff --git a/test/Semantics/oldparam01.f90 b/test/Semantics/oldparam01.f90
index b78869f..b02ded3 100644
--- a/test/Semantics/oldparam01.f90
+++ b/test/Semantics/oldparam01.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -falternative-parameter-statement -fdebug-dump-symbols -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %f18 -falternative-parameter-statement -fdebug-dump-symbols %s 2>&1 | FileCheck %s
 
 ! Non-error tests for "old style" PARAMETER statements
 
diff --git a/test/Semantics/oldparam02.f90 b/test/Semantics/oldparam02.f90
index fd58988..aff4892 100644
--- a/test/Semantics/oldparam02.f90
+++ b/test/Semantics/oldparam02.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -falternative-parameter-statement -fdebug-dump-symbols -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: not %f18 -falternative-parameter-statement -fdebug-dump-symbols %s 2>&1 | FileCheck %s
 
 ! Error tests for "old style" PARAMETER statements
 subroutine subr(x1,x2,x3,x4,x5)
diff --git a/test/Semantics/resolve100.f90 b/test/Semantics/resolve100.f90
index 52fca54..98d67d9 100644
--- a/test/Semantics/resolve100.f90
+++ b/test/Semantics/resolve100.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols -fsyntax-only %s | FileCheck %s
+!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
 
 program p
   ! CHECK: a size=4 offset=0: ObjectEntity type: LOGICAL(4)
diff --git a/test/Semantics/rewrite01.f90 b/test/Semantics/rewrite01.f90
index cd5453e..a189d44 100644
--- a/test/Semantics/rewrite01.f90
+++ b/test/Semantics/rewrite01.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fsyntax-only -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s
+! RUN: %f18 -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s
 ! Ensure that READ(CVAR) [, item-list] is corrected when CVAR is a
 ! character variable so as to be a formatted read from the default
 ! unit, not an unformatted read from an internal unit (which is not
diff --git a/test/Semantics/typeinfo01.f90 b/test/Semantics/typeinfo01.f90
index 2274896..3575aca 100644
--- a/test/Semantics/typeinfo01.f90
+++ b/test/Semantics/typeinfo01.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols -fsyntax-only %s | FileCheck %s
+!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
 ! Tests for derived type runtime descriptions
 
 module m01
diff --git a/tools/f18/f18.cpp b/tools/f18/f18.cpp
index f9bf3e3..7960403 100644
--- a/tools/f18/f18.cpp
+++ b/tools/f18/f18.cpp
@@ -526,10 +526,12 @@
       options.needProvenanceRangeToCharBlockMappings = true;
     } else if (arg == "-fdebug-dump-parse-tree") {
       driver.dumpParseTree = true;
+      driver.syntaxOnly = true;
     } else if (arg == "-fdebug-pre-fir-tree") {
       driver.dumpPreFirTree = true;
     } else if (arg == "-fdebug-dump-symbols") {
       driver.dumpSymbols = true;
+      driver.syntaxOnly = true;
     } else if (arg == "-fdebug-module-writer") {
       driver.debugModuleWriter = true;
     } else if (arg == "-fdebug-measure-parse-tree") {