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
This commit is contained in:
parent
0e0bcc4bdb
commit
bf01080672
|
@ -153,8 +153,10 @@ public:
|
||||||
///
|
///
|
||||||
/// \param Opts - The LangOptions object to set up.
|
/// \param Opts - The LangOptions object to set up.
|
||||||
/// \param IK - The input language.
|
/// \param IK - The input language.
|
||||||
|
/// \param T - The target triple.
|
||||||
/// \param LangStd - The input language standard.
|
/// \param LangStd - The input language standard.
|
||||||
static void setLangDefaults(LangOptions &Opts, InputKind IK,
|
static void setLangDefaults(LangOptions &Opts, InputKind IK,
|
||||||
|
const llvm::Triple &T,
|
||||||
LangStandard::Kind LangStd = LangStandard::lang_unspecified);
|
LangStandard::Kind LangStd = LangStandard::lang_unspecified);
|
||||||
|
|
||||||
/// \brief Retrieve a module hash string that is suitable for uniquely
|
/// \brief Retrieve a module hash string that is suitable for uniquely
|
||||||
|
|
|
@ -1344,6 +1344,7 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
|
void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
|
||||||
|
const llvm::Triple &T,
|
||||||
LangStandard::Kind LangStd) {
|
LangStandard::Kind LangStd) {
|
||||||
// Set some properties which depend solely on the input kind; it would be nice
|
// 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
|
// to move these to the language standard, and have the driver resolve the
|
||||||
|
@ -1376,7 +1377,11 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
|
||||||
case IK_PreprocessedC:
|
case IK_PreprocessedC:
|
||||||
case IK_ObjC:
|
case IK_ObjC:
|
||||||
case IK_PreprocessedObjC:
|
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;
|
break;
|
||||||
case IK_CXX:
|
case IK_CXX:
|
||||||
case IK_PreprocessedCXX:
|
case IK_PreprocessedCXX:
|
||||||
|
@ -1529,7 +1534,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
|
||||||
LangStd = OpenCLLangStd;
|
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
|
// We abuse '-f[no-]gnu-keywords' to force overriding all GNU-extension
|
||||||
// keywords. This behavior is provided by GCC's poorly named '-fasm' flag,
|
// keywords. This behavior is provided by GCC's poorly named '-fasm' flag,
|
||||||
|
@ -1851,7 +1857,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
|
||||||
// Provide diagnostic when a given target is not expected to be an OpenMP
|
// Provide diagnostic when a given target is not expected to be an OpenMP
|
||||||
// device or host.
|
// device or host.
|
||||||
if (Opts.OpenMP && !Opts.OpenMPIsDevice) {
|
if (Opts.OpenMP && !Opts.OpenMPIsDevice) {
|
||||||
llvm::Triple T(TargetOpts.Triple);
|
|
||||||
switch (T.getArch()) {
|
switch (T.getArch()) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -22,6 +22,8 @@ void test_point() {
|
||||||
(void)get_origin->x; // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments?}}
|
(void)get_origin->x; // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments?}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// These errors require C11.
|
||||||
|
#if __STDC_VERSION__ > 199901L
|
||||||
void noreturn_1() _Noreturn; // expected-error {{must precede function declarator}}
|
void noreturn_1() _Noreturn; // expected-error {{must precede function declarator}}
|
||||||
void noreturn_1() {
|
void noreturn_1() {
|
||||||
return; // expected-warning {{should not return}}
|
return; // expected-warning {{should not return}}
|
||||||
|
@ -29,3 +31,4 @@ void noreturn_1() {
|
||||||
void noreturn_2() _Noreturn { // expected-error {{must precede function declarator}}
|
void noreturn_2() _Noreturn { // expected-error {{must precede function declarator}}
|
||||||
return; // expected-warning {{should not return}}
|
return; // expected-warning {{should not return}}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -88,7 +88,6 @@
|
||||||
// COMMON:#define __ORDER_LITTLE_ENDIAN__ 1234
|
// COMMON:#define __ORDER_LITTLE_ENDIAN__ 1234
|
||||||
// COMMON:#define __ORDER_PDP_ENDIAN__ 3412
|
// COMMON:#define __ORDER_PDP_ENDIAN__ 3412
|
||||||
// COMMON:#define __STDC_HOSTED__ 1
|
// COMMON:#define __STDC_HOSTED__ 1
|
||||||
// COMMON:#define __STDC_VERSION__ 201112L
|
|
||||||
// COMMON:#define __STDC__ 1
|
// COMMON:#define __STDC__ 1
|
||||||
// COMMON:#define __VERSION__ {{.*}}
|
// COMMON:#define __VERSION__ {{.*}}
|
||||||
// COMMON:#define __clang__ 1
|
// COMMON:#define __clang__ 1
|
||||||
|
@ -98,7 +97,13 @@
|
||||||
// COMMON:#define __clang_version__ {{.*}}
|
// COMMON:#define __clang_version__ {{.*}}
|
||||||
// COMMON:#define __llvm__ 1
|
// COMMON:#define __llvm__ 1
|
||||||
//
|
//
|
||||||
|
// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-win32 < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
|
||||||
|
// RUN: %clang_cc1 -E -dM -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
|
||||||
|
// RUN: %clang_cc1 -E -dM -triple=x86_64-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
|
||||||
|
// RUN: %clang_cc1 -E -dM -triple=armv7a-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s
|
||||||
//
|
//
|
||||||
|
// C-DEFAULT:#define __STDC_VERSION__ 201112L
|
||||||
|
//
|
||||||
// RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
|
// RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
|
||||||
// FREESTANDING:#define __STDC_HOSTED__ 0
|
// FREESTANDING:#define __STDC_HOSTED__ 0
|
||||||
//
|
//
|
||||||
|
@ -8361,6 +8366,7 @@
|
||||||
// PS4:#define __SSE2__ 1
|
// PS4:#define __SSE2__ 1
|
||||||
// PS4:#define __SSE_MATH__ 1
|
// PS4:#define __SSE_MATH__ 1
|
||||||
// PS4:#define __SSE__ 1
|
// PS4:#define __SSE__ 1
|
||||||
|
// PS4:#define __STDC_VERSION__ 199901L
|
||||||
// PS4:#define __UINTMAX_TYPE__ long unsigned int
|
// PS4:#define __UINTMAX_TYPE__ long unsigned int
|
||||||
// PS4:#define __USER_LABEL_PREFIX__
|
// PS4:#define __USER_LABEL_PREFIX__
|
||||||
// PS4:#define __WCHAR_MAX__ 65535
|
// PS4:#define __WCHAR_MAX__ 65535
|
||||||
|
|
|
@ -122,5 +122,10 @@ struct test22 {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int test23_ty __attribute((deprecated));
|
typedef int test23_ty __attribute((deprecated));
|
||||||
|
// Redefining a typedef is a C11 feature.
|
||||||
|
#if __STDC_VERSION__ <= 199901L
|
||||||
|
// expected-note@-3 {{'test23_ty' has been explicitly marked deprecated here}}
|
||||||
|
#else
|
||||||
typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}}
|
typedef int test23_ty; // expected-note {{'test23_ty' has been explicitly marked deprecated here}}
|
||||||
|
#endif
|
||||||
test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}
|
test23_ty test23_v; // expected-warning {{'test23_ty' is deprecated}}
|
||||||
|
|
|
@ -8,7 +8,11 @@
|
||||||
typedef int * int_ptr;
|
typedef int * int_ptr;
|
||||||
|
|
||||||
// Parse nullability type specifiers.
|
// Parse nullability type specifiers.
|
||||||
typedef int * _Nonnull nonnull_int_ptr; // expected-note{{'_Nonnull' specified here}}
|
// This note requires C11.
|
||||||
|
#if __STDC_VERSION__ > 199901L
|
||||||
|
// expected-note@+2{{'_Nonnull' specified here}}
|
||||||
|
#endif
|
||||||
|
typedef int * _Nonnull nonnull_int_ptr;
|
||||||
typedef int * _Nullable nullable_int_ptr;
|
typedef int * _Nullable nullable_int_ptr;
|
||||||
typedef int * _Null_unspecified null_unspecified_int_ptr;
|
typedef int * _Null_unspecified null_unspecified_int_ptr;
|
||||||
|
|
||||||
|
@ -23,9 +27,14 @@ typedef int * _Null_unspecified _Nonnull conflicting_2; // expected-error{{nulla
|
||||||
typedef nonnull_int_ptr _Nonnull redundant_okay_1;
|
typedef nonnull_int_ptr _Nonnull redundant_okay_1;
|
||||||
|
|
||||||
// Conflicting nullability specifiers via a typedef are not.
|
// Conflicting nullability specifiers via a typedef are not.
|
||||||
|
// Some of these errors require C11.
|
||||||
|
#if __STDC_VERSION__ > 199901L
|
||||||
typedef nonnull_int_ptr _Nullable conflicting_2; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
|
typedef nonnull_int_ptr _Nullable conflicting_2; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
|
||||||
|
#endif
|
||||||
typedef nonnull_int_ptr nonnull_int_ptr_typedef;
|
typedef nonnull_int_ptr nonnull_int_ptr_typedef;
|
||||||
|
#if __STDC_VERSION__ > 199901L
|
||||||
typedef nonnull_int_ptr_typedef _Nullable conflicting_2; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
|
typedef nonnull_int_ptr_typedef _Nullable conflicting_2; // expected-error{{nullability specifier '_Nullable' conflicts with existing specifier '_Nonnull'}}
|
||||||
|
#endif
|
||||||
typedef nonnull_int_ptr_typedef nonnull_int_ptr_typedef_typedef;
|
typedef nonnull_int_ptr_typedef nonnull_int_ptr_typedef_typedef;
|
||||||
typedef nonnull_int_ptr_typedef_typedef _Null_unspecified conflicting_3; // expected-error{{nullability specifier '_Null_unspecified' conflicts with existing specifier '_Nonnull'}}
|
typedef nonnull_int_ptr_typedef_typedef _Null_unspecified conflicting_3; // expected-error{{nullability specifier '_Null_unspecified' conflicts with existing specifier '_Nonnull'}}
|
||||||
|
|
||||||
|
@ -69,8 +78,11 @@ typedef _Nonnull int * _Nullable * conflict_int_ptr_ptr_2; // expected-error{{n
|
||||||
|
|
||||||
// Nullability is not part of the canonical type.
|
// Nullability is not part of the canonical type.
|
||||||
typedef int * _Nonnull ambiguous_int_ptr;
|
typedef int * _Nonnull ambiguous_int_ptr;
|
||||||
|
// Redefining a typedef is a C11 feature.
|
||||||
|
#if __STDC_VERSION__ > 199901L
|
||||||
typedef int * ambiguous_int_ptr;
|
typedef int * ambiguous_int_ptr;
|
||||||
typedef int * _Nullable ambiguous_int_ptr;
|
typedef int * _Nullable ambiguous_int_ptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Printing of nullability.
|
// Printing of nullability.
|
||||||
float f;
|
float f;
|
||||||
|
|
|
@ -23,7 +23,10 @@ typedef struct __CFSetRef * CFSetRef __attribute__((objc_bridge(NSSet))); // exp
|
||||||
|
|
||||||
typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
|
typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
|
||||||
|
|
||||||
typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
|
// This error requires C11.
|
||||||
|
#if __STDC_VERSION__ > 199901L
|
||||||
|
typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) *CFUColor1Ref; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
|
typedef union __CFUColor __attribute__((objc_bridge(NSUColor))) *CFUColor1Ref; // expected-error {{parameter of 'objc_bridge' attribute must be 'id' when used on a typedef}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue