From 69f8cbfaa92e236bf8b7841403d23e07fb113494 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Tue, 6 Mar 2001 10:04:54 +0000 Subject: [PATCH] objc-act.c (objc_add_static_instance): Set DECL_INITIAL and DECL_DEFER_OUTPUT on the decl we create... * objc/objc-act.c (objc_add_static_instance): Set DECL_INITIAL and DECL_DEFER_OUTPUT on the decl we create, before calling rest_of_decl_compilation. testsuite: * objc/execute/string1.m, objc/execute/string2.m: Compare the result of -cString against what we expect it to be; don't just print it out for no one to read. * objc/execute/string3.m, objc/execute/string4.m: New tests. Based on testcases provided by Nicola Pero. From-SVN: r40261 --- gcc/ChangeLog | 10 ++++++++-- gcc/objc/objc-act.c | 9 +++++---- gcc/testsuite/ChangeLog | 9 +++++++++ gcc/testsuite/objc/execute/string1.m | 8 ++++++-- gcc/testsuite/objc/execute/string2.m | 9 +++++++-- gcc/testsuite/objc/execute/string3.m | 14 ++++++++++++++ gcc/testsuite/objc/execute/string4.m | 12 ++++++++++++ 7 files changed, 61 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/objc/execute/string3.m create mode 100644 gcc/testsuite/objc/execute/string4.m diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8b9f61a..1b1b3d0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2001-03-06 Zack Weinberg + * objc/objc-act.c (objc_add_static_instance): Set DECL_INITIAL + and DECL_DEFER_OUTPUT on the decl we create, before calling + rest_of_decl_compilation. + +2001-03-06 Zack Weinberg + * aclocal.m4 (AM_GNU_GETTEXT): Don't AC_REQUIRE AC_FUNC_ALLOCA. * configure, config.in: Regenerate. @@ -101,8 +107,8 @@ from 2000-09-06 Zack Weinberg * c-parse.gperf, c-gperf.h: Delete. - (c-gperf.h was accidently re-added to the CVS repo in the rev 1.16 commit - by tromey) + (c-gperf.h was accidently re-added to the CVS repo in the rev + 1.16 commit by tromey) 2001-03-03 Neil Booth diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index f5f27ad..99cb297 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1474,13 +1474,14 @@ objc_add_static_instance (constructor, class_decl) DECL_COMMON (decl) = 1; TREE_STATIC (decl) = 1; DECL_ARTIFICIAL (decl) = 1; + DECL_INITIAL (decl) = constructor; + + /* We may be writing something else just now. + Postpone till end of input. */ + DECL_DEFER_OUTPUT (decl) = 1; pushdecl_top_level (decl); rest_of_decl_compilation (decl, 0, 1, 0); - /* Do this here so it gets output later instead of possibly - inside something else we are writing. */ - DECL_INITIAL (decl) = constructor; - /* Add the DECL to the head of this CLASS' list. */ TREE_PURPOSE (*chain) = tree_cons (NULL_TREE, decl, TREE_PURPOSE (*chain)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8e2e7b0..d0a7835 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2001-03-06 Zack Weinberg + + * objc/execute/string1.m, objc/execute/string2.m: Compare the + result of -cString against what we expect it to be; don't just + print it out for no one to read. + + * objc/execute/string3.m, objc/execute/string4.m: New tests. + Based on testcases provided by Nicola Pero. + 2001-03-03 Neil Booth * gcc.dg/cpp/macro7.c: New test. diff --git a/gcc/testsuite/objc/execute/string1.m b/gcc/testsuite/objc/execute/string1.m index f0d1473..fff03c7 100644 --- a/gcc/testsuite/objc/execute/string1.m +++ b/gcc/testsuite/objc/execute/string1.m @@ -1,8 +1,12 @@ -#include +/* Based on a test case contributed by Nicola Pero. */ + +#include +#include #include int main(int argc, void **args) { - printf ([@"this is a string\n" cString]); + if (strcmp ([@"this is a string" cString], "this is a string")) + abort (); return 0; } diff --git a/gcc/testsuite/objc/execute/string2.m b/gcc/testsuite/objc/execute/string2.m index 247e22b..66462b3 100644 --- a/gcc/testsuite/objc/execute/string2.m +++ b/gcc/testsuite/objc/execute/string2.m @@ -1,8 +1,13 @@ -#include +/* Based on a test case contributed by Nicola Pero. */ + +#include +#include #include int main(int argc, void **args) { - printf ([@"this " @"is " @"a " @"string\n" cString]); + if (strcmp ([@"this " @"is " @"a " @"string" cString], + "this " "is " "a " "string")) + abort (); return 0; } diff --git a/gcc/testsuite/objc/execute/string3.m b/gcc/testsuite/objc/execute/string3.m new file mode 100644 index 0000000..21527dc --- /dev/null +++ b/gcc/testsuite/objc/execute/string3.m @@ -0,0 +1,14 @@ +/* Based on a test case contributed by Nicola Pero. */ + +#include +#include +#include + +#define STRING "this is a string" + +int main (int argc, void **args) +{ + if (strcmp ([@STRING cString], STRING)) + abort (); + return 0; +} diff --git a/gcc/testsuite/objc/execute/string4.m b/gcc/testsuite/objc/execute/string4.m new file mode 100644 index 0000000..54550d6 --- /dev/null +++ b/gcc/testsuite/objc/execute/string4.m @@ -0,0 +1,12 @@ +/* Based on a test case contributed by Nicola Pero. */ + +#include +#include +#include + +int main(int argc, void **args) +{ + if ([@"this is a string" length] != strlen ("this is a string")) + abort (); + return 0; +} -- 2.7.4