[OpenCL] Allow -cl-std and other standard -cl- options in driver
Allow -cl-std and other standard -cl- options from cc1 to driver.
Added a test for the options moved.
Patch by Aaron En Ye Shi.
Differential Revision: http://reviews.llvm.org/D21031
llvm-svn: 274150
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 0fc6e3a..1abe4ff 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -41,6 +41,7 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Target/TargetOptions.h"
+#include "llvm/Support/ScopedPrinter.h"
#include <atomic>
#include <memory>
#include <sys/stat.h>
@@ -1671,6 +1672,18 @@
LangStd = OpenCLLangStd;
}
+ // -cl-strict-aliasing needs to emit diagnostic in the case where CL > 1.0.
+ // This option should be deprecated for CL > 1.0 because
+ // this option was added for compatibility with OpenCL 1.0.
+ if (const Arg *A = Args.getLastArg(OPT_cl_strict_aliasing))
+ if (Opts.OpenCLVersion > 100) {
+ std::string VerSpec = llvm::to_string(Opts.OpenCLVersion / 100) +
+ std::string (".") +
+ llvm::to_string((Opts.OpenCLVersion % 100) / 10);
+ Diags.Report(diag::warn_option_invalid_ocl_version)
+ << VerSpec << A->getAsString(Args);
+ }
+
Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
llvm::Triple T(TargetOpts.Triple);