OSDN Git Service

* config/vax/vax.h (target_flags, MASK_UNIX_ASM, MASK_VAXC_ALIGNMENT)
[pf3gnuchains/gcc-fork.git] / gcc / ada / misc.c
index 37e6f17..39feb1c 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                           C Implementation File                          *
  *                                                                          *
- *          Copyright (C) 1992-2004 Free Software Foundation, Inc.          *
+ *          Copyright (C) 1992-2005, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -100,8 +100,10 @@ static int gnat_eh_type_covers             (tree, tree);
 static void gnat_parse_file            (int);
 static rtx gnat_expand_expr            (tree, rtx, enum machine_mode, int,
                                         rtx *);
+static void gnat_expand_body           (tree);
 static void internal_error_function    (const char *, va_list *);
 static void gnat_adjust_rli            (record_layout_info);
+static tree gnat_type_max_size         (tree);
 
 /* Definitions for our language-specific hooks.  */
 
@@ -115,50 +117,47 @@ static void gnat_adjust_rli               (record_layout_info);
 #define LANG_HOOKS_INIT_OPTIONS                gnat_init_options
 #undef  LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION       gnat_handle_option
-#undef LANG_HOOKS_POST_OPTIONS
+#undef  LANG_HOOKS_POST_OPTIONS
 #define LANG_HOOKS_POST_OPTIONS                gnat_post_options
-#undef LANG_HOOKS_PARSE_FILE
+#undef  LANG_HOOKS_PARSE_FILE
 #define LANG_HOOKS_PARSE_FILE          gnat_parse_file
-#undef LANG_HOOKS_HONOR_READONLY
-#define LANG_HOOKS_HONOR_READONLY      true
-#undef LANG_HOOKS_HASH_TYPES
+#undef  LANG_HOOKS_HASH_TYPES
 #define LANG_HOOKS_HASH_TYPES          false
-#undef LANG_HOOKS_GETDECLS
+#undef  LANG_HOOKS_GETDECLS
 #define LANG_HOOKS_GETDECLS            lhd_return_null_tree_v
-#undef LANG_HOOKS_PUSHDECL
+#undef  LANG_HOOKS_PUSHDECL
 #define LANG_HOOKS_PUSHDECL            lhd_return_tree
-#undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
+#undef  LANG_HOOKS_FINISH_INCOMPLETE_DECL
 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL gnat_finish_incomplete_decl
-#undef LANG_HOOKS_GET_ALIAS_SET
+#undef LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS
+#define LANG_HOOKS_REDUCE_BIT_FIELD_OPERATIONS true
+#undef  LANG_HOOKS_GET_ALIAS_SET
 #define LANG_HOOKS_GET_ALIAS_SET       gnat_get_alias_set
-#undef LANG_HOOKS_EXPAND_EXPR
+#undef  LANG_HOOKS_EXPAND_EXPR
 #define LANG_HOOKS_EXPAND_EXPR         gnat_expand_expr
-#undef LANG_HOOKS_MARK_ADDRESSABLE
+#undef  LANG_HOOKS_MARK_ADDRESSABLE
 #define LANG_HOOKS_MARK_ADDRESSABLE    gnat_mark_addressable
-#undef LANG_HOOKS_TRUTHVALUE_CONVERSION
-#define LANG_HOOKS_TRUTHVALUE_CONVERSION gnat_truthvalue_conversion
-#undef LANG_HOOKS_PRINT_DECL
+#undef  LANG_HOOKS_PRINT_DECL
 #define LANG_HOOKS_PRINT_DECL          gnat_print_decl
-#undef LANG_HOOKS_PRINT_TYPE
+#undef  LANG_HOOKS_PRINT_TYPE
 #define LANG_HOOKS_PRINT_TYPE          gnat_print_type
-#undef LANG_HOOKS_DECL_PRINTABLE_NAME
+#undef  LANG_HOOKS_TYPE_MAX_SIZE
+#define LANG_HOOKS_TYPE_MAX_SIZE       gnat_type_max_size
+#undef  LANG_HOOKS_DECL_PRINTABLE_NAME
 #define LANG_HOOKS_DECL_PRINTABLE_NAME gnat_printable_name
-#undef LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
+#undef  LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION
 #define LANG_HOOKS_CALLGRAPH_EXPAND_FUNCTION gnat_expand_body
