OSDN Git Service

* cp-tree.h (CAN_HAVE_FULL_LANG_DECL_P): New macro.
[pf3gnuchains/gcc-fork.git] / gcc / cp / lex.c
index 48a2d98..f641dc6 100644 (file)
@@ -330,8 +330,7 @@ get_time_identifier (name)
   time_identifier = get_identifier (buf);
   if (TIME_IDENTIFIER_TIME (time_identifier) == NULL_TREE)
     {
-      push_obstacks_nochange ();
-      end_temporary_allocation ();
+      push_permanent_obstack ();
       TIME_IDENTIFIER_TIME (time_identifier) = build_int_2 (0, 0);
       TIME_IDENTIFIER_FILEINFO (time_identifier) 
        = build_int_2 (0, 1);
@@ -524,6 +523,7 @@ init_parse (filename)
   set_identifier_size (sizeof (struct lang_identifier));
   decl_printable_name = lang_printable_name;
 
+  init_cplus_unsave ();
   init_cplus_expand ();
 
   bcopy (cplus_tree_code_type,
@@ -733,11 +733,6 @@ init_parse (filename)
   /* This is for ANSI C++.  */
   ridpointers[(int) RID_MUTABLE] = get_identifier ("mutable");
 
-  /* Signature handling extensions.  */
-  signature_type_node = build_int_2 (signature_type, 0);
-  TREE_TYPE (signature_type_node) = signature_type_node;
-  ridpointers[(int) RID_SIGNATURE] = signature_type_node;
-
   /* Create the built-in __null node.  Note that we can't yet call for
      type_for_size here because integer_type_node and so forth are not
      set up.  Therefore, we don't set the type of these nodes until
@@ -850,13 +845,6 @@ init_parse (filename)
       UNSET_RESERVED_WORD ("headof");
     }
 
-  if (! flag_handle_signatures || flag_no_gnu_keywords)
-    {
-      /* Easiest way to not recognize signature
-        handling extensions...  */
-      UNSET_RESERVED_WORD ("signature");
-      UNSET_RESERVED_WORD ("sigof");
-    }
   if (flag_no_asm || flag_no_gnu_keywords)
     UNSET_RESERVED_WORD ("typeof");
   if (! flag_operator_names)
@@ -941,8 +929,6 @@ yyprint (file, yychar, yylval)
        fprintf (file, " `union'");
       else if (yylval.ttype == enum_type_node)
        fprintf (file, " `enum'");
-      else if (yylval.ttype == signature_type_node)
-       fprintf (file, " `signature'");
       else
        my_friendly_abort (80);
       break;
@@ -3091,39 +3077,14 @@ do_identifier (token, parsing, args)
   else
     id = lastiddecl;
 
-  /* Scope class declarations before global
-     declarations.  */
-  if ((!id || is_global (id))
-      && current_class_type != 0
-      && TYPE_SIZE (current_class_type) == 0)
-    {
-      /* Could be from one of the base classes.  */
-      tree field = lookup_field (current_class_type, token, 1, 0);
-      if (field == 0)
-       ;
-      else if (field == error_mark_node)
-       /* We have already generated the error message.
-          But we still want to return this value.  */
-       id = lookup_field (current_class_type, token, 0, 0);
-      else if (TREE_CODE (field) == VAR_DECL
-              || TREE_CODE (field) == CONST_DECL
-              || TREE_CODE (field) == TEMPLATE_DECL)
-       id = field;
-      else if (TREE_CODE (field) != FIELD_DECL)
-       my_friendly_abort (61);
-      else
-       {
-         cp_error ("invalid use of member `%D'", field);
-         id = error_mark_node;
-         return id;
-       }
-    }
-
   /* Do Koenig lookup if appropriate (inside templates we build lookup
-     expressions instead).  */
+     expressions instead).
+
+     [basic.lookup.koenig]: If the ordinary unqualified lookup of the name
+     finds the declaration of a class member function, the associated
+     namespaces and classes are not considered.  */
+
   if (args && !current_template_parms && (!id || is_global (id)))
-    /* If we have arguments and we only found global names, do Koenig
-       lookup. */
     id = lookup_arg_dependent (token, id, args);
 
   /* Remember that this name has been used in the class definition, as per
@@ -4757,8 +4718,8 @@ extern int tree_node_sizes[];
 #endif
 
 /* Place to save freed lang_decls which were allocated on the
-   permanent_obstack.  @@ Not currently used.  */
-tree free_lang_decl_chain;
+   permanent_obstack.  */
+struct lang_decl *free_lang_decl_chain;
 
 tree
 build_lang_decl (code, name, type)
