89th Cygnus<->FSF quick merge
[platform/upstream/gcc.git] / gcc / cp / lex.c
index 66e0046..4888981 100644 (file)
@@ -131,35 +131,35 @@ extern int *token_count;
 \f
 /* Return something to represent absolute declarators containing a *.
    TARGET is the absolute declarator that the * contains.
-   TYPE_QUALS is a list of modifiers such as const or volatile
+   CV_QUALIFIERS is a list of modifiers such as const or volatile
    to apply to the pointer type, represented as identifiers.
 
    We return an INDIRECT_REF whose "contents" are TARGET
    and whose type is the modifier list.  */
 
 tree
-make_pointer_declarator (type_quals, target)
-     tree type_quals, target;
+make_pointer_declarator (cv_qualifiers, target)
+     tree cv_qualifiers, target;
 {
   if (target && TREE_CODE (target) == IDENTIFIER_NODE
       && ANON_AGGRNAME_P (target))
     error ("type name expected before `*'");
   target = build_parse_node (INDIRECT_REF, target);
-  TREE_TYPE (target) = type_quals;
+  TREE_TYPE (target) = cv_qualifiers;
   return target;
 }
 
 /* Return something to represent absolute declarators containing a &.
    TARGET is the absolute declarator that the & contains.
-   TYPE_QUALS is a list of modifiers such as const or volatile
+   CV_QUALIFIERS is a list of modifiers such as const or volatile
    to apply to the reference type, represented as identifiers.
 
    We return an ADDR_EXPR whose "contents" are TARGET
    and whose type is the modifier list.  */
    
 tree
-make_reference_declarator (type_quals, target)
-     tree type_quals, target;
+make_reference_declarator (cv_qualifiers, target)
+     tree cv_qualifiers, target;
 {
   if (target)
     {
@@ -177,9 +177,26 @@ make_reference_declarator (type_quals, target)
          error ("type name expected before `&'");
     }
   target = build_parse_node (ADDR_EXPR, target);
-  TREE_TYPE (target) = type_quals;
+  TREE_TYPE (target) = cv_qualifiers;
   return target;
 }
+
+tree
+make_call_declarator (target, parms, cv_qualifiers, exception_specification)
+     tree target, parms, cv_qualifiers, exception_specification;
+{
+  target = build_parse_node (CALL_EXPR, target, parms, cv_qualifiers);
+  TREE_TYPE (target) = exception_specification;
+  return target;
+}
+
+void
+set_quals_and_spec (call_declarator, cv_qualifiers, exception_specification)
+     tree call_declarator, cv_qualifiers, exception_specification;
+{
+  TREE_OPERAND (call_declarator, 2) = cv_qualifiers;
+  TREE_TYPE (call_declarator) = exception_specification;
+}
 \f
 /* Build names and nodes for overloaded operators.  */
 
@@ -673,8 +690,8 @@ init_lex ()
   TREE_TYPE (signature_type_node) = signature_type_node;
   ridpointers[(int) RID_SIGNATURE] = signature_type_node;
 
-  null_pointer_node = build_int_2 (0, 0);
-  ridpointers[RID_NULL] = null_pointer_node;
+  null_node = build_int_2 (0, 0);
+  ridpointers[RID_NULL] = null_node;
 
   opname_tab[(int) COMPONENT_REF] = "->";
   opname_tab[(int) MEMBER_REF] = "->*";
@@ -804,8 +821,6 @@ init_lex ()
       UNSET_RESERVED_WORD ("xor");
       UNSET_RESERVED_WORD ("xor_eq");
     }
-  if (! flag_traditional)
-    UNSET_RESERVED_WORD ("overload");
 
   token_count = init_parse ();
   interface_unknown = 1;
@@ -1681,17 +1696,19 @@ cons_up_default_function (type, full_name, kind)
   TREE_PARMLIST (args) = 1;
 
   {
-    tree declarator = build_parse_node (CALL_EXPR, name, args, NULL_TREE);
+    tree declarator = make_call_declarator (name, args, NULL_TREE, NULL_TREE);
     if (retref)
       declarator = build_parse_node (ADDR_EXPR, declarator);
     
-    fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE,
-                   NULL_TREE, NULL_TREE);
+    fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
   }
   
   if (fn == void_type_node)
     return fn;
 
