diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-04-29 07:13:33 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-04-29 07:13:33 +0000 |
commit | 0dbc5cd368fb5f0e5b4d5db8fdf08a6553713d46 (patch) | |
tree | e72e0999e33e11d6faa91e666f94ea7a4706d2f0 | |
parent | 48f2318c45c3567803990921a40e6bc12b6fb65b (diff) | |
download | gcc-0dbc5cd368fb5f0e5b4d5db8fdf08a6553713d46.zip gcc-0dbc5cd368fb5f0e5b4d5db8fdf08a6553713d46.tar.gz gcc-0dbc5cd368fb5f0e5b4d5db8fdf08a6553713d46.tar.bz2 |
decl.c (maybe_commonize_var): Further tweak support for systems without weak symbols.
* decl.c (maybe_commonize_var): Further tweak support for systems
without weak symbols.
* g++.old-deja/g++.pt/deduct5.C: Remove unnecessary initializer.
From-SVN: r66205
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/decl.c | 53 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.pt/deduct5.C | 2 |
4 files changed, 43 insertions, 21 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 84578bd..995f8bb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2003-04-29 Mark Mitchell <mark@codesourcery.com> + + * decl.c (maybe_commonize_var): Further tweak support for systems + without weak symbols. + 2003-04-27 Mark Mitchell <mark@codesourcery.com> * decl.c (maybe_commonize_var): Fix thinko in last patch. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6fe39c8..1e157f7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7346,34 +7346,34 @@ maybe_commonize_var (tree decl) || DECL_TEMPLATE_INSTANTIATION (DECL_CONTEXT (decl))) && TREE_PUBLIC (DECL_CONTEXT (decl))))) { - /* If flag_weak, we don't need to mess with this, as we can just - make the function weak, and let it refer to its unique local - copy. This works because we don't allow the function to be - inlined. */ - if (! flag_weak) + if (flag_weak) { - if (DECL_INTERFACE_KNOWN (current_function_decl)) - { - TREE_PUBLIC (decl) = 1; - DECL_EXTERNAL (decl) = DECL_EXTERNAL (current_function_decl); - } - else if (DECL_INITIAL (decl) == NULL_TREE - || DECL_INITIAL (decl) == error_mark_node) + /* With weak symbols, we simply make the variable COMDAT; + that will cause copies in multiple translations units to + be merged. */ + comdat_linkage (decl); + } + else + { + if (DECL_INITIAL (decl) == NULL_TREE + || DECL_INITIAL (decl) == error_mark_node) { + /* Without weak symbols, we can use COMMON to merge + uninitialized variables. */ TREE_PUBLIC (decl) = 1; DECL_COMMON (decl) = 1; } - /* else we lose. We can only do this if we can use common, - which we can't if it has been initialized. */ - - if (!TREE_PUBLIC (decl)) + else { + /* While for initialized variables, we must use internal + linkage -- which means that multiple copies will not + be merged. */ + TREE_PUBLIC (decl) = 0; + DECL_COMMON (decl) = 0; cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl); cp_warning_at (" you can work around this by removing the initializer", decl); } } - else - comdat_linkage (decl); } else if (DECL_LANG_SPECIFIC (decl) && DECL_COMDAT (decl)) /* Set it up again; we might have set DECL_INITIAL since the last @@ -7551,11 +7551,24 @@ reshape_init (tree type, tree *initp) { /* Loop through the initializable fields, gathering initializers. */ - /* FIXME support non-trivial labeled initializers. */ - while (*initp && field) + while (*initp) { tree field_init; + /* Handle designated initializers, as an extension. */ + if (TREE_PURPOSE (*initp)) + { + if (pedantic) + pedwarn ("ISO C++ does not allow designated initializers"); + field = lookup_field_1 (type, TREE_PURPOSE (*initp), + /*want_type=*/false); + if (!field || TREE_CODE (field) != FIELD_DECL) + error ("`%T' has no non-static data member named `%D'", + type, TREE_PURPOSE (*initp)); + } + if (!field) + break; + field_init = reshape_init (TREE_TYPE (field), initp); TREE_CHAIN (field_init) = CONSTRUCTOR_ELTS (new_init); CONSTRUCTOR_ELTS (new_init) = field_init; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b0d8e75..d125328 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-04-29 Mark Mitchell <mark@codesourcery.com> + + * g++.old-deja/g++.pt/deduct5.C: Remove unnecessary initializer. + 2003-04-28 Mark Mitchell <mark@codesourcery.com> PR c++/10180 diff --git a/gcc/testsuite/g++.old-deja/g++.pt/deduct5.C b/gcc/testsuite/g++.old-deja/g++.pt/deduct5.C index d47a766..7c3769c 100644 --- a/gcc/testsuite/g++.old-deja/g++.pt/deduct5.C +++ b/gcc/testsuite/g++.old-deja/g++.pt/deduct5.C @@ -7,7 +7,7 @@ template <typename T> int Foo (T const *ptr) { - static int count = 0; + static int count; printf ("%s\n", __PRETTY_FUNCTION__); count++; |