cp-tree.h (hack_identifier): Remove.
authorNathan Sidwell <nathan@codesourcery.com>
Mon, 21 Jul 2003 08:28:33 +0000 (08:28 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 21 Jul 2003 08:28:33 +0000 (08:28 +0000)
cp:
* cp-tree.h (hack_identifier): Remove.
* method.c (hack_identifier): Remove.
* semantics.c (finish_id_expression): Expand hack_identifier
here. Simplify.

From-SVN: r69625

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/method.c
gcc/cp/semantics.c

index ef5694f..d13909b 100644 (file)
@@ -1,3 +1,10 @@
+2003-07-21  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * cp-tree.h (hack_identifier): Remove.
+       * method.c (hack_identifier): Remove.
+       * semantics.c (finish_id_expression): Expand hack_identifier
+       here. Simplify.
+
 2003-07-19  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * call.c class.c decl.c decl2.c g++spec.c lex.c parser.c pt.c rtti.c
@@ -5,6 +12,13 @@
 
 2003-07-18  Nathan Sidwell  <nathan@codesourcery.com>
 
+       * cp-tree.h (hack_identifier): Remove.
+       * method.c (hack_identifier): Remove.
+       * semantics.c (finish_id_expression): Expand hack_identifier
+       here. Simplify.
+
+2003-07-18  Nathan Sidwell  <nathan@codesourcery.com>
+
        * 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
index 4f2a143..29a9f29 100644 (file)
@@ -3923,7 +3923,6 @@ extern void cxx_finish (void);
 /* in method.c */
 extern void init_method        (void);
 extern void set_mangled_name_for_decl (tree);
-extern tree hack_identifier (tree, tree);
 extern tree make_thunk (tree, bool, tree, tree);
 extern void finish_thunk (tree);
 extern void use_thunk (tree, bool);
index fdc026b..35319de 100644 (file)
@@ -88,119 +88,6 @@ set_mangled_name_for_decl (tree decl)
 }
 
 \f
