Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td @@ -247,6 +247,10 @@ def warn_drv_invoking_fallback : Warning<"falling back to %0">, InGroup; +def warn_slash_u_filename : Warning<"'/U%0' treated as the '/U' option">, + InGroup>; +def note_use_dashdash : Note<"Use '--' to treat subsequent arguments as filenames">; + def err_drv_ropi_rwpi_incompatible_with_pic : Error< "embedded and GOT-based position independence are incompatible">; def err_drv_ropi_incompatible_with_cxx : Error< Index: cfe/trunk/lib/Driver/Driver.cpp =================================================================== --- cfe/trunk/lib/Driver/Driver.cpp +++ cfe/trunk/lib/Driver/Driver.cpp @@ -1583,6 +1583,14 @@ Diag(clang::diag::err_drv_unknown_language) << A->getValue(); InputType = types::TY_Object; } + } else if (A->getOption().getID() == options::OPT__SLASH_U) { + assert(A->getNumValues() == 1 && "The /U option has one value."); + StringRef Val = A->getValue(0); + if (Val.find_first_of("/\\") != StringRef::npos) { + // Warn about e.g. "/Users/me/myfile.c". + Diag(diag::warn_slash_u_filename) << Val; + Diag(diag::note_use_dashdash); + } } } if (CCCIsCPP() && Inputs.empty()) { Index: cfe/trunk/test/Driver/cl-options.c =================================================================== --- cfe/trunk/test/Driver/cl-options.c +++ cfe/trunk/test/Driver/cl-options.c @@ -442,6 +442,12 @@ // Xclang: "-cc1" // Xclang: "hellocc1" +// Files under /Users are often confused with the /U flag. (This could happen +// for other flags too, but this is the one people run into.) +// RUN: %clang_cl /c /Users/me/myfile.c -### 2>&1 | FileCheck -check-prefix=SlashU %s +// SlashU: warning: '/Users/me/myfile.c' treated as the '/U' option +// SlashU: note: Use '--' to treat subsequent arguments as filenames + // RTTI is on by default. /GR- controls -fno-rtti-data. // RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s // NoRTTI: "-fno-rtti-data"