@@ -4779,8 +4740,9 @@ retrofit_lang_decl (t)
      tree t;
 {
   struct obstack *obstack = current_obstack;
-  register int i = sizeof (struct lang_decl) / sizeof (int);
-  register int *pi;
+  struct lang_decl *ld;
+
+  my_friendly_assert (CAN_HAVE_FULL_LANG_DECL_P (t), 19990816);
 
   if (! TREE_PERMANENT (t))
     obstack = saveable_obstack;
@@ -4790,20 +4752,18 @@ retrofit_lang_decl (t)
 
   if (free_lang_decl_chain && obstack == &permanent_obstack)
     {
-      pi = (int *)free_lang_decl_chain;
-      free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
+      ld = free_lang_decl_chain;
+      free_lang_decl_chain = free_lang_decl_chain->u.next;
     }
   else
-    pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
+    ld = ((struct lang_decl *) 
+         obstack_alloc (obstack, sizeof (struct lang_decl)));
 
-  while (i > 0)
-    pi[--i] = 0;
+  bzero (ld, sizeof (struct lang_decl));
 
-  DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
-  LANG_DECL_PERMANENT ((struct lang_decl *) pi)
-    = obstack == &permanent_obstack;
-  my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi)
-         == TREE_PERMANENT  (t), 234);
+  DECL_LANG_SPECIFIC (t) = ld;
+  LANG_DECL_PERMANENT (ld) = obstack == &permanent_obstack;
+  my_friendly_assert (LANG_DECL_PERMANENT (ld) == TREE_PERMANENT  (t), 234);
   DECL_MAIN_VARIANT (t) = t;
   if (current_lang_name == lang_name_cplusplus)
     DECL_LANGUAGE (t) = lang_cplusplus;
@@ -4813,21 +4773,15 @@ retrofit_lang_decl (t)
     DECL_LANGUAGE (t) = lang_java;
   else my_friendly_abort (64);
 
-#if 0 /* not yet, should get fixed properly later */
-  if (code == TYPE_DECL)
-    {
-      tree id;
-      id = get_identifier (build_overload_name (type, 1, 1));
-      DECL_ASSEMBLER_NAME (t) = id;
-    }
-
-#endif
 #ifdef GATHER_STATISTICS
   tree_node_counts[(int)lang_decl] += 1;
   tree_node_sizes[(int)lang_decl] += sizeof (struct lang_decl);
 #endif
 }
 
+/* Like build_decl, except that a new lang_decl_flags structure is
+   placed in DECL_LANG_SPECIFIC.  */
+
 tree
 build_lang_field_decl (code, name, type)
      enum tree_code code;
@@ -4837,28 +4791,18 @@ build_lang_field_decl (code, name, type)
   extern struct obstack *current_obstack, *saveable_obstack;
   register tree t = build_decl (code, name, type);
   struct obstack *obstack = current_obstack;
-  register int i = sizeof (struct lang_decl_flags) / sizeof (int);
-  register int *pi;
-#if 0 /* not yet, should get fixed properly later */
-
-  if (code == TYPE_DECL)
-    {
-      tree id;
-      id = get_identifier (build_overload_name (type, 1, 1));
-      DECL_ASSEMBLER_NAME (t) = id;
-    }
-#endif
 
   if (! TREE_PERMANENT (t))
     obstack = saveable_obstack;
   else
     my_friendly_assert (obstack == &permanent_obstack, 235);
 
-  pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
-  while (i > 0)
-    pi[--i] = 0;
+  my_friendly_assert (!CAN_HAVE_FULL_LANG_DECL_P (t), 19990816);
 
-  DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
+  DECL_LANG_SPECIFIC (t) 
+    = ((struct lang_decl *) 
+       obstack_alloc (obstack, sizeof (struct lang_decl_flags)));
+  bzero (DECL_LANG_SPECIFIC (t), sizeof (struct lang_decl_flags));
   return t;
 }
 
@@ -4872,7 +4816,7 @@ copy_lang_decl (node)
   if (! DECL_LANG_SPECIFIC (node))
     return;
 
-  if (TREE_CODE (node) == FIELD_DECL)
+  if (!CAN_HAVE_FULL_LANG_DECL_P (node))
     size = sizeof (struct lang_decl_flags);
   else
     size = sizeof (struct lang_decl);