OSDN Git Service

* config/alpha/vms.h (INCLUDE_DEFAULTS): Add /gnu/lib/gcc-lib/include.
[pf3gnuchains/gcc-fork.git] / gcc / ch / decl.c
index 8b65179..01ca9e6 100644 (file)
@@ -1,21 +1,22 @@
 /* Process declarations and variables for GNU CHILL compiler.
-   Copyright (C) 1992, 93, 1994, 1998, 1999 Free Software Foundation, Inc. 
+   Copyright (C) 1992, 1993, 1994, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc. 
    
-   This file is part of GNU CC.
-   
-   GNU CC is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
    
-   GNU CC is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
    
-   You should have received a copy of the GNU General Public License
-   along with GNU CC; see the file COPYING.  If not, write to
-   the Free Software Foundation, 59 Temple Place - Suite 330,
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
 
@@ -84,7 +85,7 @@ Boston, MA 02111-1307, USA.  */
    This must be done before we can Layout a.
    The reason this is an issue is that we do *not* have a lookup
    (or hash) table per scope (or module).  Instead we have a single
-   global table we we keep adding and removing bindings from.
+   global table we keep adding and removing bindings from.
    (This is both for speed, and because of gcc history.)
 
    Note that a SEIZE generates a declaration in the current scope,
@@ -190,6 +191,7 @@ Boston, MA 02111-1307, USA.  */
 #include "input.h"
 #include "rtl.h"
 #include "toplev.h"
+#include "diagnostic.h"
 
 #define IS_UNKNOWN_TYPE(type) (TYPE_SIZE(type)==0)
 #define BUILTIN_NESTING_LEVEL (-1)
@@ -205,12 +207,12 @@ extern struct obstack *saveable_obstack;
 extern tree signal_code;
 extern int special_UC;
 
-static tree get_next_decl             PROTO((void));
-static tree lookup_name_for_seizing   PROTO((tree));
+static tree get_next_decl             PARAMS ((void));
+static tree lookup_name_for_seizing   PARAMS ((tree));
 #if 0
-static tree lookup_name_current_level PROTO((tree));
+static tree lookup_name_current_level PARAMS ((tree));
 #endif
-static void save_decl                 PROTO((tree));
+static void save_decl                 PARAMS ((tree));
 
 extern struct obstack permanent_obstack;
 extern int in_pseudo_module;
@@ -240,21 +242,21 @@ tree chill_result_decl;
 int result_never_set;
 
 /* forward declarations */
-static void pushdecllist                     PROTO((tree, int));
-static int  init_nonvalue_struct             PROTO((tree));
-static int  init_nonvalue_array              PROTO((tree));
-static void set_nesting_level                PROTO((tree, int));
-static tree make_chill_variants              PROTO((tree, tree, tree));
-static tree fix_identifier                   PROTO((tree));
-static void proclaim_decl                    PROTO((tree, int));
-static tree maybe_acons                      PROTO((tree, tree));
-static void push_scope_decls                 PROTO((int));
-static void pop_scope_decls                  PROTO((tree, tree));
-static tree build_implied_names              PROTO((tree));
-static void bind_sub_modules                 PROTO((int));
-static void layout_array_type                PROTO((tree));
-static void do_based_decl                    PROTO((tree, tree, tree));
-static void handle_one_level                 PROTO((tree, tree));
+static void pushdecllist                     PARAMS ((tree, int));
+static int  init_nonvalue_struct             PARAMS ((tree));
+static int  init_nonvalue_array              PARAMS ((tree));
+static void set_nesting_level                PARAMS ((tree, int));
+static tree make_chill_variants              PARAMS ((tree, tree, tree));
+static tree fix_identifier                   PARAMS ((tree));
+static void proclaim_decl                    PARAMS ((tree, int));
+static tree maybe_acons                      PARAMS ((tree, tree));
+static void push_scope_decls                 PARAMS ((int));
+static void pop_scope_decls                  PARAMS ((tree, tree));
+static tree build_implied_names              PARAMS ((tree));
+static void bind_sub_modules                 PARAMS ((int));
+static void layout_array_type                PARAMS ((tree));
+static void do_based_decl                    PARAMS ((tree, tree, tree));
+static void handle_one_level                 PARAMS ((tree, tree));
 
 int current_nesting_level = BUILTIN_NESTING_LEVEL;
 int current_module_nesting_level = 0;
@@ -263,52 +265,6 @@ int current_module_nesting_level = 0;
 /* ??? not all decl nodes are given the most useful possible
    line numbers.  For example, the CONST_DECLs for enum values.  */
 
