[PATCH] D18708: Set C99 as default C Standard for PS4 target

Yung, Douglas via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 1 16:06:28 PDT 2016


Forwarding to cfe-commits as I don't think I saw it appear there.

> dyung created this revision.
> 
> On the PS4, the default C standard is C99 which differs from the
> current default of C11. This patch makes the default C99 when targeting
> the PS4.
> 
> http://reviews.llvm.org/D18708
> 
> Files:
>   include/clang/Frontend/CompilerInvocation.h
>   lib/Frontend/CompilerInvocation.cpp
>   test/Driver/ps4-cpu-defaults.cpp
>   test/Driver/ps4-misc-defaults.cpp
> 
> Index: test/Driver/ps4-misc-defaults.cpp
> ===================================================================
> --- test/Driver/ps4-misc-defaults.cpp
> +++ test/Driver/ps4-misc-defaults.cpp
> @@ -4,3 +4,7 @@
>  // RUN: %clang -target x86_64-scei-ps4 -c %s -### 2>&1 | FileCheck %s
> // CHECK: "-target-cpu" "btver2"
>  // CHECK-NOT: exceptions
> +
> +// Check that the PS4 defaults to C99 when compiling C files // RUN:
> +%clang -target x86_64-scei-ps4 -E -x c -dM %s | FileCheck
> +-check-prefix=CHECK-CSTD %s // CHECK-CSTD: __STDC_VERSION__ 199901L
> Index: test/Driver/ps4-cpu-defaults.cpp
> ===================================================================
> --- test/Driver/ps4-cpu-defaults.cpp
> +++ test/Driver/ps4-cpu-defaults.cpp
> @@ -1,6 +0,0 @@
> -// Check that on the PS4 we default to:
> -// -target-cpu btver2 and no exceptions
> -
> -// RUN: %clang -target x86_64-scei-ps4 -c %s -### 2>&1 | FileCheck %s
> -// CHECK: "-target-cpu" "btver2"
> -// CHECK-NOT: exceptions
> Index: lib/Frontend/CompilerInvocation.cpp
> ===================================================================
> --- lib/Frontend/CompilerInvocation.cpp
> +++ lib/Frontend/CompilerInvocation.cpp
> @@ -1355,6 +1355,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 @@ -1387,7 +1388,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:
> @@ -1541,7 +1546,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, @@ -1858,7 +1864,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;
> Index: include/clang/Frontend/CompilerInvocation.h
> ===================================================================
> --- include/clang/Frontend/CompilerInvocation.h
> +++ include/clang/Frontend/CompilerInvocation.h
> @@ -153,8 +153,10 @@
>    ///
>    /// \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
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18708.52406.patch
Type: text/x-patch
Size: 3310 bytes
Desc: D18708.52406.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160401/c2ddd2f4/attachment-0001.bin>


More information about the cfe-commits mailing list