Commit 6eb35968 by David Edelsohn Committed by David Edelsohn

re PR c++/7228 (ICE when using member template and template function)

        PR c++/7228
        * cp-tree.h (CLASSTYPE_READONLY_FIELDS_NEED_INIT): Check that
        lang_type structure exists before accessing field.
        (SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT): New macro.
        (CLASSTYPE_REF_FIELDS_NEED_INIT): Similar.
        (SET_CLASSTYPE_REF_FIELDS_NEED_INIT): New macro.
        * class.c (check_field_decls): Use new macros.
        * typeck2.c (process_init_constructor): Remove redundant check for
        existence of lang_type structure.

From-SVN: r58532
parent 8c40b097
2002-10-24 David Edelsohn <edelsohn@gnu.org>
PR c++/7228
* cp-tree.h (CLASSTYPE_READONLY_FIELDS_NEED_INIT): Check that
lang_type structure exists before accessing field.
(SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT): New macro.
(CLASSTYPE_REF_FIELDS_NEED_INIT): Similar.
(SET_CLASSTYPE_REF_FIELDS_NEED_INIT): New macro.
* class.c (check_field_decls): Use new macros.
* typeck2.c (process_init_constructor): Remove redundant check for
existence of lang_type structure.
2002-10-24 Mark Mitchell <mark@codesourcery.com>
* class.c (end_of_base): New method.
......
......@@ -3264,7 +3264,7 @@ check_field_decls (tree t, tree *access_decls,
{
CLASSTYPE_NON_POD_P (t) = 1;
if (DECL_INITIAL (x) == NULL_TREE)
CLASSTYPE_REF_FIELDS_NEED_INIT (t) = 1;
SET_CLASSTYPE_REF_FIELDS_NEED_INIT (t, 1);
/* ARM $12.6.2: [A member initializer list] (or, for an
aggregate, initialization by a brace-enclosed list) is the
......@@ -3299,7 +3299,7 @@ check_field_decls (tree t, tree *access_decls,
{
C_TYPE_FIELDS_READONLY (t) = 1;
if (DECL_INITIAL (x) == NULL_TREE)
CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) = 1;
SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t, 1);
/* ARM $12.6.2: [A member initializer list] (or, for an
aggregate, initialization by a brace-enclosed list) is the
......@@ -3316,8 +3316,9 @@ check_field_decls (tree t, tree *access_decls,
else if (IS_AGGR_TYPE (type))
{
C_TYPE_FIELDS_READONLY (t) |= C_TYPE_FIELDS_READONLY (type);
CLASSTYPE_READONLY_FIELDS_NEED_INIT (t)
|= CLASSTYPE_READONLY_FIELDS_NEED_INIT (type);
SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t,
CLASSTYPE_READONLY_FIELDS_NEED_INIT (t)
| CLASSTYPE_READONLY_FIELDS_NEED_INIT (type));
}
/* Core issue 80: A nonstatic data member is required to have a
......
......@@ -1476,13 +1476,21 @@ struct lang_type GTY(())
#define CLASSTYPE_DECLARED_CLASS(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->declared_class)
/* Nonzero if this class has const members which have no specified initialization. */
#define CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->h.const_needs_init)
/* Nonzero if this class has ref members which have no specified initialization. */
#define CLASSTYPE_REF_FIELDS_NEED_INIT(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->h.ref_needs_init)
/* Nonzero if this class has const members
which have no specified initialization. */
#define CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE) \
(TYPE_LANG_SPECIFIC (NODE) \
? LANG_TYPE_CLASS_CHECK (NODE)->h.const_needs_init : 0)
#define SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE, VALUE) \
(LANG_TYPE_CLASS_CHECK (NODE)->h.const_needs_init = (VALUE))
/* Nonzero if this class has ref members
which have no specified initialization. */
#define CLASSTYPE_REF_FIELDS_NEED_INIT(NODE) \
(TYPE_LANG_SPECIFIC (NODE) \
? LANG_TYPE_CLASS_CHECK (NODE)->h.ref_needs_init : 0)
#define SET_CLASSTYPE_REF_FIELDS_NEED_INIT(NODE, VALUE) \
(LANG_TYPE_CLASS_CHECK (NODE)->h.ref_needs_init = (VALUE))
/* Nonzero if this class is included from a header file which employs
`#pragma interface', and it is not included in its implementation file. */
......
......@@ -830,8 +830,7 @@ process_init_constructor (type, init, elts)
{
if (TREE_READONLY (field))
error ("uninitialized const member `%D'", field);
else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field))
&& CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
else if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
error ("member `%D' with uninitialized const fields",
field);
else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
......
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