diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2002-03-12 23:32:47 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2002-03-12 23:32:47 +0000 |
commit | df867456d79fcb8d136e9e64e6caff4435eb5ca7 (patch) | |
tree | 43e771810125bfcb9dfe317ea9f8984be22db3a4 | |
parent | 35bb2beeac02c760aac69d0eff9605bf9c2f2204 (diff) | |
download | gcc-df867456d79fcb8d136e9e64e6caff4435eb5ca7.zip gcc-df867456d79fcb8d136e9e64e6caff4435eb5ca7.tar.gz gcc-df867456d79fcb8d136e9e64e6caff4435eb5ca7.tar.bz2 |
re PR c++/5659 (default access for class/struct bug)
cp:
PR c++/5659
* decl.c (xref_tag): Don't set CLASSTYPE_DECLARED_CLASS here.
* decl2.c (handle_class_head): Set CLASSTYPE_DECLARED_CLASS for
definitions.
testsuite:
* g++.dg/other/access1.C: New test.
From-SVN: r50692
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 13 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/other/access1.C | 26 |
5 files changed, 44 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1ad21d3..e9d8283 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2002-03-12 Nathan Sidwell <nathan@codesourcery.com> + + PR c++/5659 + * decl.c (xref_tag): Don't set CLASSTYPE_DECLARED_CLASS here. + * decl2.c (handle_class_head): Set CLASSTYPE_DECLARED_CLASS for + definitions. + 2002-03-11 Nathan Sidwell <nathan@codesourcery.com> Revert 2001-03-26 Nathan Sidwell <nathan@codesourcery.com>, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d7047fc..9b5d3e9 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12858,19 +12858,6 @@ xref_tag (code_type_node, name, globalize) redeclare_class_template (ref, current_template_parms); } - /* Until the type is defined, tentatively accept whatever - structure tag the user hands us. */ - if (!COMPLETE_TYPE_P (ref) - && ref != current_class_type - /* Have to check this, in case we have contradictory tag info. */ - && IS_AGGR_TYPE_CODE (TREE_CODE (ref))) - { - if (tag_code == class_type) - CLASSTYPE_DECLARED_CLASS (ref) = 1; - else if (tag_code == record_type) - CLASSTYPE_DECLARED_CLASS (ref) = 0; - } - TYPE_ATTRIBUTES (ref) = attributes; return ref; diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 71dc388..8841dec 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -5252,7 +5252,13 @@ handle_class_head (aggr, scope, id, defn_p, new_type_p) && TREE_CODE (context) != BOUND_TEMPLATE_TEMPLATE_PARM); if (*new_type_p) push_scope (context); - + + if (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE) + /* It is legal to define a class with a different class key, + and this changes the default member access. */ + CLASSTYPE_DECLARED_CLASS (TREE_TYPE (decl)) + = aggr == class_type_node; + if (!xrefd_p && PROCESSING_REAL_TEMPLATE_DECL_P ()) decl = push_template_decl (decl); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ae6ec90..cde8e62 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-03-12 Nathan Sidwell <nathan@codesourcery.com> + + * g++.dg/other/access1.C: New test. + 2002-03-12 Jakub Jelinek <jakub@redhat.com> * gcc.c-torture/execute/wchar_t-1.c: New test. diff --git a/gcc/testsuite/g++.dg/other/access1.C b/gcc/testsuite/g++.dg/other/access1.C new file mode 100644 index 0000000..ee3239b --- /dev/null +++ b/gcc/testsuite/g++.dg/other/access1.C @@ -0,0 +1,26 @@ +// { dg-do compile } + +// Copyright (C) 2002 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 12 Mar 2002 <nathan@codesourcery.com> + +// PR c++/5659. Failed to notice default accessed changed + +class Foo; +struct Foo +{ + static int m; +}; + +class Outer { + private: + class Inner; + Inner *i; + public: + void pub(); +}; + +struct Outer::Inner { + Inner(int i); +}; + +void Outer::pub() { i = new Inner(Foo::m); } |