hanchenye-llvm-project/clang/test/Sema/builtins.c

43 lines
1.3 KiB
C
Raw Normal View History

// RUN: clang-cc %s -fsyntax-only -verify -pedantic -triple=i686-apple-darwin9
// This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si
int test1(float a, int b) {
return __builtin_isless(a, b);
}
int test2(int a, int b) {
return __builtin_islessequal(a, b); // expected-error {{floating point type}}
}
int test3(double a, float b) {
return __builtin_isless(a, b);
}
int test4(int* a, double b) {
return __builtin_islessequal(a, b); // expected-error {{floating point type}}
}
int test5(float a, long double b) {
return __builtin_isless(a, b, b); // expected-error {{too many arguments}}
}
int test6(float a, long double b) {
return __builtin_islessequal(a); // expected-error {{too few arguments}}
}
#define CFSTR __builtin___CFStringMakeConstantString
void cfstring() {
CFSTR("\242");
CFSTR("\0"); // expected-warning {{ CFString literal contains NUL character }}
CFSTR(242); // expected-error {{ CFString literal is not a string constant }} expected-warning {{incompatible integer to pointer conversion}}
CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
}
Simplify the scheme used for keywords, and change the classification scheme to be more useful. The new scheme introduces a set of categories that should be more readable, and also reflects what we want to consider as an extension more accurately. Specifically, it makes the "what is a keyword" determination accurately reflect whether the keyword is a GNU or Microsoft extension. I also introduced separate flags for keyword aliases; this is useful because the classification of the aliases is mostly unrelated to the classification of the original keyword. This patch treats anything that's in the implementation namespace (prefixed with "__", or "_X" where "X" is any upper-case letter) as a keyword without marking it as an extension. This is consistent with the standards in that an implementation is allowed to define arbitrary extensions in the implementation namespace without violating the standard. This gets rid of all the nasty "extension used" warnings for stuff like __attribute__ in -pedantic mode. We still warn for extensions outside of the the implementation namespace, like typeof. If someone wants to implement -Wextensions or something like that, we could add additional information to the keyword table. This also removes processing for the unused "Boolean" language option; such an extension isn't supported on any other C implementation, so I don't see any point to adding it. The changes to test/CodeGen/inline.c are required because previously, we weren't actually disabling the "inline" keyword in -std=c89 mode. I'll remove Boolean and NoExtensions from LangOptions in a follow-up commit. llvm-svn: 70281
2009-04-28 11:13:54 +08:00
typedef __attribute__(( ext_vector_type(16) )) unsigned char uchar16;
// rdar://5905347
unsigned char foo( short v ) {
uchar16 c;
return __builtin_ia32_vec_ext_v4si( c ); // expected-error {{too few arguments to function}}
}