varasm.c (output_addressed_constants): For CONST_DECLs, output the initializer if present.
[gcc/ChangeLog] 2004-11-12 Ziemowit Laski <zlaski@apple.com> * varasm.c (output_addressed_constants): For CONST_DECLs, output the initializer if present. [gcc/testsuite/ChangeLog] 2004-11-12 Ziemowit Laski <zlaski@apple.com> * objc.dg/const-str-8.m, objc.dg/const-str-9.m: New tests. From-SVN: r90569
This commit is contained in:
parent
0abe417015
commit
2256aa1cff
5 changed files with 73 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
2004-11-12 Ziemowit Laski <zlaski@apple.com>
|
||||
|
||||
* varasm.c (output_addressed_constants): For CONST_DECLs,
|
||||
output the initializer if present.
|
||||
|
||||
2004-11-12 Ziemowit Laski <zlaski@apple.com>
|
||||
|
||||
* config/rs6000/darwin.h: Fix confusing typo in comment.
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2004-11-12 Ziemowit Laski <zlaski@apple.com>
|
||||
|
||||
* objc.dg/const-str-8.m, objc.dg/const-str-9.m:
|
||||
New tests.
|
||||
|
||||
2004-11-12 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
* lib/gcc-dg.exp (dg-forbid-option): New function.
|
||||
|
|
39
gcc/testsuite/objc.dg/const-str-8.m
Normal file
39
gcc/testsuite/objc.dg/const-str-8.m
Normal file
|
@ -0,0 +1,39 @@
|
|||
/* Test for assigning compile-time constant-string objects to static variables. */
|
||||
/* Contributed by Ziemowit Laski <zlaski@apple.com> */
|
||||
|
||||
/* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
|
||||
/* { dg-do run { target *-*-darwin* } } */
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <objc/Object.h>
|
||||
|
||||
@interface Foo: Object {
|
||||
char *cString;
|
||||
unsigned int len;
|
||||
}
|
||||
@end
|
||||
|
||||
struct objc_class _FooClassReference;
|
||||
|
||||
@implementation Foo : Object
|
||||
- (char *)customString {
|
||||
return cString;
|
||||
}
|
||||
@end
|
||||
|
||||
static const Foo *appKey = @"MyApp";
|
||||
static int CFPreferencesSynchronize (const Foo *ref) {
|
||||
return ref == appKey;
|
||||
}
|
||||
|
||||
static void PrefsSynchronize(void)
|
||||
{
|
||||
if(!CFPreferencesSynchronize(appKey))
|
||||
abort();
|
||||
}
|
||||
|
||||
int main () {
|
||||
PrefsSynchronize();
|
||||
return 0;
|
||||
}
|
20
gcc/testsuite/objc.dg/const-str-9.m
Normal file
20
gcc/testsuite/objc.dg/const-str-9.m
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* Test if ObjC constant strings get placed in the correct section. */
|
||||
/* Contributed by Ziemowit Laski <zlaski@apple.com> */
|
||||
|
||||
/* { dg-options "-fnext-runtime" } */
|
||||
/* { dg-do compile { target *-*-darwin* } } */
|
||||
|
||||
#include <objc/Object.h>
|
||||
|
||||
@interface NSConstantString: Object {
|
||||
char *cString;
|
||||
unsigned int len;
|
||||
}
|
||||
@end
|
||||
|
||||
extern struct objc_class _NSConstantStringClassReference;
|
||||
|
||||
static const NSConstantString *appKey = @"MyApp";
|
||||
|
||||
/* { dg-final { scan-assembler ".section __OBJC, __cstring_object" } } */
|
||||
/* { dg-final { scan-assembler ".long\t__NSConstantStringClassReference\n\t.long\t.*\n\t.long\t5\n\t.data" } } */
|
|
@ -3385,6 +3385,10 @@ output_addressed_constants (tree exp)
|
|||
tem = TREE_OPERAND (tem, 0))
|
||||
;
|
||||
|
||||
/* If we have an initialized CONST_DECL, retrieve the initializer. */
|
||||
if (TREE_CODE (tem) == CONST_DECL && DECL_INITIAL (tem))
|
||||
tem = DECL_INITIAL (tem);
|
||||
|
||||
if (CONSTANT_CLASS_P (tem) || TREE_CODE (tem) == CONSTRUCTOR)
|
||||
output_constant_def (tem, 0);
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue