PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / darwin-cfstring-1.c
blobb9565e721a31ff8d743f219c517297bc1c78cc68
1 /* Test whether the __builtin__CFStringMakeConstantString
2 "function" fails gracefully when handed a non-constant
3 argument. This will only work on MacOS X 10.1.2 and later. */
4 /* Developed by Ziemowit Laski <zlaski@apple.com>. */
6 /* { dg-do compile { target *-*-darwin* } } */
7 /* { dg-options "-mconstant-cfstrings" } */
9 typedef const struct __CFString *CFStringRef;
11 #ifdef __CONSTANT_CFSTRINGS__
12 #define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
13 #else
14 #error __CONSTANT_CFSTRINGS__ not defined
15 #endif
17 extern int cond;
18 extern const char *func(void);
20 const CFStringRef s0 = CFSTR("Hello" "there");
22 int main(void) {
23 CFStringRef s1 = CFSTR("Str1");
24 CFStringRef s2 = CFSTR(cond? "Str2": "Str3"); /* { dg-error "CFString literal expression is not a string constant" } */
25 CFStringRef s3 = CFSTR(func()); /* { dg-error "CFString literal expression is not a string constant" } */
27 return 0;