From: Zack Weinberg Date: Tue, 6 Mar 2001 10:04:54 +0000 (+0000) Subject: objc-act.c (objc_add_static_instance): Set DECL_INITIAL and DECL_DEFER_OUTPUT on... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=69f8cbfaa92e236bf8b7841403d23e07fb113494;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8b9f61abeb7..1b1b3d092cc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +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 @@ -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 f5f27ad8038..99cb2971543 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 8e2e7b0399c..d0a7835b769 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 f0d14731836..fff03c7cfa6 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 247e22bc3d6..66462b3c96c 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 00000000000..21527dcbf15 --- /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 00000000000..54550d6f5e9 --- /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; +}