File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change @@ -308,9 +308,18 @@ InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
308308 auto ArgString = A->getAsString (Args);
309309 std::string Nearest;
310310 if (getOpts ().findNearest (ArgString, Nearest, VisibilityMask) > 1 ) {
311- if (!IsCLMode () &&
312- getOpts ().findExact (ArgString, Nearest,
313- llvm::opt::Visibility (options::CC1Option))) {
311+ if (IsFlangMode ()) {
312+ if (getOpts ().findExact (ArgString, Nearest,
313+ llvm::opt::Visibility (options::FC1Option))) {
314+ DiagID = diag::err_drv_unknown_argument_with_suggestion;
315+ Diags.Report (DiagID) << ArgString << " -Xflang " + Nearest;
316+ } else {
317+ DiagID = diag::err_drv_unknown_argument;
318+ Diags.Report (DiagID) << ArgString;
319+ }
320+ } else if (!IsCLMode () && getOpts ().findExact (ArgString, Nearest,
321+ llvm::opt::Visibility (
322+ options::CC1Option))) {
314323 DiagID = diag::err_drv_unknown_argument_with_suggestion;
315324 Diags.Report (DiagID) << ArgString << " -Xclang " + Nearest;
316325 } else {
Original file line number Diff line number Diff line change 1- ! Test for warnings generated when parsing driver options. You can use this file for relatively small tests and to avoid creating
2- ! new test files.
1+ ! Test for errors and warnings generated when parsing driver options. You can
2+ ! use this file for relatively small tests and to avoid creating new test files.
33
44! RUN: %flang -### -S -O4 -ffp-contract=on %s 2>&1 | FileCheck %s
55
2626! RUN: | FileCheck %s -check-prefix=WARN-BUILTIN-MULTIPLE
2727! WARN-BUILTIN-MULTIPLE: warning: '-fbuiltin' is not valid for Fortran
2828! WARN-BUILTIN-MULTIPLE: warning: '-fno-builtin' is not valid for Fortran
29+
30+ ! When emitting an error with a suggestion, ensure that the diagnostic message
31+ ! uses '-Xflang' instead of '-Xclang'. This is typically emitted when an option
32+ ! that is available for `flang -fc1` is passed to `flang`. We use -complex-range
33+ ! since it is only available for fc1. If this option is ever exposed to `flang`,
34+ ! a different option will have to be used in the test below.
35+ !
36+ ! RUN: not %flang -### -complex-range=full %s 2>&1 \
37+ ! RUN: | FileCheck %s -check-prefix UNKNOWN-SUGGEST
38+ !
39+ ! UNKNOWN-SUGGEST: error: unknown argument '-complex-range=full';
40+ ! UNKNOWN-SUGGEST-SAME: did you mean '-Xflang -complex-range=full'
41+ !
42+ ! RUN: not %flang -### -not-an-option %s 2>&1 \
43+ ! RUN: | FileCheck %s -check-prefix UNKNOWN-NO-SUGGEST
44+ !
45+ ! UNKNOWN-NO-SUGGEST: error: unknown argument: '-not-an-option'{{$}}
You can’t perform that action at this time.
0 commit comments