diff options
author | zlaski <zlaski@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-13 02:08:44 +0000 |
---|---|---|
committer | zlaski <zlaski@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-11-13 02:08:44 +0000 |
commit | 5dea86897277316778ac91cd98b2ed698937109b (patch) | |
tree | 8e3a09df7697ec7b47fb3922ba9d2dcbd933970e /gcc | |
parent | 753b364605dcdc2d3a1d16a80ed7724687741ba1 (diff) | |
download | gcc-5dea86897277316778ac91cd98b2ed698937109b.tar.gz |
[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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@90569 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/const-str-8.m | 39 | ||||
-rw-r--r-- | gcc/testsuite/objc.dg/const-str-9.m | 20 | ||||
-rw-r--r-- | gcc/varasm.c | 4 |
5 files changed, 73 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d7016a9cdde..b26460bfb09 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 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> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a2d6a24a205..a8ea52ed6f3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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. diff --git a/gcc/testsuite/objc.dg/const-str-8.m b/gcc/testsuite/objc.dg/const-str-8.m new file mode 100644 index 00000000000..60abcbd52b1 --- /dev/null +++ b/gcc/testsuite/objc.dg/const-str-8.m @@ -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; +} diff --git a/gcc/testsuite/objc.dg/const-str-9.m b/gcc/testsuite/objc.dg/const-str-9.m new file mode 100644 index 00000000000..033337452d4 --- /dev/null +++ b/gcc/testsuite/objc.dg/const-str-9.m @@ -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" } } */ diff --git a/gcc/varasm.c b/gcc/varasm.c index a92abb4917e..6019b5a7e06 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -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; |