| 1 |
/* Ensure that the preprocessor handles ObjC string constants gracefully. */ |
| 2 |
/* Author: Ziemowit Laski <[email protected]> */ |
| 3 |
|
| 4 |
/* { dg-do run { target *-*-darwin* } } */ |
| 5 |
/* { dg-options "-fconstant-string-class=MyString" } */ |
| 6 |
/* { dg-options "-mno-constant-cfstrings -fconstant-string-class=MyString" { target *-*-darwin* } } */ |
| 7 |
|
| 8 |
#include <stdlib.h> |
| 9 |
|
| 10 |
@interface MyString |
| 11 |
{ |
| 12 |
void *isa; |
| 13 |
char *str; |
| 14 |
int len; |
| 15 |
} |
| 16 |
@end |
| 17 |
|
| 18 |
#define kMyStringMacro1 "My String" |
| 19 |
#define kMyStringMacro2 @"My String" |
| 20 |
|
| 21 |
void *_MyStringClassReference; |
| 22 |
|
| 23 |
@implementation MyString |
| 24 |
@end |
| 25 |
|
| 26 |
int main(void) { |
| 27 |
MyString* aString1 = @kMyStringMacro1; |
| 28 |
MyString* aString2 = kMyStringMacro2; |
| 29 |
if(aString1 != aString2) { |
| 30 |
abort(); |
| 31 |
} |
| 32 |
return 0; |
| 33 |
} |