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
This commit is contained in:
Zack Weinberg 2001-03-06 10:04:54 +00:00
parent 1f50aafb85
commit 69f8cbfaa9
7 changed files with 61 additions and 10 deletions

View File

@ -1,3 +1,9 @@
2001-03-06 Zack Weinberg <zackw@stanford.edu>
* 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 <zackw@stanford.edu>
* aclocal.m4 (AM_GNU_GETTEXT): Don't AC_REQUIRE
@ -101,8 +107,8 @@
from 2000-09-06 Zack Weinberg <zack@wolery.cumb.org>
* 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 <neil@daikokuya.demon.co.uk>

View File

@ -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));

View File

@ -1,3 +1,12 @@
2001-03-06 Zack Weinberg <zackw@stanford.edu>
* 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 <neil@daikokuya.demon.co.uk>
* gcc.dg/cpp/macro7.c: New test.

View File

@ -1,8 +1,12 @@
#include <stdio.h>
/* Based on a test case contributed by Nicola Pero. */
#include <string.h>
#include <stdlib.h>
#include <objc/NXConstStr.h>
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;
}

View File

@ -1,8 +1,13 @@
#include <stdio.h>
/* Based on a test case contributed by Nicola Pero. */
#include <string.h>
#include <stdlib.h>
#include <objc/NXConstStr.h>
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;
}

View File

@ -0,0 +1,14 @@
/* Based on a test case contributed by Nicola Pero. */
#include <string.h>
#include <stdlib.h>
#include <objc/NXConstStr.h>
#define STRING "this is a string"
int main (int argc, void **args)
{
if (strcmp ([@STRING cString], STRING))
abort ();
return 0;
}

View File

@ -0,0 +1,12 @@
/* Based on a test case contributed by Nicola Pero. */
#include <string.h>
#include <stdlib.h>
#include <objc/NXConstStr.h>
int main(int argc, void **args)
{
if ([@"this is a string" length] != strlen ("this is a string"))
abort ();
return 0;
}