-#undef LANG_HOOKS_RTL_EXPAND_STMT
-#define LANG_HOOKS_RTL_EXPAND_STMT gnat_expand_stmt
-#undef LANG_HOOKS_GIMPLIFY_EXPR
-#define LANG_HOOKS_GIMPLIFY_EXPR gnat_gimplify_expr
-
-#undef LANG_HOOKS_TYPE_FOR_MODE
+#undef  LANG_HOOKS_GIMPLIFY_EXPR
+#define LANG_HOOKS_GIMPLIFY_EXPR       gnat_gimplify_expr
+#undef  LANG_HOOKS_TYPE_FOR_MODE
 #define LANG_HOOKS_TYPE_FOR_MODE       gnat_type_for_mode
-#undef LANG_HOOKS_TYPE_FOR_SIZE
+#undef  LANG_HOOKS_TYPE_FOR_SIZE
 #define LANG_HOOKS_TYPE_FOR_SIZE       gnat_type_for_size
-#undef LANG_HOOKS_SIGNED_TYPE
+#undef  LANG_HOOKS_SIGNED_TYPE
 #define LANG_HOOKS_SIGNED_TYPE         gnat_signed_type
-#undef LANG_HOOKS_UNSIGNED_TYPE
+#undef  LANG_HOOKS_UNSIGNED_TYPE
 #define LANG_HOOKS_UNSIGNED_TYPE       gnat_unsigned_type
-#undef LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
+#undef  LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE
 #define LANG_HOOKS_SIGNED_OR_UNSIGNED_TYPE gnat_signed_or_unsigned_type
 
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
@@ -171,9 +170,9 @@ const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
 
-const char tree_code_type[] = {
+const enum tree_code_class tree_code_type[] = {
 #include "tree.def"
-  'x',
+  tcc_exceptional,
 #include "ada-tree.def"
 };
 #undef DEFTREECODE
@@ -216,17 +215,26 @@ extern char **gnat_argv;
 
 \f
 /* Declare functions we use as part of startup.  */
-extern void __gnat_initialize  (void);
-extern void adainit            (void);
-extern void _ada_gnat1drv      (void);
+extern void __gnat_initialize           (void *);
+extern void __gnat_install_SEH_handler  (void *);
+extern void adainit                    (void);
+extern void _ada_gnat1drv              (void);
 
 /* The parser for the language.  For us, we process the GNAT tree.  */
 
 static void
 gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
 {
+  int seh[2];
+
   /* call the target specific initializations */
-  __gnat_initialize();
+  __gnat_initialize (NULL);
+
+  /* ??? call the SEH initialization routine, this is to workaround a
+  bootstrap path problem. The call below should be removed at some point and
+  the seh pointer passed to __gnat_initialize() above.  */
+
+  __gnat_install_SEH_handler((void *)seh);
 
   /* Call the front-end elaboration procedures */
   adainit ();
@@ -249,7 +257,6 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED)
   const struct cl_option *option = &cl_options[scode];
   enum opt_code code = (enum opt_code) scode;
   char *q;
-  unsigned int i;
 
   if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
     {
@@ -288,13 +295,13 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED)
       gnat_argc++;
       break;
 
-    case OPT_fRTS:
+    case OPT_fRTS_:
       gnat_argv[gnat_argc] = xstrdup ("-fRTS");
       gnat_argc++;
       break;
 
     case OPT_gant:
-      warning ("`-gnat' misspelled as `-gant'");
+      warning ("%<-gnat%> misspelled as %<-gant%>");
 
       /* ... fall through ... */
 
@@ -304,17 +311,13 @@ gnat_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED)
       gnat_argv[gnat_argc][0] = '-';
       strcpy (gnat_argv[gnat_argc] + 1, arg);
       gnat_argc++;
+      break;
 
-      if (arg[0] == 'O')
-       for (i = 1; i < save_argc - 1; i++)
-         if (!strncmp (save_argv[i], "-gnatO", 6))
-           if (save_argv[++i][0] != '-')
-             {
-               /* Preserve output filename as GCC doesn't save it for GNAT. */
-               gnat_argv[gnat_argc] = xstrdup (save_argv[i]);
-               gnat_argc++;
-               break;
-             }
+    case OPT_gnatO:
+      gnat_argv[gnat_argc] = xstrdup ("-O");
+      gnat_argc++;
+      gnat_argv[gnat_argc] = xstrdup (arg);
+      gnat_argc++;
       break;
     }
 
@@ -350,10 +353,9 @@ gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
   if (!flag_no_inline)
     flag_no_inline = 1;
   if (flag_inline_functions)
-    {
-      flag_inline_trees = 2;
-      flag_inline_functions = 0;
-    }
+    flag_inline_trees = 2;
+  
+  flag_tree_salias = 0;
 
   return false;
 }
@@ -371,7 +373,7 @@ internal_error_function (const char *msgid, va_list *ap)
   vsprintf (buffer, msgid, *ap);
 
   /* Go up to the first newline.  */
-  for (p = buffer; *p != 0; p++)
+  for (p = buffer; *p; p++)
     if (*p == '\n')
       {
        *p = '\0';
@@ -421,7 +423,7 @@ gnat_init (void)
 static void
 gnat_finish_incomplete_decl (tree dont_care ATTRIBUTE_UNUSED)
 {
-  gigi_abort (202);
+  abort ();
 }
 \f
 /* Compute the alignment of the largest mode that can be used for copying
@@ -497,7 +499,12 @@ gnat_print_decl (FILE *file, tree node, int indent)
       break;
 
     case FIELD_DECL:
-      print_node (file, "original field", DECL_ORIGINAL_FIELD (node),
+      print_node (file, "original_field", DECL_ORIGINAL_FIELD (node),
+                 indent + 4);
+      break;
+
+    case VAR_DECL:
+      print_node (file, "renamed_object", DECL_RENAMED_OBJECT (node),
                  indent + 4);
       break;
 
@@ -516,7 +523,7 @@ gnat_print_type (FILE *file, tree node, int indent)
       break;
 
     case ENUMERAL_TYPE:
-      print_node (file, "RM size", TYPE_RM_SIZE_ENUM (node), indent + 4);
+      print_node (file, "RM size", TYPE_RM_SIZE_NUM (node), indent + 4);
       break;
 
     case INTEGER_TYPE:
@@ -530,7 +537,7 @@ gnat_print_type (FILE *file, tree node, int indent)
       else
        print_node (file, "index type", TYPE_INDEX_TYPE (node), indent + 4);
 
-      print_node (file, "RM size", TYPE_RM_SIZE_INT (node), indent + 4);
+      print_node (file, "RM size", TYPE_RM_SIZE_NUM (node), indent + 4);
       break;
 
     case ARRAY_TYPE:
@@ -612,12 +619,23 @@ gnat_expand_expr (tree exp, rtx target, enum machine_mode tmode,
       /* ... fall through ... */
 
     default:
-      gigi_abort (201);
+      abort ();
     }
 
   return expand_expr_real (new, target, tmode, modifier, alt_rtl);
 }
 
+/* Generate the RTL for the body of GNU_DECL.  */
+
+static void
+gnat_expand_body (tree gnu_decl)
+{
+  if (!DECL_INITIAL (gnu_decl) || DECL_INITIAL (gnu_decl) == error_mark_node)
+    return;
+
+  tree_rest_of_compilation (gnu_decl);
+}
+
 /* Adjusts the RLI used to layout a record after all the fields have been
    added.  We only handle the packed case and cause it to use the alignment
    that will pad the record at the end.  */
@@ -691,10 +709,19 @@ gnat_get_alias_set (tree type)
   return -1;
 }
 
+/* GNU_TYPE is a type.  Return its maxium size in bytes, if known.  */
+
+static tree
+gnat_type_max_size (gnu_type)
+     tree gnu_type;
+{
+  return max_size (TYPE_SIZE_UNIT (gnu_type), true);
+}
+
 /* GNU_TYPE is a type. Determine if it should be passed by reference by
    default.  */
 
-int
+bool
 default_pass_by_ref (tree gnu_type)
 {
   /* We pass aggregates by reference if they are sufficiently large.  The
@@ -709,9 +736,9 @@ default_pass_by_ref (tree gnu_type)
 
   if (targetm.calls.return_in_memory (gnu_type, NULL_TREE))
     return true;
-  
+
   if (AGGREGATE_TYPE_P (gnu_type)
-      && (! host_integerp (TYPE_SIZE (gnu_type), 1)
+      && (!host_integerp (TYPE_SIZE (gnu_type), 1)
          || 0 < compare_tree_int (TYPE_SIZE (gnu_type),
                                   8 * TYPE_ALIGN (gnu_type))))
     return true;
@@ -722,7 +749,7 @@ default_pass_by_ref (tree gnu_type)
 /* GNU_TYPE is the type of a subprogram parameter.  Determine from the type if
    it should be passed by reference. */
 
-int
+bool
 must_pass_by_ref (tree gnu_type)
 {
   /* We pass only unconstrained objects, those required by the language
@@ -732,7 +759,7 @@ must_pass_by_ref (tree gnu_type)
      not have such objects.  */
   return (TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE
          || (AGGREGATE_TYPE_P (gnu_type) && TYPE_BY_REFERENCE_P (gnu_type))
-         || (TYPE_SIZE (gnu_type) != 0
+         || (TYPE_SIZE (gnu_type)
              && TREE_CODE (TYPE_SIZE (gnu_type)) != INTEGER_CST));
 }