-/* This function takes an identifier, ID, and attempts to figure out what
-   it means. There are a number of possible scenarios, presented in increasing
-   order of hair:
-
-   1) not in a class's scope
-   2) in class's scope, member name of the class's method
-   3) in class's scope, but not a member name of the class
-   4) in class's scope, member name of a class's variable
-
-   NAME is $1 from the bison rule. It is an IDENTIFIER_NODE.
-   VALUE is $$ from the bison rule. It is the value returned by lookup_name ($1)
-
-   As a last ditch, try to look up the name as a label and return that
-   address.
-
-   Values which are declared as being of REFERENCE_TYPE are
-   automatically dereferenced here (as a hack to make the
-   compiler faster).  */
-
-tree
-hack_identifier (tree value, tree name)
-{
-  tree type;
-
-  if (value == error_mark_node)
-    return error_mark_node;
-
-  type = TREE_TYPE (value);
-  if (TREE_CODE (value) == FIELD_DECL)
-    value = finish_non_static_data_member (value, current_class_ref,
-                                          /*qualifying_scope=*/NULL_TREE);
-  else if ((TREE_CODE (value) == FUNCTION_DECL
-           && DECL_FUNCTION_MEMBER_P (value))
-          || (TREE_CODE (value) == OVERLOAD
-              && DECL_FUNCTION_MEMBER_P (OVL_CURRENT (value))))
-    {
-      tree decl;
-
-      if (TREE_CODE (value) == OVERLOAD)
-       value = OVL_CURRENT (value);
-
-      decl = maybe_dummy_object (DECL_CONTEXT (value), 0);
-      value = finish_class_member_access_expr (decl, name);
-    }
-  else if (really_overloaded_fn (value))
-    ;
-  else if (TREE_CODE (value) == OVERLOAD)
-    /* not really overloaded function */
-    mark_used (OVL_FUNCTION (value));
-  else if (TREE_CODE (value) == TREE_LIST)
-    {
-      /* Ambiguous reference to base members, possibly other cases?.  */
-      tree t = value;
-      while (t && TREE_CODE (t) == TREE_LIST)
-       {
-         mark_used (TREE_VALUE (t));
-         t = TREE_CHAIN (t);
-       }
-    }
-  else if (TREE_CODE (value) == NAMESPACE_DECL)
-    {
-      error ("use of namespace `%D' as expression", value);
-      return error_mark_node;
-    }
-  else if (DECL_CLASS_TEMPLATE_P (value))
-    {
-      error ("use of class template `%T' as expression", value);
-      return error_mark_node;
-    }
-  else
-    mark_used (value);
-
-  if (TREE_CODE (value) == VAR_DECL || TREE_CODE (value) == PARM_DECL
-      || TREE_CODE (value) == RESULT_DECL)
-    {
-      tree context = decl_function_context (value);
-      if (context != NULL_TREE && context != current_function_decl
-         && ! TREE_STATIC (value))
-       {
-         error ("use of %s from containing function",
-                     (TREE_CODE (value) == VAR_DECL
-                      ? "`auto' variable" : "parameter"));
-         cp_error_at ("  `%#D' declared here", value);
-         value = error_mark_node;
-       }
-    }
-
-  if (DECL_P (value) && DECL_NONLOCAL (value))
-    {
-      if (DECL_CLASS_SCOPE_P (value)
-         && DECL_CONTEXT (value) != current_class_type)
-       {
-         tree path;
-         path = currently_open_derived_class (DECL_CONTEXT (value));
-         perform_or_defer_access_check (TYPE_BINFO (path), value);
-       }
-    }
-  else if (TREE_CODE (value) == TREE_LIST 
-          && TREE_TYPE (value) == error_mark_node)
-    {
-      error ("\
-request for member `%D' is ambiguous in multiple inheritance lattice",
-               name);
-      print_candidates (value);
-      return error_mark_node;
-    }
-
-  if (! processing_template_decl)
-    value = convert_from_reference (value);
-  return value;
-}
-
-\f
 /* Return a this or result adjusting thunk to FUNCTION.  THIS_ADJUSTING
    indicates whether it is a this or result adjusting thunk.
    FIXED_OFFSET and VIRTUAL_OFFSET indicate how to do the adjustment
index a34cc46..c490ab8 100644 (file)
@@ -1248,11 +1248,11 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope)
          
          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
@@ -2522,11 +2522,80 @@ finish_id_expression (tree id_expression,
          else if (TYPE_P (scope))
            decl = build (SCOPE_REF, TREE_TYPE (decl), scope, decl);
        }
-      else
-       /* Transform references to non-static data members into
-          COMPONENT_REFs.  */
-       decl = hack_identifier (decl, id_expression);
+      else if (TREE_CODE (decl) == NAMESPACE_DECL)
+       {
+         error ("use of namespace `%D' as expression", decl);
+         return error_mark_node;
+       }
+      else if (DECL_CLASS_TEMPLATE_P (decl))
+       {
+         error ("use of class template `%T' as expression", decl);
+         return error_mark_node;
+       }
+      else if (TREE_CODE (decl) == TREE_LIST)
+       {
+         /* Ambiguous reference to base members.  */
+         error ("request for member `%D' is ambiguous in "
+                "multiple inheritance lattice", id_expression);
+         print_candidates (decl);
+         return error_mark_node;
+       }
+      else if (TREE_CODE (decl) == FIELD_DECL)
+       decl = finish_non_static_data_member (decl, current_class_ref,
+                                             /*qualifying_scope=*/NULL_TREE);
+      else if (is_overloaded_fn (decl))
+       {
+         tree first_fn = OVL_CURRENT (decl);
 
+         if (TREE_CODE (first_fn) == TEMPLATE_DECL)
+           first_fn = DECL_TEMPLATE_RESULT (first_fn);
+         
+         if (TREE_CODE (first_fn) == FUNCTION_DECL
+             && DECL_FUNCTION_MEMBER_P (first_fn))
+           {
+             /* A set of member functions.  */
+             decl = maybe_dummy_object (DECL_CONTEXT (first_fn), 0);
+             return finish_class_member_access_expr (decl, id_expression);
+           }
+         else if (!really_overloaded_fn (decl))
+           /* not really overloaded function */
+           mark_used (first_fn);
+       }
+      else
+       {
+         if (TREE_CODE (decl) == VAR_DECL
+             || TREE_CODE (decl) == PARM_DECL
+             || TREE_CODE (decl) == RESULT_DECL)
+           {
+             tree context = decl_function_context (decl);
+             
+             if (context != NULL_TREE && context != current_function_decl
+                 && ! TREE_STATIC (decl))
+               {
+                 error ("use of %s from containing function",
+                        (TREE_CODE (decl) == VAR_DECL
+                         ? "`auto' variable" : "parameter"));
+                 cp_error_at ("  `%#D' declared here", decl);
+                 return error_mark_node;
+               }
+           }
+         
+         if (DECL_P (decl) && DECL_NONLOCAL (decl)
+             && DECL_CLASS_SCOPE_P (decl)
+             && DECL_CONTEXT (decl) != current_class_type)
+           {
+             tree path;
+             
+             path = currently_open_derived_class (DECL_CONTEXT (decl));
+             perform_or_defer_access_check (TYPE_BINFO (path), decl);
+           }
+         
+         mark_used (decl);
+         
+         if (! processing_template_decl)
+           decl = convert_from_reference (decl);
+       }
+      
       /* Resolve references to variables of anonymous unions
         into COMPONENT_REFs.  */
       if (TREE_CODE (decl) == ALIAS_DECL)