diff --git a/clang/lib/Driver/ToolChains/CrossWindows.cpp b/clang/lib/Driver/ToolChains/CrossWindows.cpp --- a/clang/lib/Driver/ToolChains/CrossWindows.cpp +++ b/clang/lib/Driver/ToolChains/CrossWindows.cpp @@ -94,7 +94,8 @@ CmdArgs.push_back("-m"); switch (TC.getArch()) { default: - llvm_unreachable("unsupported architecture"); + D.Diag(diag::err_target_unknown_triple) << TC.getEffectiveTriple().str(); + break; case llvm::Triple::arm: case llvm::Triple::thumb: // FIXME: this is incorrect for WinCE diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -135,7 +135,7 @@ CmdArgs.push_back("arm64pe"); break; default: - llvm_unreachable("Unsupported target architecture."); + D.Diag(diag::err_target_unknown_triple) << TC.getEffectiveTriple().str(); } Arg *SubsysArg = diff --git a/clang/test/Driver/unsupported-target-arch.c b/clang/test/Driver/unsupported-target-arch.c --- a/clang/test/Driver/unsupported-target-arch.c +++ b/clang/test/Driver/unsupported-target-arch.c @@ -23,3 +23,11 @@ // RUN: not %clang --target=noarch-unknown-nacl -o %t.o %s 2> %t.err // RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-NACL %s // CHECK-NOARCH-NACL: error: the target architecture 'noarch' is not supported by the target 'Native Client' + +// RUN: not %clang --target=noarch-unknown-windows-gnu -o %t.o %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-MINGW %s +// CHECK-NOARCH-MINGW: error: unknown target triple 'noarch-unknown-windows-gnu' + +// RUN: not %clang --target=noarch-unknown-windows-itanium -o %t.o %s 2> %t.err +// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-CROSSWINDOWS %s +// CHECK-NOARCH-CROSSWINDOWS: error: unknown target triple 'noarch-unknown-windows-itanium'