Commit 2256aa1c by Ziemowit Laski Committed by Ziemowit Laski

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
parent 0abe4170
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.
2004-11-12 Devang Patel <dpatel@apple.com>
......
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.
......
/* 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;
}
/* 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment