Index: lib/Basic/Targets.cpp =================================================================== --- lib/Basic/Targets.cpp +++ lib/Basic/Targets.cpp @@ -5669,9 +5669,6 @@ std::find(Features.begin(), Features.end(), "+soft-float"); if (it != Features.end()) Features.erase(it); - it = std::find(Features.begin(), Features.end(), "+nan2008"); - if (it != Features.end()) - Features.erase(it); setDescriptionString(); Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -1037,8 +1037,14 @@ } if (Arg *A = Args.getLastArg(options::OPT_mnan_EQ)) { - if (StringRef(A->getValue()) == "2008") + StringRef Val = StringRef(A->getValue()); + if (Val == "2008") Features.push_back("+nan2008"); + else if (Val == "legacy") + Features.push_back("-nan2008"); + else + D.Diag(diag::err_drv_unsupported_option_argument) + << A->getOption().getName() << Val; } AddTargetFeature(Args, Features, options::OPT_msingle_float, Index: test/Driver/mips-features.c =================================================================== --- test/Driver/mips-features.c +++ test/Driver/mips-features.c @@ -72,6 +72,18 @@ // RUN: | FileCheck --check-prefix=CHECK-NOMFP64 %s // CHECK-NOMFP64: "-target-feature" "-fp64" // +// -mnan=2008 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mnan=legacy -mnan=2008 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NAN2008 %s +// CHECK-NAN2008: "-target-feature" "+nan2008" +// +// -mnan=legacy +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mnan=2008 -mnan=legacy 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NANLEGACY %s +// CHECK-NANLEGACY: "-target-feature" "-nan2008" +// // -mxgot // RUN: %clang -target mips-linux-gnu -### -c %s \ // RUN: -mno-xgot -mxgot 2>&1 \