Commit df867456 by Nathan Sidwell Committed by Nathan Sidwell

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
parent 35bb2bee
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> 2002-03-11 Nathan Sidwell <nathan@codesourcery.com>
Revert 2001-03-26 Nathan Sidwell <nathan@codesourcery.com>, Revert 2001-03-26 Nathan Sidwell <nathan@codesourcery.com>,
......
...@@ -12858,19 +12858,6 @@ xref_tag (code_type_node, name, globalize) ...@@ -12858,19 +12858,6 @@ xref_tag (code_type_node, name, globalize)
redeclare_class_template (ref, current_template_parms); 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; TYPE_ATTRIBUTES (ref) = attributes;
return ref; return ref;
......
...@@ -5252,7 +5252,13 @@ handle_class_head (aggr, scope, id, defn_p, new_type_p) ...@@ -5252,7 +5252,13 @@ handle_class_head (aggr, scope, id, defn_p, new_type_p)
&& TREE_CODE (context) != BOUND_TEMPLATE_TEMPLATE_PARM); && TREE_CODE (context) != BOUND_TEMPLATE_TEMPLATE_PARM);
if (*new_type_p) if (*new_type_p)
push_scope (context); 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 ()) if (!xrefd_p && PROCESSING_REAL_TEMPLATE_DECL_P ())
decl = push_template_decl (decl); decl = push_template_decl (decl);
} }
......
2002-03-12 Nathan Sidwell <nathan@codesourcery.com>
* g++.dg/other/access1.C: New test.
2002-03-12 Jakub Jelinek <jakub@redhat.com> 2002-03-12 Jakub Jelinek <jakub@redhat.com>
* gcc.c-torture/execute/wchar_t-1.c: New test. * gcc.c-torture/execute/wchar_t-1.c: New test.
......
// { 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); }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment