diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Frontend/CompilerInvocation.h | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 11 | ||||
-rw-r--r-- | clang/test/Preprocessor/init.c | 1 |
3 files changed, 11 insertions, 3 deletions
diff --git a/clang/include/clang/Frontend/CompilerInvocation.h b/clang/include/clang/Frontend/CompilerInvocation.h index 0b4a1e587e7..6d964bda4c5 100644 --- a/clang/include/clang/Frontend/CompilerInvocation.h +++ b/clang/include/clang/Frontend/CompilerInvocation.h @@ -153,8 +153,10 @@ public: /// /// \param Opts - The LangOptions object to set up. /// \param IK - The input language. + /// \param T - The target triple. /// \param LangStd - The input language standard. static void setLangDefaults(LangOptions &Opts, InputKind IK, + const llvm::Triple &T, LangStandard::Kind LangStd = LangStandard::lang_unspecified); /// \brief Retrieve a module hash string that is suitable for uniquely diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 5bb036ab26e..da0b3a83be8 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1355,6 +1355,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) { } 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 @@ -1387,7 +1388,11 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK, 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: @@ -1541,7 +1546,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, 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, @@ -1861,7 +1867,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, // 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; diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c index dbd4de605e5..5f3284710a6 100644 --- a/clang/test/Preprocessor/init.c +++ b/clang/test/Preprocessor/init.c @@ -8358,6 +8358,7 @@ // PS4:#define __SSE2__ 1 // PS4:#define __SSE_MATH__ 1 // PS4:#define __SSE__ 1 +// PS4:#define __STDC_VERSION__ 199901L // PS4:#define __UINTMAX_TYPE__ long unsigned int // PS4:#define __USER_LABEL_PREFIX__ // PS4:#define __WCHAR_MAX__ 65535 |