diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5421,6 +5421,9 @@ CM == "tiny") { if (Triple.isOSAIX() && CM == "medium") CmdArgs.push_back("-mcmodel=large"); + else if (Triple.isAArch64() && (CM == "kernel" || CM == "medium")) + D.Diag(diag::err_drv_invalid_argument_to_option) + << CM << A->getOption().getName(); else A->render(Args, CmdArgs); } else { diff --git a/clang/test/Driver/mcmodel.c b/clang/test/Driver/mcmodel.c --- a/clang/test/Driver/mcmodel.c +++ b/clang/test/Driver/mcmodel.c @@ -6,6 +6,8 @@ // RUN: %clang -target powerpc-unknown-aix -### -S -mcmodel=medium %s 2> %t.log // RUN: FileCheck --check-prefix=AIX-MCMEDIUM-OVERRIDE %s < %t.log // RUN: not %clang -c -mcmodel=lager %s 2>&1 | FileCheck --check-prefix=INVALID %s +// RUN: not %clang -c -target aarch64 -mcmodel=medium %s 2>&1 | FileCheck --check-prefix=AARCH64-MEDIUM %s +// RUN: not %clang -c -target aarch64 -mcmodel=kernel %s 2>&1 | FileCheck --check-prefix=AARCH64-KERNEL %s // TINY: "-mcmodel=tiny" // SMALL: "-mcmodel=small" @@ -15,3 +17,6 @@ // AIX-MCMEDIUM-OVERRIDE: "-mcmodel=large" // INVALID: error: invalid argument 'lager' to -mcmodel= + +// AARCH64-MEDIUM: error: invalid argument 'medium' to -mcmodel= +// AARCH64-KERNEL: error: invalid argument 'kernel' to -mcmodel=