-#if 0
-/* In grokdeclarator, distinguish syntactic contexts of declarators.  */
-enum decl_context
-{ NORMAL,                      /* Ordinary declaration */
-    FUNCDEF,                   /* Function definition */
-    PARM,                      /* Declaration of parm before function body */
-    FIELD,                     /* Declaration inside struct or union */
-    BITFIELD,                  /* Likewise but with specified width */
-    TYPENAME};                 /* Typename (inside cast or sizeof)  */
-#endif
-
-#ifndef CHAR_TYPE_SIZE
-#define CHAR_TYPE_SIZE BITS_PER_UNIT
-#endif
-
-#ifndef SHORT_TYPE_SIZE
-#define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
-#endif
-
-#ifndef INT_TYPE_SIZE
-#define INT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef LONG_TYPE_SIZE
-#define LONG_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef LONG_LONG_TYPE_SIZE
-#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef WCHAR_UNSIGNED
-#define WCHAR_UNSIGNED 0
-#endif
-
-#ifndef FLOAT_TYPE_SIZE
-#define FLOAT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
 
 /* We let tm.h override the types used here, to handle trivial differences
    such as the choice of unsigned int or long unsigned int for size_t.
@@ -344,9 +300,6 @@ tree default_function_type;
 
 const char **boolean_code_name;
 
-/* A node for the integer constant -1.  */
-tree integer_minus_one_node;
-
 /* Nodes for boolean constants TRUE and FALSE. */
 tree boolean_true_node, boolean_false_node;
 
@@ -374,10 +327,6 @@ static tree current_function_parms;
 
 static int c_function_varargs;
 
-/* The FUNCTION_DECL for the function currently being compiled,
-   or 0 if between functions.  */
-tree current_function_decl;
-
 /* These are irrelevant for Chill, but are referenced from from c-typeck.c. */
 int warn_format;
 int warn_traditional;
@@ -513,14 +462,6 @@ int flag_no_builtin;
 
 int flag_no_nonansi_builtin;
 
-/* Nonzero means do some things the same way PCC does.  */
-
-int flag_traditional;
-
-/* Nonzero means to allow single precision math even if we're generally
-   being traditional. */
-int flag_allow_single_precision = 0;
-
 /* Nonzero means to treat bitfields as signed unless they say `unsigned'.  */
 
 int flag_signed_bitfields = 1;
@@ -593,7 +534,8 @@ int warn_missing_braces;
 
 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
   
