Set the default C standard to C99 when targeting the PS4.
Patch by Douglas Yung!
Differential Revision: http://reviews.llvm.org/D19003
llvm-svn: 267772
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 67d116c..0c4d5c7 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1344,6 +1344,7 @@
}
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
+ const llvm::Triple &T,
LangStandard::Kind LangStd) {
// Set some properties which depend solely on the input kind; it would be nice
// to move these to the language standard, and have the driver resolve the
@@ -1376,7 +1377,11 @@
case IK_PreprocessedC:
case IK_ObjC:
case IK_PreprocessedObjC:
- LangStd = LangStandard::lang_gnu11;
+ // The PS4 uses C99 as the default C standard.
+ if (T.isPS4())
+ LangStd = LangStandard::lang_gnu99;
+ else
+ LangStd = LangStandard::lang_gnu11;
break;
case IK_CXX:
case IK_PreprocessedCXX:
@@ -1529,7 +1534,8 @@
LangStd = OpenCLLangStd;
}
- CompilerInvocation::setLangDefaults(Opts, IK, LangStd);
+ llvm::Triple T(TargetOpts.Triple);
+ CompilerInvocation::setLangDefaults(Opts, IK, T, LangStd);
// We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension
// keywords. This behavior is provided by GCC's poorly named '-fasm' flag,
@@ -1851,7 +1857,6 @@
// Provide diagnostic when a given target is not expected to be an OpenMP
// device or host.
if (Opts.OpenMP && !Opts.OpenMPIsDevice) {
- llvm::Triple T(TargetOpts.Triple);
switch (T.getArch()) {
default:
break;