diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2003-07-18 17:19:41 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2003-07-18 17:19:41 +0000 |
commit | a3f10e50d72e939d3d413d0c84a92af34b53c3b6 (patch) | |
tree | 739c2d965b5f14c53b06da69cb304426d2ea001d /gcc/cp/semantics.c | |
parent | c26052b06be808348a5bf78f9bf3d4a29cb80843 (diff) | |
download | gcc-a3f10e50d72e939d3d413d0c84a92af34b53c3b6.zip gcc-a3f10e50d72e939d3d413d0c84a92af34b53c3b6.tar.gz gcc-a3f10e50d72e939d3d413d0c84a92af34b53c3b6.tar.bz2 |
cp-tree.h (finish_non_static_data_member): Add object param.
cp:
* cp-tree.h (finish_non_static_data_member): Add object param.
* method.c (hack_identifier): Adjust.
* pt.c (tsubst_copy_and_build) <COMPONENT_REF case>: Don't search
again for a FIELD_DECL.
* semantics.c (finish_non_static_data_member): Add object
parameter. Always save the DECL in the COMPONENT_REF.
* call.c (resolve_scoped_fn_name): Adjust.
testsuite:
* g++.dg/parse/non-dependent2.C: New test.
From-SVN: r69564
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3d704eb..812ef6d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1218,11 +1218,11 @@ finish_parenthesized_expr (tree expr) preceded by `.' or `->'. */ tree -finish_non_static_data_member (tree decl, tree qualifying_scope) +finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) { my_friendly_assert (TREE_CODE (decl) == FIELD_DECL, 20020909); - if (current_class_ptr == NULL_TREE) + if (!object) { if (current_function_decl && DECL_STATIC_FUNCTION_P (current_function_decl)) @@ -1236,27 +1236,42 @@ finish_non_static_data_member (tree decl, tree qualifying_scope) } TREE_USED (current_class_ptr) = 1; if (processing_template_decl) - return build_min (COMPONENT_REF, TREE_TYPE (decl), - current_class_ref, DECL_NAME (decl)); - else { - tree access_type = current_class_type; - tree object = current_class_ref; + tree type = TREE_TYPE (decl); - while (access_type - && !DERIVED_FROM_P (context_for_name_lookup (decl), access_type)) + if (TREE_CODE (type) == REFERENCE_TYPE) + type = TREE_TYPE (type); + else + { + /* Set the cv qualifiers */ + int quals = cp_type_quals (TREE_TYPE (current_class_ref)); + + if (DECL_MUTABLE_P (decl)) + quals &= ~TYPE_QUAL_CONST; + + quals |= cp_type_quals (TREE_TYPE (decl)); + type = cp_build_qualified_type (type, quals); + } + + return build_min (COMPONENT_REF, type, object, decl); + } + else + { + tree access_type = TREE_TYPE (object); + tree lookup_context = context_for_name_lookup (decl); + + while (!DERIVED_FROM_P (lookup_context, access_type)) { access_type = TYPE_CONTEXT (access_type); while (access_type && DECL_P (access_type)) access_type = DECL_CONTEXT (access_type); - } - if (!access_type) - { - cp_error_at ("object missing in reference to `%D'", - decl); - error ("from this location"); - return error_mark_node; + if (!access_type) + { + cp_error_at ("object missing in reference to `%D'", decl); + error ("from this location"); + return error_mark_node; + } } perform_or_defer_access_check (TYPE_BINFO (access_type), decl); @@ -1357,7 +1372,8 @@ finish_qualified_id_expr (tree qualifying_class, tree expr, bool done, } if (TREE_CODE (expr) == FIELD_DECL) - expr = finish_non_static_data_member (expr, qualifying_class); + expr = finish_non_static_data_member (expr, current_class_ref, + qualifying_class); else if (BASELINK_P (expr) && !processing_template_decl) { tree fn; |