-  const char chill_tree_code_type[] = {
+const char tree_code_type[] = {
+#include "tree.def"
     'x',
 #include "ch-tree.def"
   };
@@ -605,7 +547,8 @@ int warn_missing_braces;
 
 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
   
-int chill_tree_code_length[] = {
+const unsigned char tree_code_length[] = {
+#include "tree.def"
     0,
 #include "ch-tree.def"
   };
@@ -616,15 +559,14 @@ int chill_tree_code_length[] = {
    Used for printing out the tree and error messages.  */
 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
   
-const char *chill_tree_code_name[] = {
+const char *const tree_code_name[] = {
+#include "tree.def"
     "@@dummy",
 #include "ch-tree.def"
   };
 #undef DEFTREECODE
 
-/* Nonzero means `$' can be in an identifier.
-   See cccp.c for reasons why this breaks some obscure ANSI C programs.  */
-
+/* Nonzero means `$' can be in an identifier. */
 #ifndef DOLLARS_IN_IDENTIFIERS
 #define DOLLARS_IN_IDENTIFIERS 0
 #endif
@@ -670,21 +612,8 @@ c_decode_option (argc, argv)
      char **argv;
 {
   char *p = argv[0];
-  if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
-    {
-      flag_traditional = 1;
-      flag_writable_strings = 1;
-#if DOLLARS_IN_IDENTIFIERS > 0
-      dollars_in_ident = 1;
-#endif
-    }
-  else if (!strcmp (p, "-fnotraditional") || !strcmp (p, "-fno-traditional"))
-    {
-      flag_traditional = 0;
-      flag_writable_strings = 0;
-      dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 1;
-    }
-  else if (!strcmp (p, "-fsigned-char"))
+
+  if (!strcmp (p, "-fsigned-char"))
     flag_signed_char = 1;
   else if (!strcmp (p, "-funsigned-char"))
     flag_signed_char = 0;
@@ -804,7 +733,7 @@ c_decode_option (argc, argv)
        warn_uninitialized = 2;
       warn_implicit = 1;
       warn_return_type = 1;
-      warn_unused = 1;
+      set_Wunused (1);
       warn_char_subscripts = 1;
       warn_parentheses = 1;
       warn_missing_braces = 1;
@@ -1109,7 +1038,7 @@ do_decl (name, type, is_static, lifetime_bound, opt_init, opt_external)
          if (CH_TYPE_NONVALUE_P (type))
            {
              error_with_decl (decl,
-                              "no initialisation allowed for `%s'");
+                              "no initialization allowed for `%s'");
              temp = NULL_TREE;
            }
          else if (TREE_CODE (type) == REFERENCE_TYPE)
@@ -1545,7 +1474,7 @@ struct tree_pair
   tree decl;
 };
 
-static int  label_value_cmp                  PROTO((struct tree_pair *,
+static int  label_value_cmp                  PARAMS ((struct tree_pair *,
                                                    struct tree_pair *));
 
 /* Function to help qsort sort variant labels by value order.  */
@@ -1739,7 +1668,7 @@ layout_chill_variants (utype)
       int limit;
       qsort (label_value_array,
             label_index, sizeof (struct tree_pair),
-            (int (*) PROTO ((const void *, const void *))) label_value_cmp);
+            (int (*) PARAMS ((const void *, const void *))) label_value_cmp);
       limit = label_index - 1;
       for (label_index = 0; label_index < limit; label_index++)
        {
@@ -2014,9 +1943,6 @@ finish_chill_function ()
          /* Generate rtl for function exit.  */
          expand_function_end (input_filename, lineno, 0);
 
-         /* So we can tell if jump_optimize sets it to 1.  */
-         can_reach_end = 0;
-
          /* Run the optimizers and output assembler code for this function. */
          rest_of_compilation (fndecl);
        }
@@ -2334,7 +2260,7 @@ find_granted_decls ()
            }
          if (!found)
            {
-             error_with_decl (alias, "Nothing named `%s' to grant.");
+             error_with_decl (alias, "nothing named `%s' to grant");
              DECL_ABSTRACT_ORIGIN (alias) = error_mark_node;
            }
        }
@@ -2493,7 +2419,7 @@ struct path
   tree node;
 };
 
-static tree find_implied_types            PROTO((tree, struct path *, tree));
+static tree find_implied_types            PARAMS ((tree, struct path *, tree));
 \f
 /* Look for implied types (enumeral types) implied by TYPE (a decl or type).
    Add these to list.
@@ -2940,7 +2866,6 @@ poplevel (keep, reverse, functionbody)
            }
 
          BLOCK_SUBBLOCKS (block) = subblocks;
-         remember_end_note (block);
        }
 
       /* In each subblock, record that this is its superior.  */
@@ -2979,7 +2904,7 @@ poplevel (keep, reverse, functionbody)
              define_label (input_filename, lineno,
                            DECL_NAME (label));
            }
-         else if (warn_unused && !TREE_USED (label))
+         else if (warn_unused_label && !TREE_USED (label))
            warning_with_decl (label, "label `%s' defined but not used");
          IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0;
 
@@ -3074,6 +2999,9 @@ set_block (block)
      register tree block;
 {
   current_scope->this_block = block;
+  current_scope->decls = chainon (current_scope->decls, BLOCK_VARS (block));
+  current_scope->blocks = chainon (current_scope->blocks,
+                                  BLOCK_SUBBLOCKS (block));
 }
 \f
 /* Record a decl-node X as belonging to the current lexical scope.
@@ -3157,7 +3085,7 @@ pushdecl_top_level (x)
 
 tree
 define_label (filename, line, name)
-     char *filename;
+     const char *filename;
      int line;
      tree name;
 {
@@ -3401,8 +3329,6 @@ init_decl_processing ()
   tree ptr_ftype_luns_ptr_int;
   tree double_ftype_double;
 
-  extern int set_alignment;
-
   /* allow 0-255 enums to occupy only a byte */
   flag_short_enums = 1;
 
@@ -3445,9 +3371,6 @@ init_decl_processing ()
   pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_DOUBLE],
                        double_type_node));
 