+  if (kind > 2)
+    SET_DECL_ARTIFICIAL (TREE_CHAIN (DECL_ARGUMENTS (fn)));
+
 #if 0
   if (processing_template_defn)
     {
@@ -2320,12 +2337,6 @@ readescape (ignore_ptr)
   switch (c)
     {
     case 'x':
-      if (warn_traditional)
-       warning ("the meaning of `\\x' varies with -traditional");
-
-      if (flag_traditional)
-       return c;
-
       code = 0;
       count = 0;
       nonnull = 0;
@@ -2400,11 +2411,6 @@ readescape (ignore_ptr)
       return TARGET_BS;
 
     case 'a':
-      if (warn_traditional)
-       warning ("the meaning of `\\a' varies with -traditional");
-
-      if (flag_traditional)
-       return c;
       return TARGET_BELL;
 
     case 'v':
@@ -2441,20 +2447,6 @@ readescape (ignore_ptr)
    Value is 0 if we treat this name in a default fashion.  */
 int looking_for_typename = 0;
 
-#if 0
-/* NO LONGER USED: Value is -1 if we must not see a type name.  */
-void
-dont_see_typename ()
-{
-  looking_for_typename = -1;
-  if (yychar == TYPENAME || yychar == PTYPENAME)
-    {
-      yychar = IDENTIFIER;
-      lastiddecl = 0;
-    }
-}
-#endif
-
 #ifdef __GNUC__
 extern __inline int identifier_type ();
 __inline
@@ -2649,7 +2641,7 @@ do_identifier (token, parsing)
            cp_error ("enum `%D' is private", id);
          /* protected is OK, since it's an enum of `this'.  */
        }
-      if (! current_template_parms
+      if (! processing_template_decl
          || (DECL_INITIAL (id)
              && TREE_CODE (DECL_INITIAL (id)) == TEMPLATE_CONST_PARM))
        id = DECL_INITIAL (id);
@@ -2686,7 +2678,7 @@ do_scoped_id (token, parsing)
     yychar = yylex ();
   if (! id)
     {
-      if (current_template_parms)
+      if (processing_template_decl)
        {
          id = build_min_nt (LOOKUP_EXPR, token, NULL_TREE);
          LOOKUP_EXPR_GLOBAL (id) = 1;
@@ -2711,7 +2703,7 @@ do_scoped_id (token, parsing)
       else if (TREE_CODE (id) != TREE_LIST)
        mark_used (id);
     }
-  if (TREE_CODE (id) == CONST_DECL && ! current_template_parms)
+  if (TREE_CODE (id) == CONST_DECL && ! processing_template_decl)
     {
       /* XXX CHS - should we set TREE_USED of the constant? */
       id = DECL_INITIAL (id);
@@ -2721,7 +2713,7 @@ do_scoped_id (token, parsing)
       TREE_CONSTANT (id) = 1;
     }
 
-  if (current_template_parms)
+  if (processing_template_decl)
     {
       if (is_overloaded_fn (id))
        {
@@ -3522,7 +3514,6 @@ real_yylex ()
            TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
 
            if (!spec_long && !spec_unsigned
-               && !(flag_traditional && base != 10)
                && int_fits_type_p (yylval.ttype, integer_type_node))
              {
                type = integer_type_node;
@@ -3541,12 +3532,7 @@ real_yylex ()
            else if (! spec_long_long
                     && int_fits_type_p (yylval.ttype,
                                         long_unsigned_type_node))
-             {
-               if (flag_traditional && !spec_unsigned)
-                 type = long_integer_type_node;
-               else
-                 type = long_unsigned_type_node;
-             }
+             type = long_unsigned_type_node;
 
            else if (! spec_unsigned
                     /* Verify value does not overflow into sign bit.  */
@@ -3557,12 +3543,7 @@ real_yylex ()
 
            else if (int_fits_type_p (yylval.ttype,
                                      long_long_unsigned_type_node))
-             {
-               if (flag_traditional && !spec_unsigned)
-                 type = long_long_integer_type_node;
-               else
-                 type = long_long_unsigned_type_node;
-             }
+             type = long_long_unsigned_type_node;
 
            else
              {
@@ -3662,7 +3643,7 @@ real_yylex ()
            num_chars = max_chars;
            error ("character constant too long");
          }
-       else if (num_chars != 1 && ! flag_traditional)
+       else if (num_chars != 1)
          warning ("multi-character character constant");
 
        /* If char type is signed, sign-extend the constant.  */
@@ -3791,19 +3772,19 @@ real_yylex ()
              len = p - token_buffer - 1;
            }
 #endif
-           if (current_template_parms)
+           if (processing_template_decl)
              push_obstacks (&permanent_obstack, &permanent_obstack);
            yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep);
-           if (current_template_parms)
+           if (processing_template_decl)
              pop_obstacks ();
            TREE_TYPE (yylval.ttype) = wchar_array_type_node;
          }
        else
          {
-           if (current_template_parms)
+           if (processing_template_decl)
              push_obstacks (&permanent_obstack, &permanent_obstack);
            yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
-           if (current_template_parms)
+           if (processing_template_decl)
              pop_obstacks ();
            TREE_TYPE (yylval.ttype) = char_array_type_node;
          }
@@ -4022,6 +4003,30 @@ is_rid (t)
 }
 
 #ifdef GATHER_STATISTICS
+/* The original for tree_node_kind is in the toplevel tree.c; changes there
+   need to be brought into here, unless this were actually put into a header
+   instead.  */
+/* Statistics-gathering stuff.  */
+typedef enum
+{
+  d_kind,
+  t_kind,
+  b_kind,
+  s_kind,
+  r_kind,
+  e_kind,
+  c_kind,
+  id_kind,
+  op_id_kind,
+  perm_list_kind,
+  temp_list_kind,
+  vec_kind,
+  x_kind,
+  lang_decl,
+  lang_type,
+  all_kinds
+} tree_node_kind;
+
 extern int tree_node_counts[];
 extern int tree_node_sizes[];
 #endif
@@ -4065,22 +4070,7 @@ build_lang_decl (code, name, type)
          == TREE_PERMANENT  (t), 234);
   DECL_MAIN_VARIANT (t) = t;
   if (current_lang_name == lang_name_cplusplus)
-    {
-      DECL_LANGUAGE (t) = lang_cplusplus;
-#if 0
-#ifndef NO_AUTO_OVERLOAD
-      if (code == FUNCTION_DECL && name != 0
-         && ! (IDENTIFIER_LENGTH (name) == 4
-               && IDENTIFIER_POINTER (name)[0] == 'm'
-               && strcmp (IDENTIFIER_POINTER (name), "main") == 0)
-         && ! (IDENTIFIER_LENGTH (name) > 10
-               && IDENTIFIER_POINTER (name)[0] == '_'
-               && IDENTIFIER_POINTER (name)[1] == '_'
-               && strncmp (IDENTIFIER_POINTER (name)+2, "builtin_", 8) == 0))
-       TREE_OVERLOADED (name) = 1;
-#endif
-#endif
-    }
+    DECL_LANGUAGE (t) = lang_cplusplus;
   else if (current_lang_name == lang_name_c)
     DECL_LANGUAGE (t) = lang_c;
   else my_friendly_abort (64);
@@ -4360,11 +4350,6 @@ handle_cp_pragma (pname)
          main_filename = TREE_STRING_POINTER (yylval.ttype);
        }
 
-#ifdef SUPPORTS_ONE_ONLY
-      if (SUPPORTS_ONE_ONLY > 1)
-       return 1;
-#endif
-      
       while (token != END_OF_LINE)
        {
          if (!warned_already && extra_warnings)
@@ -4375,6 +4360,7 @@ handle_cp_pragma (pname)
          token = real_yylex ();
        }
 
+#ifndef NO_LINKAGE_HEURISTICS
       write_virtuals = 3;
 
       if (impl_file_chain == 0)
@@ -4401,6 +4387,7 @@ handle_cp_pragma (pname)
       interface_unknown = 0;
       TREE_INT_CST_LOW (fileinfo) = interface_only;
       TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
+#endif /* NO_LINKAGE_HEURISTICS */
 
       return 1;
     }
@@ -4433,11 +4420,7 @@ handle_cp_pragma (pname)
          token = real_yylex ();
        }
 
-#ifdef SUPPORTS_ONE_ONLY
-      if (SUPPORTS_ONE_ONLY > 1)
-       return 1;
-#endif
-
+#ifndef NO_LINKAGE_HEURISTICS
       if (write_virtuals == 3)
        {
          struct impl_files *ifiles = impl_file_chain;
@@ -4482,6 +4465,8 @@ handle_cp_pragma (pname)
 #endif
       TREE_INT_CST_LOW (fileinfo) = interface_only;
       TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
+#endif /* NO_LINKAGE_HEURISTICS */
+
       return 1;
     }