OSDN Git Service

* class.c (check_field_decls): Only check C_TYPE_FIELDS_READONLY
[pf3gnuchains/gcc-fork.git] / gcc / cp / cp-tree.h
index 313b124..087a1c0 100644 (file)
@@ -82,13 +82,13 @@ struct diagnostic_context;
    6: BINFO_ACCESS (in BINFO)
 
    Usage of TYPE_LANG_FLAG_?:
-   0: C_TYPE_FIELDS_READONLY (in RECORD_TYPE or UNION_TYPE).
+   0: TYPE_DEPENDENT_P
    1: TYPE_HAS_CONSTRUCTOR.
    2: TYPE_HAS_DESTRUCTOR.
    3: TYPE_FOR_JAVA.
    4: TYPE_HAS_NONTRIVIAL_DESTRUCTOR
    5: IS_AGGR_TYPE.
-   6: TYPE_BUILT_IN.
+   6: TYPE_DEPENDENT_P_VALID
 
    Usage of DECL_LANG_FLAG_?:
    0: DECL_ERROR_REPORTED (in VAR_DECL).
@@ -253,13 +253,6 @@ struct lang_id2 GTY(())
   tree error_locus;
 };
 
-typedef struct flagged_type_tree_s GTY(())
-{
-  tree t;
-  int new_type_flag;
-  tree lookups;
-} flagged_type_tree;
-
 typedef struct template_parm_index_s GTY(())
 {
   struct tree_common common;
@@ -374,16 +367,16 @@ struct tree_overload GTY(())
   (TREE_CODE (NODE) == BASELINK)
 /* The BINFO indicating the base from which the BASELINK_FUNCTIONS came.  */
 #define BASELINK_BINFO(NODE) \
-  (TREE_OPERAND (BASELINK_CHECK (NODE), 0))
+  (((struct tree_baselink*) BASELINK_CHECK (NODE))->binfo)
 /* The functions referred to by the BASELINK; either a FUNCTION_DECL,
    a TEMPLATE_DECL, an OVERLOAD, or a TEMPLATE_ID_EXPR.  */
 #define BASELINK_FUNCTIONS(NODE) \
-  (TREE_OPERAND (BASELINK_CHECK (NODE), 1))
+  (((struct tree_baselink*) BASELINK_CHECK (NODE))->functions)
 /* The BINFO in which the search for the functions indicated by this baselink 
    began.  This base is used to determine the accessibility of functions 
    selected by overload resolution.  */
 #define BASELINK_ACCESS_BINFO(NODE) \
-  (TREE_OPERAND (BASELINK_CHECK (NODE), 2))
+  (((struct tree_baselink*) BASELINK_CHECK (NODE))->access_binfo)
 /* For a type-conversion operator, the BASELINK_OPTYPE indicates the type
    to which the conversion should occur.  This value is important if
    the BASELINK_FUNCTIONS include a template conversion operator --
@@ -392,6 +385,14 @@ struct tree_overload GTY(())
 #define BASELINK_OPTYPE(NODE) \
   (TREE_CHAIN (BASELINK_CHECK (NODE)))
 
+struct tree_baselink GTY(())
+{
+  struct tree_common common;
+  tree binfo;
+  tree functions;
+  tree access_binfo;
+};
+
 #define WRAPPER_ZC(NODE) (((struct tree_wrapper*)WRAPPER_CHECK (NODE))->z_c)
 
 struct tree_wrapper GTY(())
@@ -496,7 +497,8 @@ struct tree_srcloc GTY(())
   TREE_LANG_FLAG_3 (NODE)
 
 /* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only.  */
-#define C_TYPE_FIELDS_READONLY(TYPE) TYPE_LANG_FLAG_0 (TYPE)
+#define C_TYPE_FIELDS_READONLY(TYPE) \
+  (LANG_TYPE_CLASS_CHECK (TYPE)->fields_readonly)
 
 /* Store a value in that field.  */
 #define C_SET_EXP_ORIGINAL_CODE(EXP, CODE) \
@@ -521,6 +523,7 @@ enum cp_tree_node_structure_enum {
   TS_CP_PTRMEM,
   TS_CP_BINDING,
   TS_CP_OVERLOAD,
+  TS_CP_BASELINK,
   TS_CP_WRAPPER,
   TS_CP_SRCLOC,
   TS_CP_DEFAULT_ARG,
@@ -538,6 +541,7 @@ union lang_tree_node GTY((desc ("cp_tree_node_structure (&%h)"),
   struct ptrmem_cst GTY ((tag ("TS_CP_PTRMEM"))) ptrmem;
   struct tree_binding GTY ((tag ("TS_CP_BINDING"))) binding;
   struct tree_overload GTY ((tag ("TS_CP_OVERLOAD"))) overload;
+  struct tree_baselink GTY ((tag ("TS_CP_BASELINK"))) baselink;
   struct tree_wrapper GTY ((tag ("TS_CP_WRAPPER"))) wrapper;
   struct tree_srcloc GTY ((tag ("TS_CP_SRCLOC"))) srcloc;
   struct tree_default_arg GTY ((tag ("TS_CP_DEFAULT_ARG"))) default_arg;
@@ -784,7 +788,6 @@ struct saved_scope GTY(())
   tree x_previous_class_type;
   tree x_previous_class_values;
   tree x_saved_tree;
-  tree lookups;
   tree last_parms;
 
   HOST_WIDE_INT x_processing_template_decl;
@@ -851,8 +854,6 @@ struct saved_scope GTY(())
 
 /* A list of private types mentioned, for deferred access checking.  */
 
-#define type_lookups scope_chain->lookups
-
 extern GTY(()) struct saved_scope *scope_chain;
 
 /* Global state pertinent to the current function.  */
@@ -1028,12 +1029,17 @@ enum languages { lang_c, lang_cplusplus, lang_java };
   (CLASS_TYPE_P (T) || TREE_CODE (T) == ENUMERAL_TYPE)
 #define IS_OVERLOAD_TYPE(T) TAGGED_TYPE_P (T)
 
-/* In a *_TYPE, nonzero means a built-in type.  */
-#define TYPE_BUILT_IN(NODE) TYPE_LANG_FLAG_6 (NODE)
-
 /* True if this a "Java" type, defined in 'extern "Java"'.  */
 #define TYPE_FOR_JAVA(NODE) TYPE_LANG_FLAG_3 (NODE)
 
+/* True if this type is dependent.  This predicate is only valid if
+   TYPE_DEPENDENT_P_VALID is true.  */
+#define TYPE_DEPENDENT_P(NODE) TYPE_LANG_FLAG_0 (NODE)
+
+/* True if dependent_type_p has been called for this type, with the
+   result that TYPE_DEPENDENT_P is valid.  */
+#define TYPE_DEPENDENT_P_VALID(NODE) TYPE_LANG_FLAG_6(NODE)
+
 /* Nonzero if this type is const-qualified.  */
 #define CP_TYPE_CONST_P(NODE)                          \
   ((cp_type_quals (NODE) & TYPE_QUAL_CONST) != 0)
@@ -1137,6 +1143,7 @@ struct lang_type_class GTY(())
   unsigned has_arrow_overloaded : 1;
   unsigned interface_only : 1;
   unsigned interface_unknown : 1;
+  unsigned contains_empty_class_p : 1;
 
   unsigned marks: 6;
   unsigned vec_new_uses_cookie : 1;
@@ -1156,13 +1163,12 @@ struct lang_type_class GTY(())
   unsigned has_complex_assign_ref : 1;
   unsigned has_abstract_assign_ref : 1;
   unsigned non_aggregate : 1;
-  unsigned is_partial_instantiation : 1;
   unsigned java_interface : 1;
-
   unsigned anon_aggr : 1;
+
   unsigned non_zero_init : 1;
   unsigned empty_p : 1;
-  unsigned contains_empty_class_p : 1;
+  unsigned fields_readonly : 1;
 
   /* When adding a flag here, consider whether or not it ought to
      apply to a template instance if it applies to the template.  If
@@ -2416,17 +2422,6 @@ struct lang_decl GTY(())
    TEMPLATE_ID_EXPR if we had something like `typename X::Y<T>'.  */
 #define TYPENAME_TYPE_FULLNAME(NODE) (TYPE_FIELDS (NODE))
 
-/* Nonzero if NODE is an implicit typename.  */
-#define IMPLICIT_TYPENAME_P(NODE) \
-  (TREE_CODE (NODE) == TYPENAME_TYPE && TREE_TYPE (NODE))
-
-/* Nonzero if NODE is a TYPE_DECL that should not be visible because
-   it is from a dependent base class.  */
-#define IMPLICIT_TYPENAME_TYPE_DECL_P(NODE)    \
-  (TREE_CODE (NODE) == TYPE_DECL               \
-   && DECL_ARTIFICIAL (NODE)                   \
-   && IMPLICIT_TYPENAME_P (TREE_TYPE (NODE)))
-
 /* Nonzero in INTEGER_CST means that this int is negative by dint of
    using a twos-complement negated operand.  */
 #define TREE_NEGATED_INT(NODE) TREE_LANG_FLAG_0 (INTEGER_CST_CHECK (NODE))
@@ -2489,6 +2484,10 @@ struct lang_decl GTY(())
   (TREE_CODE (TYPE) == BOOLEAN_TYPE            \
    || TREE_CODE (TYPE) == INTEGER_TYPE)
 
+/* Returns true if TYPE is an integral or enumeration name.  */
+#define INTEGRAL_OR_ENUMERATION_TYPE_P(TYPE) \
+  (CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == ENUMERAL_TYPE)
+
 /* [basic.fundamental]
 
    Integral and floating types are collectively called arithmetic
@@ -2912,12 +2911,6 @@ struct lang_decl GTY(())
 #define DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION(DECL) \
   (DECL_TEMPLATE_INFO (DECL) && !DECL_USE_TEMPLATE (DECL))
 
-/* Nonzero if TYPE is a partial instantiation of a template class,
-   i.e., an instantiation whose instantiation arguments involve
-   template types.  */
-#define PARTIAL_INSTANTIATION_P(TYPE) \
-  (LANG_TYPE_CLASS_CHECK (TYPE)->is_partial_instantiation)
-
 /* Nonzero iff we are currently processing a declaration for an
    entity with its own template parameter list, and which is not a
    full specialization.  */
@@ -3197,6 +3190,32 @@ extern GTY(()) tree anonymous_namespace_name;
    function, two inside the body of a function in a local class, etc.)  */
 extern int function_depth;
 
+typedef struct deferred_access GTY(())
+{
+  /* A TREE_LIST representing name-lookups for which we have deferred
+     checking access controls.  We cannot check the accessibility of
+     names used in a decl-specifier-seq until we know what is being
+     declared because code like:
+
+       class A { 
+         class B {};
+         B* f();
+       }
+
+       A::B* A::f() { return 0; }
+
+     is valid, even though `A::B' is not generally accessible.  
+
+     The TREE_PURPOSE of each node is the scope used to qualify the
+     name being looked up; the TREE_VALUE is the DECL to which the
+     name was resolved.  */
+  tree deferred_access_checks;
+  /* TRUE iff we are deferring access checks.  */
+  bool deferring_access_checks_p;
+  /* The next deferred access data in stack or linked-list.  */
+  struct deferred_access *next;
+} deferred_access;
+
 /* in pt.c  */
 
 /* These values are used for the `STRICT' parameter to type_unification and
@@ -3634,9 +3653,9 @@ extern void finish_struct_1                       (tree);
 extern int resolves_to_fixed_type_p            (tree, int *);
 extern void init_class_processing              (void);
 extern int is_empty_class                      (tree);
-extern void pushclass                          (tree, int);
+extern void pushclass                          (tree, bool);
 extern void popclass                           (void);
-extern void push_nested_class                  (tree, int);
+extern void push_nested_class                  (tree);
 extern void pop_nested_class                   (void);
 extern int current_lang_depth                  (void);
 extern void push_lang_context                  (tree);
@@ -3743,7 +3762,6 @@ extern tree binding_for_name                    (tree, tree);
 extern tree namespace_binding                   (tree, tree);
 extern void set_namespace_binding               (tree, tree, tree);
 extern tree lookup_namespace_name              (tree, tree);
-extern tree build_typename_type                 (tree, tree, tree, tree);
 extern tree make_typename_type                 (tree, tree, tsubst_flags_t);
 extern tree make_unbound_class_template                (tree, tree, tsubst_flags_t);
 extern tree lookup_name_nonclass               (tree);
@@ -3778,7 +3796,6 @@ extern int complete_array_type                    (tree, tree, int);
 extern tree build_ptrmemfunc_type              (tree);
 extern tree build_ptrmem_type                   (tree, tree);
 /* the grokdeclarator prototype is in decl.h */
-extern int parmlist_is_exprlist                        (tree);
 extern int copy_fn_p                           (tree);
 extern tree get_scope_of_declarator             (tree);
 extern void grok_special_member_properties     (tree);
@@ -3848,7 +3865,6 @@ extern void check_member_template (tree);
 extern tree grokfield (tree, tree, tree, tree, tree);
 extern tree grokbitfield (tree, tree, tree);
 extern tree groktypefield                      (tree, tree);
-extern tree grokoptypename (tree, tree, tree);
 extern void cplus_decl_attributes (tree *, tree, int);
 extern tree constructor_name_full              (tree);
 extern tree constructor_name (tree);
@@ -3865,9 +3881,9 @@ extern void import_export_tinfo   (tree, tree, bool);
 extern tree build_cleanup                      (tree);
 extern void finish_file                                (void);
 extern tree build_expr_from_tree               (tree);
-extern tree build_cleanup                      PARAMS ((tree));
-extern void finish_file                                PARAMS ((void));
-extern tree build_expr_from_tree               PARAMS ((tree));
+extern tree build_cleanup                      (tree);
+extern void finish_file                                (void);
+extern tree build_expr_from_tree               (tree);
 extern tree build_offset_ref_call_from_tree     (tree, tree);
 extern tree build_call_from_tree                (tree, tree, bool);
 extern void set_decl_namespace (tree, tree, bool);
@@ -3955,7 +3971,7 @@ extern tree build_member_call                     (tree, tree, tree);
 extern tree build_offset_ref                   (tree, tree);
 extern tree resolve_offset_ref                 (tree);
 extern tree build_new                          (tree, tree, tree, int);
-extern tree build_vec_init                     (tree, tree, int);
+extern tree build_vec_init                     (tree, tree, tree, int);
 extern tree build_x_delete                     (tree, int, tree);
 extern tree build_delete                       (tree, tree, special_function_kind, int, int);
 extern void push_base_cleanups                 (void);
@@ -4003,7 +4019,6 @@ extern void cxx_init_options (void);
 /* in method.c */
 extern void init_method        (void);
 extern void set_mangled_name_for_decl (tree);
-extern tree build_opfncall (enum tree_code, int, tree, tree, tree);
 extern tree hack_identifier (tree, tree);
 extern tree make_thunk (tree, bool, tree, tree);
 extern void finish_thunk (tree);
@@ -4020,9 +4035,6 @@ extern bool maybe_clone_body (tree);
 /* in pt.c */
 extern void check_template_shadow              (tree);
 extern tree get_innermost_template_args         (tree, int);
-extern tree tsubst                             (tree, tree, tsubst_flags_t, tree);
-extern tree tsubst_expr                                (tree, tree, tsubst_flags_t, tree);
-extern tree tsubst_copy                                (tree, tree, tsubst_flags_t, tree);
 extern void maybe_begin_member_template_processing (tree);
 extern void maybe_end_member_template_processing (void);
 extern tree finish_member_template_decl         (tree);
@@ -4075,6 +4087,13 @@ extern void record_last_problematic_instantiation (void);
 extern tree current_instantiation               (void);
 extern tree maybe_get_template_decl_from_type_decl (tree);
 extern int processing_template_parmlist;
+extern bool dependent_type_p                    (tree);
+extern bool dependent_template_arg_p            (tree);
+extern bool dependent_template_p                (tree);
+extern bool type_dependent_expression_p         (tree);
+extern bool value_dependent_expression_p        (tree);
+extern tree resolve_typename_type               (tree, bool);
+extern tree resolve_typename_type_in_current_instantiation (tree);
 
 /* in repo.c */
 extern void repo_template_used (tree);
@@ -4097,7 +4116,6 @@ extern tree lookup_base (tree, tree, base_access, base_kind *);
 extern int types_overlap_p                     (tree, tree);
 extern tree get_vbase                          (tree, tree);
 extern tree get_dynamic_cast_base_type          (tree, tree);
-extern void type_access_control                        (tree, tree);
 extern int accessible_p                         (tree, tree);
 extern tree lookup_field                       (tree, tree, int, int);
 extern int lookup_fnfields_1                    (tree, tree);
@@ -4147,6 +4165,14 @@ extern tree build_baselink                      (tree, tree, tree, tree);
 extern tree adjust_result_of_qualified_name_lookup
                                                 (tree, tree, tree);
 /* in semantics.c */
+extern void push_deferring_access_checks       (bool defer_p);
+extern void resume_deferring_access_checks     (void);
+extern void stop_deferring_access_checks       (void);
+extern void pop_deferring_access_checks                (void);
+extern tree get_deferred_access_checks         (void);
+extern void pop_to_parent_deferring_access_checks      (void);
+extern void perform_deferred_access_checks     (void);
+extern void perform_or_defer_access_check      (tree, tree);
 extern void init_cp_semantics                   (void);
 extern tree finish_expr_stmt                    (tree);
 extern tree begin_if_stmt                       (void);
@@ -4207,11 +4233,7 @@ extern tree finish_pseudo_destructor_expr       (tree, tree, tree);
 extern tree finish_unary_op_expr                (enum tree_code, tree);
 extern tree finish_compound_literal             (tree, tree);
 extern tree finish_fname                        (tree);
-extern void save_type_access_control           (tree);
-extern void reset_type_access_control           (void);
-extern void decl_type_access_control           (tree);
 extern int begin_function_definition            (tree, tree, tree);
-extern tree begin_constructor_declarator        (tree, tree);
 extern tree finish_declarator                   (tree, tree, tree, tree, int);
 extern void finish_translation_unit             (void);
 extern tree finish_template_type_parm           (tree, tree);
@@ -4223,7 +4245,6 @@ extern void finish_default_args                 (void);
 extern tree finish_member_class_template        (tree);
 extern void finish_template_decl                (tree);
 extern tree finish_template_type                (tree, tree, int);
-extern void enter_scope_of                      (tree);
 extern tree finish_base_specifier               (tree, tree);
 extern void finish_member_declaration           (tree);
 extern void check_multiple_declarators          (void);
@@ -4412,7 +4433,6 @@ extern tree build_scoped_ref                      (tree, tree, tree *);
 extern tree build_x_arrow                      (tree);
 extern tree build_m_component_ref              (tree, tree);
 extern tree build_functional_cast              (tree, tree);
-extern void check_for_new_type                 (const char *, flagged_type_tree);
 extern tree add_exception_specifier             (tree, tree, int);
 extern tree merge_exception_specifiers          (tree, tree);