Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4091,9 +4091,10 @@ if (Triple.isOSWindows() && (Triple.getArch() == llvm::Triple::arm || Triple.getArch() == llvm::Triple::thumb)) { unsigned Offset = Triple.getArch() == llvm::Triple::arm ? 4 : 6; - unsigned Version; - Triple.getArchName().substr(Offset).getAsInteger(10, Version); - if (Version < 7) + unsigned Version = 0; + bool Failure = + Triple.getArchName().substr(Offset).consumeInteger(10, Version); + if (Failure || Version < 7) D.Diag(diag::err_target_unsupported_arch) << Triple.getArchName() << TripleStr; } Index: clang/test/Driver/windows-thumbv7em.cpp =================================================================== --- /dev/null +++ clang/test/Driver/windows-thumbv7em.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cpp --target=thumbv7em-none-windows-eabi-coff \ +// RUN: -mcpu=cortex-m7 -c %s -o /dev/null 2>&1 \ +// RUN: | FileCheck --allow-empty %s + +// CHECK-NOT: error: the target architecture 'thumbv7em' is not supported by the target 'thumbv7em-none-windows-eabi'