From: Hans Wennborg Date: Wed, 29 Jan 2014 01:04:40 +0000 (+0000) Subject: clang-cl: Better error message when trying to compile stdin (PR18640) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87a33de66c0af3fbf1c14d946b98a275e4322aea;p=clang clang-cl: Better error message when trying to compile stdin (PR18640) We should suggest using /Tc or /Tp to set the input type, instead of erroneously suggesting -x, which isn't a clang-cl flag. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200362 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index 59805b59ba..dbc5ce994c 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -17,6 +17,8 @@ def err_drv_unsupported_option_argument : Error< "unsupported argument '%1' to option '%0'">; def err_drv_unknown_stdin_type : Error< "-E or -x required when input is from standard input">; +def err_drv_unknown_stdin_type_clang_cl : Error< + "use /Tc or /Tp to set input type for standard input">; def err_drv_unknown_language : Error<"language not recognized: '%0'">; def err_drv_invalid_arch_name : Error< "invalid arch name '%0'">; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index ca3e50fd53..bd43fbeec1 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1030,7 +1030,8 @@ void Driver::BuildInputs(const ToolChain &TC, const DerivedArgList &Args, // Otherwise emit an error but still use a valid type to avoid // spurious errors (e.g., no inputs). if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP()) - Diag(clang::diag::err_drv_unknown_stdin_type); + Diag(IsCLMode() ? clang::diag::err_drv_unknown_stdin_type_clang_cl + : clang::diag::err_drv_unknown_stdin_type); Ty = types::TY_C; } else { // Otherwise lookup by extension. diff --git a/test/Driver/cl-inputs.c b/test/Driver/cl-inputs.c index d6ee520257..066e0e32d9 100644 --- a/test/Driver/cl-inputs.c +++ b/test/Driver/cl-inputs.c @@ -33,3 +33,11 @@ // WARN: warning: overriding '/TC' option with '/TP' // WARN: note: The last /TC or /TP option takes precedence over earlier instances // WARN-NOT: note + +// RUN: not %clang_cl - 2>&1 | FileCheck -check-prefix=STDIN %s +// STDIN: error: use /Tc or /Tp + +// RUN: %clang_cl -### /Tc - 2>&1 | FileCheck -check-prefix=STDINTc %s +// STDINTc: "-x" "c" + +void f();