mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-24 08:50:26 +08:00
tests for Darwin CFStrings
gcc/testsuite: Based on the CFString implementation in FSF apple/trunk branch. * gcc.dg/darwin-cfstring-1.c: New. * gcc.dg/darwin-cfstring-2.c: New. * gcc.dg/torture/darwin-cfstring-3.c: New. * g++.dg/other/darwin-cfstring1.C: New. * g++.dg/torture/darwin-cfstring-3.C: New. From-SVN: r165889
This commit is contained in:
parent
b8a1880581
commit
505bff7a28
@ -1,3 +1,13 @@
|
||||
2010-10-23 Iain Sandoe <iains@gcc.gnu.org>
|
||||
|
||||
Based on the CFString implementation in FSF apple/trunk branch.
|
||||
|
||||
* gcc.dg/darwin-cfstring-1.c: New.
|
||||
* gcc.dg/darwin-cfstring-2.c: New.
|
||||
* gcc.dg/torture/darwin-cfstring-3.c: New.
|
||||
* g++.dg/other/darwin-cfstring1.C: New.
|
||||
* g++.dg/torture/darwin-cfstring-3.C: New.
|
||||
|
||||
2010-10-23 Nicola Pero <nicola.pero@meta-innovation.com>
|
||||
|
||||
* objc.dg/demangle-1.m: New test.
|
||||
|
25
gcc/testsuite/g++.dg/other/darwin-cfstring1.C
Normal file
25
gcc/testsuite/g++.dg/other/darwin-cfstring1.C
Normal file
@ -0,0 +1,25 @@
|
||||
/* Test whether the __builtin__CFStringMakeConstantString
|
||||
"function" fails gracefully when handed a non-constant
|
||||
argument. This will only work on MacOS X 10.1.2 and later. */
|
||||
/* Developed by Ziemowit Laski <zlaski@apple.com>. */
|
||||
|
||||
/* { dg-do compile { target *-*-darwin* } } */
|
||||
/* { dg-options "-mconstant-cfstrings" } */
|
||||
|
||||
#include <CoreFoundation/CFString.h>
|
||||
|
||||
#ifdef __CONSTANT_CFSTRINGS__
|
||||
#undef CFSTR
|
||||
#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
|
||||
#endif
|
||||
|
||||
extern int cond;
|
||||
extern const char *func(void);
|
||||
|
||||
int main(void) {
|
||||
CFStringRef s1 = CFSTR("Str1");
|
||||
CFStringRef s2 = CFSTR(cond? "Str2": "Str3"); /* { dg-error "CFString literal expression is not a string constant" } */
|
||||
CFStringRef s3 = CFSTR(func()); /* { dg-error "CFString literal expression is not a string constant" } */
|
||||
|
||||
return 0;
|
||||
}
|
30
gcc/testsuite/g++.dg/torture/darwin-cfstring-3.C
Normal file
30
gcc/testsuite/g++.dg/torture/darwin-cfstring-3.C
Normal file
@ -0,0 +1,30 @@
|
||||
/* Test whether the __builtin__CFStringMakeConstantString
|
||||
"function" generates compile-time objects with the correct layout. */
|
||||
/* Developed by Ziemowit Laski <zlaski@apple.com>. */
|
||||
|
||||
/* { dg-do compile { target *-*-darwin* } } */
|
||||
/* { dg-options "-mconstant-cfstrings" } */
|
||||
|
||||
typedef const struct __CFString *CFStringRef;
|
||||
|
||||
#ifdef __CONSTANT_CFSTRINGS__
|
||||
#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
|
||||
#else
|
||||
#error __CONSTANT_CFSTRINGS__ not defined
|
||||
#endif
|
||||
|
||||
extern int cond;
|
||||
extern const char *func(void);
|
||||
|
||||
CFStringRef s0 = CFSTR("Hello" "there");
|
||||
|
||||
void foo(void) {
|
||||
const CFStringRef s1 = CFSTR("Str1");
|
||||
|
||||
s0 = s1;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
|
||||
/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
|
||||
/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t4\n" { target { *-*-darwin* && { lp64 } } } } } */
|
||||
/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t10\n" { target { *-*-darwin* && { lp64 } } } } } */
|
28
gcc/testsuite/gcc.dg/darwin-cfstring-1.c
Normal file
28
gcc/testsuite/gcc.dg/darwin-cfstring-1.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* Test whether the __builtin__CFStringMakeConstantString
|
||||
"function" fails gracefully when handed a non-constant
|
||||
argument. This will only work on MacOS X 10.1.2 and later. */
|
||||
/* Developed by Ziemowit Laski <zlaski@apple.com>. */
|
||||
|
||||
/* { dg-do compile { target *-*-darwin* } } */
|
||||
/* { dg-options "-mconstant-cfstrings" } */
|
||||
|
||||
typedef const struct __CFString *CFStringRef;
|
||||
|
||||
#ifdef __CONSTANT_CFSTRINGS__
|
||||
#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
|
||||
#else
|
||||
#error __CONSTANT_CFSTRINGS__ not defined
|
||||
#endif
|
||||
|
||||
extern int cond;
|
||||
extern const char *func(void);
|
||||
|
||||
const CFStringRef s0 = CFSTR("Hello" "there");
|
||||
|
||||
int main(void) {
|
||||
CFStringRef s1 = CFSTR("Str1");
|
||||
CFStringRef s2 = CFSTR(cond? "Str2": "Str3"); /* { dg-error "CFString literal expression is not a string constant" } */
|
||||
CFStringRef s3 = CFSTR(func()); /* { dg-error "CFString literal expression is not a string constant" } */
|
||||
|
||||
return 0;
|
||||
}
|
12
gcc/testsuite/gcc.dg/darwin-cfstring-2.c
Normal file
12
gcc/testsuite/gcc.dg/darwin-cfstring-2.c
Normal file
@ -0,0 +1,12 @@
|
||||
/* Test whether the __builtin__CFStringMakeConstantString
|
||||
"function" fails gracefully when used without the
|
||||
-mconstant-cfstrings flag. */
|
||||
/* Developed by Ziemowit Laski <zlaski@apple.com>. */
|
||||
|
||||
/* { dg-do compile { target *-*-darwin* } } */
|
||||
/* { dg-options "-mno-constant-cfstrings" } */
|
||||
|
||||
typedef const struct __CFString *CFStringRef;
|
||||
|
||||
const CFStringRef S = ((CFStringRef)__builtin___CFStringMakeConstantString("Testing"));
|
||||
/* { dg-error "built-in" "built-in function .* requires .* flag" { target *-*-* } 11 } */
|
30
gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
Normal file
30
gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* Test whether the __builtin__CFStringMakeConstantString
|
||||
"function" generates compile-time objects with the correct layout. */
|
||||
/* Developed by Ziemowit Laski <zlaski@apple.com>. */
|
||||
|
||||
/* { dg-do compile { target *-*-darwin* } } */
|
||||
/* { dg-options "-mconstant-cfstrings" } */
|
||||
|
||||
typedef const struct __CFString *CFStringRef;
|
||||
|
||||
#ifdef __CONSTANT_CFSTRINGS__
|
||||
#define CFSTR(STR) ((CFStringRef) __builtin___CFStringMakeConstantString (STR))
|
||||
#else
|
||||
#error __CONSTANT_CFSTRINGS__ not defined
|
||||
#endif
|
||||
|
||||
extern int cond;
|
||||
extern const char *func(void);
|
||||
|
||||
CFStringRef s0 = CFSTR("Hello" "there");
|
||||
|
||||
void foo(void) {
|
||||
const CFStringRef s1 = CFSTR("Str1");
|
||||
|
||||
s0 = s1;
|
||||
}
|
||||
|
||||
/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
|
||||
/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+LC.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
|
||||
/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t4\n" { target { *-*-darwin* && { lp64 } } } } } */
|
||||
/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t10\n" { target { *-*-darwin* && { lp64 } } } } } */
|
Loading…
x
Reference in New Issue
Block a user