re PR objc/17923 (const-str-[34].m fails on the mainline (next runtime))

2004-10-21  Andrew Pinski  <pinskia@physics.uc.edu>

        PR objc/17923
        * tree.c (staticp): A CONST_DECL has static storage if either
        TREE_STATIC or DECL_EXTERNAL is set.
        * c-decl.c (pushdecl_top_level): Accept CONST_DECLs which can
        have null names.

2004-10-21  Andrew Pinski  <pinskia@physics.uc.edu>

        PR objc/17923
        * objc-act.c (objc_build_string_object): Create a CONST_DECL
        for the NeXT runtime case.

2004-10-21  Andrew Pinski  <pinskia@physics.uc.edu>

        PR objc/17923
        * objc.dg/const-str-7.m: New test.

From-SVN: r89384
This commit is contained in:
Andrew Pinski 2004-10-21 16:29:58 +00:00 committed by Andrew Pinski
parent 5bee567d89
commit 943db34743
7 changed files with 80 additions and 7 deletions

View File

@ -1,3 +1,11 @@
2004-10-21 Andrew Pinski <pinskia@physics.uc.edu>
PR objc/17923
* tree.c (staticp): A CONST_DECL has static storage if either
TREE_STATIC or DECL_EXTERNAL is set.
* c-decl.c (pushdecl_top_level): Accept CONST_DECLs which can
have null names.
2004-10-21 Kazu Hirata <kazu@cs.umass.edu>
* expr.c (store_expr): Remove dont_store_target.

View File

@ -2128,12 +2128,11 @@ pushdecl_top_level (tree x)
{
tree name;
bool nested = false;
gcc_assert (TREE_CODE (x) == VAR_DECL);
gcc_assert (TREE_CODE (x) == VAR_DECL || TREE_CODE (x) == CONST_DECL);
name = DECL_NAME (x);
gcc_assert (!I_SYMBOL_BINDING (name));
gcc_assert (TREE_CODE (x) == CONST_DECL || !I_SYMBOL_BINDING (name));
if (TREE_PUBLIC (x))
{

View File

@ -1,3 +1,9 @@
2004-10-21 Andrew Pinski <pinskia@physics.uc.edu>
PR objc/17923
* objc-act.c (objc_build_string_object): Create a CONST_DECL
for the NeXT runtime case.
2004-10-02 Kazu Hirata <kazu@cs.umass.edu>
* objc-act.c: Fix comment typos.

View File

@ -1661,6 +1661,7 @@ objc_build_string_object (tree string)
if (!desc)
{
tree var;
*loc = desc = ggc_alloc (sizeof (*desc));
desc->literal = string;
@ -1685,14 +1686,18 @@ objc_build_string_object (tree string)
if (!flag_next_runtime)
constructor
= objc_add_static_instance (constructor, constant_string_type);
else
{
var = build_decl (CONST_DECL, NULL, TREE_TYPE (constructor));
DECL_INITIAL (var) = constructor;
TREE_STATIC (var) = 1;
pushdecl_top_level (var);
constructor = var;
}
desc->constructor = constructor;
}
addr = build_unary_op (ADDR_EXPR, desc->constructor, 1);
TREE_CONSTANT (addr) = true;
TREE_INVARIANT (addr) = true;
TREE_STATIC (addr) = true;
return addr;
}

View File

@ -1,3 +1,8 @@
2004-10-21 Andrew Pinski <pinskia@physics.uc.edu>
PR objc/17923
* objc.dg/const-str-7.m: New test.
2004-10-20 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* g++.dg/template/memfriend11.C: Fix comment typo.

View File

@ -0,0 +1,46 @@
/* Test to make sure that the const objc strings are the same across
scopes. */
/* Developed by Andrew Pinski <pinskia@physics.uc.edu> */
/* { dg-options "-fnext-runtime -fconstant-string-class=Foo -lobjc" } */
/* { dg-do run { target *-*-darwin* } } */
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <objc/objc.h>
#include <objc/Object.h>
@interface Foo: Object {
char *cString;
unsigned int len;
}
- (char *)customString;
@end
struct objc_class _FooClassReference;
@implementation Foo : Object
- (char *)customString {
return cString;
}
@end
int main () {
Foo *string = @"bla";
{
Foo *string2 = @"bla";
if(string != string2)
abort();
printf("Strings are being uniqued properly\n");
}
return 0;
}

View File

@ -1489,6 +1489,10 @@ staticp (tree arg)
&& ! DECL_NON_ADDR_CONST_P (arg)
? arg : NULL);
case CONST_DECL:
return ((TREE_STATIC (arg) || DECL_EXTERNAL (arg))
? arg : NULL);
case CONSTRUCTOR:
return TREE_STATIC (arg) ? arg : NULL;