Skip to content

Commit 4091959

Browse files
committed
Address review comments
- simplify option check - add diagnostic of wrong option arg
1 parent 3c57a70 commit 4091959

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

clang/lib/Driver/ToolChains/Flang.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,24 @@ void Flang::AddAArch64TargetArgs(const ArgList &Args,
205205

206206
void Flang::AddPPCTargetArgs(const ArgList &Args,
207207
ArgStringList &CmdArgs) const {
208+
const Driver &D = getToolChain().getDriver();
208209
bool VecExtabi = false;
209-
for (const Arg *A : Args.filtered(options::OPT_mabi_EQ)) {
210+
211+
if (const Arg *A = Args.getLastArg(options::OPT_mabi_EQ)) {
210212
StringRef V = A->getValue();
211-
if (V == "vec-default") {
212-
VecExtabi = false;
213-
A->claim();
214-
} else if (V == "vec-extabi") {
213+
if (V == "vec-extabi") {
215214
VecExtabi = true;
216-
A->claim();
215+
} else if (V == "vec-default") {
216+
VecExtabi = false;
217+
} else {
218+
D.Diag(diag::err_drv_unsupported_option_argument)
219+
<< A->getSpelling() << V;
217220
}
218221
}
222+
219223
const llvm::Triple &T = getToolChain().getTriple();
220224
if (VecExtabi) {
221225
if (!T.isOSAIX()) {
222-
const Driver &D = getToolChain().getDriver();
223226
D.Diag(diag::err_drv_unsupported_opt_for_target)
224227
<< "-mabi=vec-extabi" << T.str();
225228
}

flang/test/Driver/mabi.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
! RUN: not %flang -### -c --target=powerpc64le-unknown-linux -mabi=vec-extabi %s 2>&1 | FileCheck --check-prefix=INVALID1 %s
22
! RUN: not %flang -### -c --target=x86_64-unknown-linux -mabi=vec-extabi %s 2>&1 | FileCheck --check-prefix=INVALID2 %s
3+
! RUN: not %flang -### -c --target=powerpc-unknown-aix -mabi=abc %s 2>&1 | FileCheck --check-prefix=INVALID3 %s
34
! RUN: %flang -### -c -target powerpc-unknown-aix %s 2>&1 | FileCheck --implicit-check-not=vec-extabi %s
45
! RUN: %flang -### -c -target powerpc-unknown-aix -mabi=vec-default %s 2>&1 | FileCheck --implicit-check-not=vec-extabi %s
56
! RUN: %flang -### -c -target powerpc-unknown-aix -mabi=vec-extabi %s 2>&1 | FileCheck --check-prefix=EXTABI %s
67

78
! INVALID1: error: unsupported option '-mabi=vec-extabi' for target '{{.*}}'
89
! INVALID2: error: unsupported option '-mabi=' for target '{{.*}}'
10+
! INVALID3: error: unsupported argument 'abc' to option '-mabi='
911

1012
! EXTABI: "-fc1"
1113
! EXTABI-SAME: "-mabi=vec-extabi"

0 commit comments

Comments
 (0)