-  integer_minus_one_node = build_int_2 (-1, -1);
-  TREE_TYPE (integer_minus_one_node) = integer_type_node;
-
   build_common_tree_nodes_2 (flag_short_double);
 
   pushdecl (build_decl (TYPE_DECL,
@@ -3455,6 +3378,7 @@ init_decl_processing ()
   /* We are not going to have real types in C with less than byte alignment,
      so we might as well not have any types that claim to have it.  */
   TYPE_ALIGN (void_type_node) = BITS_PER_UNIT;
+  TYPE_USER_ALIGN (void_type_node) = 0;
 
   /* This is for wide string constants.  */
   wchar_type_node = short_unsigned_type_node;
@@ -3561,18 +3485,6 @@ init_decl_processing ()
   DECL_SOURCE_LINE (temp) = 0;
   initializer_type = TREE_TYPE (temp);
 
-  memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
-         chill_tree_code_type,
-         (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-          * sizeof (char)));
-  memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
-         chill_tree_code_length,
-         (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-          * sizeof (int)));
-  memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
-         chill_tree_code_name,
-         (((int) LAST_CHILL_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-          * sizeof (char *)));
   boolean_code_name = (const char **) xcalloc (sizeof (char *),
                                               (int) LAST_CHILL_TREE_CODE);
 
@@ -4129,11 +4041,6 @@ builtin_function (name, type, function_code, class, library_name)
   tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
   DECL_EXTERNAL (decl) = 1;
   TREE_PUBLIC (decl) = 1;
-  /* If -traditional, permit redefining a builtin function any way you like.
-     (Though really, if the program redefines these functions,
-     it probably won't work right unless compiled with -fno-builtin.)  */
-  if (flag_traditional && name[0] != '_')
-    DECL_BUILT_IN_NONANSI (decl) = 1;
   if (library_name)
     DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
   make_decl_rtl (decl, NULL_PTR, 1);
@@ -4339,18 +4246,9 @@ finish_struct (t, fieldlist)
 {
   register tree x;
 
-  /* Install struct as DECL_CONTEXT of each field decl.
-     Also process specified field sizes.
-     Set DECL_FIELD_SIZE to the specified size, or 0 if none specified.
-     The specified size is found in the DECL_INITIAL.
-     Store 0 there, except for ": 0" fields (so we can find them
-     and delete them, below).  */
-
+  /* Install struct as DECL_CONTEXT of each field decl.  */
   for (x = fieldlist; x; x = TREE_CHAIN (x))
-    {
-      DECL_CONTEXT (x) = t;
-      DECL_FIELD_SIZE (x) = 0;
-    }
+    DECL_CONTEXT (x) = t;
 
   TYPE_FIELDS (t) = fieldlist;
 
@@ -4494,7 +4392,7 @@ layout_enum (enumtype)
              constant_expression_warning (value);
              if (tree_int_cst_lt (value, integer_zero_node))
                {
-                 error ("enumerator value for `%s' is less then 0",
+                 error ("enumerator value for `%s' is less than 0",
                         IDENTIFIER_POINTER (DECL_NAME (decl)));
                  value = error_mark_node;
                }
@@ -4542,7 +4440,7 @@ layout_enum (enumtype)
     }
 
   /* Fix all error_mark_nodes in enum. Increment maxnode and assign value.
-     This is neccessary to make a duplicate value check in the enum */
+     This is necessary to make a duplicate value check in the enum */
   for (pair = values; pair; pair = TREE_CHAIN (pair))
     {
       tree decl = TREE_VALUE (pair);
@@ -4609,8 +4507,11 @@ layout_enum (enumtype)
   for (pair = values; pair; pair = TREE_CHAIN (pair))
     {
       tree decl = TREE_VALUE (pair);
+
       DECL_SIZE (decl) = TYPE_SIZE (enumtype);
+      DECL_SIZE_UNIT (decl) = TYPE_SIZE_UNIT (enumtype);
       DECL_ALIGN (decl) = TYPE_ALIGN (enumtype);
+      DECL_USER_ALIGN (decl) = TYPE_USER_ALIGN (enumtype);
 
       /* Set the TREE_VALUE to the name, rather than the decl,
         since that is what the rest of the compiler expects. */
@@ -4627,6 +4528,7 @@ layout_enum (enumtype)
       TYPE_MODE (tem) = TYPE_MODE (enumtype);
       TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
       TYPE_ALIGN (tem) = TYPE_ALIGN (enumtype);
+      TYPE_USER_ALIGN (tem) = TYPE_USER_ALIGN (enumtype);
       TREE_UNSIGNED (tem) = TREE_UNSIGNED (enumtype);
     }
 
@@ -4678,7 +4580,7 @@ build_enumerator (name, value)
       if (!unnamed_value_warned)
        {
          unnamed_value_warned = 1;
-         warning ("undefined value in SET mode is obsolete and deprecated.");
+         warning ("undefined value in SET mode is obsolete and deprecated");
        }
       sprintf (buf, "__star_%d", next_dummy_enum_value++);
       name = get_identifier (buf);