]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/ada/misc.c
misc.c (gnat_expand_constant): Move declaration above definition of lang_hooks.
[gcc.git] / gcc / ada / misc.c
index a806d241ea8b6826144c6725527e5381197fd0fc..f3c9cbce2040f91ec28528a28a78da91be42a09d 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                           C Implementation File                          *
  *                                                                          *
- *                             $Revision$
+ *                             $Revision: 1.13 $
  *                                                                          *
  *          Copyright (C) 1992-2001 Free Software Foundation, Inc.          *
  *                                                                          *
@@ -52,6 +52,8 @@
 #include "output.h"
 #include "except.h"
 #include "tm_p.h"
+#include "langhooks.h"
+#include "langhooks-def.h"
 
 #include "ada.h"
 #include "types.h"
@@ -107,9 +109,39 @@ const char *gnat_tree_code_name[] = {
 };
 #undef DEFTREECODE
 
+static const char *gnat_init           PARAMS ((const char *));
+static void gnat_init_options          PARAMS ((void));
+static int gnat_decode_option          PARAMS ((int, char **));
+static HOST_WIDE_INT gnat_get_alias_set        PARAMS ((tree));
+static void gnat_print_decl            PARAMS ((FILE *, tree, int));
+static void gnat_print_type            PARAMS ((FILE *, tree, int));
+extern void gnat_init_decl_processing  PARAMS ((void));
+static tree gnat_expand_constant       PARAMS ((tree));
+
 /* Structure giving our language-specific hooks.  */
-struct lang_hooks lang_hooks = {gnat_init, 0, gnat_init_options,
-                               gnat_decode_option, 0};
+
+#undef  LANG_HOOKS_NAME
+#define LANG_HOOKS_NAME                        "GNU Ada"
+#undef  LANG_HOOKS_IDENTIFIER_SIZE
+#define LANG_HOOKS_IDENTIFIER_SIZE     sizeof (struct tree_identifier)
+#undef  LANG_HOOKS_INIT
+#define LANG_HOOKS_INIT                        gnat_init
+#undef  LANG_HOOKS_INIT_OPTIONS
+#define LANG_HOOKS_INIT_OPTIONS                gnat_init_options
+#undef  LANG_HOOKS_DECODE_OPTION
+#define LANG_HOOKS_DECODE_OPTION       gnat_decode_option
+#undef LANG_HOOKS_HONOR_READONLY
+#define LANG_HOOKS_HONOR_READONLY      1
+#undef LANG_HOOKS_GET_ALIAS_SET
+#define LANG_HOOKS_GET_ALIAS_SET       gnat_get_alias_set
+#undef LANG_HOOKS_PRINT_DECL
+#define LANG_HOOKS_PRINT_DECL          gnat_print_decl
+#undef LANG_HOOKS_PRINT_TYPE
+#define LANG_HOOKS_PRINT_TYPE          gnat_print_type
+#undef LANG_HOOKS_EXPAND_CONSTANT
+#define LANG_HOOKS_EXPAND_CONSTANT     gnat_expand_constant
+
+const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
 /* gnat standard argc argv */
 
@@ -118,14 +150,12 @@ extern char **gnat_argv;
 
 /* Global Variables Expected by gcc: */
 
-const char * const language_string = "GNU Ada";
 int flag_traditional;          /* Used by dwarfout.c.  */
 int ggc_p = 1;
 
 static void internal_error_function    PARAMS ((const char *, va_list *));
 static rtx gnat_expand_expr            PARAMS ((tree, rtx, enum machine_mode,
                                                 enum expand_modifier));
-static tree gnat_expand_constant       PARAMS ((tree));
 static void gnat_adjust_rli            PARAMS ((record_layout_info));
 
 #if defined(MIPS_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO)
@@ -137,9 +167,6 @@ static char *convert_ada_name_to_qualified_name PARAMS ((char *));
 /* For most front-ends, this is the parser for the language.  For us, we
    process the GNAT tree.  */
 
-#define Set_Jmpbuf_Address system__soft_links__set_jmpbuf_address_soft
-extern void Set_Jmpbuf_Address (void *);
-
 /* Declare functions we use as part of startup.  */
 extern void __gnat_initialize  PARAMS((void));
 extern void adainit            PARAMS((void));
@@ -148,34 +175,17 @@ extern void _ada_gnat1drv PARAMS((void));
 int
 yyparse ()
 {
-  /* Make up what Gigi uses as a jmpbuf.  */
-  size_t jmpbuf[10];
-
   /* call the target specific initializations */
   __gnat_initialize();
 
   /* Call the front-end elaboration procedures */
   adainit ();
 
-  /* Set up to catch unhandled exceptions.  */
-  if (__builtin_setjmp (jmpbuf))
-    {
-      Set_Jmpbuf_Address (0);
-      abort ();
-    }
-
-  /* This is only really needed in longjmp/setjmp mode exceptions
-     but we don't know any easy way to tell what mode the host is
-     compiled in, and it is harmless to do it unconditionally */
-
-  Set_Jmpbuf_Address (jmpbuf);
-
   immediate_size_expand = 1;
 
   /* Call the front end */
   _ada_gnat1drv ();
 
-  Set_Jmpbuf_Address (0);
   return 0;
 }
 
@@ -184,7 +194,7 @@ yyparse ()
    it cannot decode. This routine returns 1 if it is successful, otherwise
    it returns 0. */
 
-int
+static int
 gnat_decode_option (argc, argv)
      int argc ATTRIBUTE_UNUSED;
      char **argv;
@@ -243,7 +253,7 @@ gnat_decode_option (argc, argv)
 
 /* Initialize for option processing.  */
 
-void
+static void
 gnat_init_options ()
 {
   /* Initialize gnat_argv with save_argv size */
@@ -299,11 +309,7 @@ lang_mark_tree (t)
     }
 }
 
-/* Here we have the function to handle the compiler error processing in GCC.
-   Do this only if VPRINTF is available.  */
-
-#if defined(HAVE_VPRINTF)
-#define DO_INTERNAL_ERROR_FUNCTION
+/* Here we have the function to handle the compiler error processing in GCC.  */
 
 static void
 internal_error_function (msgid, ap)
@@ -331,21 +337,44 @@ internal_error_function (msgid, ap)
   Current_Error_Node = error_gnat_node;
   Compiler_Abort (fp, -1);
 }
-#endif
 
 /* Perform all the initialization steps that are language-specific.  */
 
-void
-gnat_init ()
+static const char *
+gnat_init (filename)
+     const char *filename;
 {
+/* Performs whatever initialization steps needed by the language-dependent
+   lexical analyzer.
+
+   Define the additional tree codes here.  This isn't the best place to put
+   it, but it's where g++ does it.  */
+
+  lang_expand_expr = gnat_expand_expr;
+
+  memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
+         (char *) gnat_tree_code_type,
+         ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
+          * sizeof (char *)));
+
+  memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
+         (char *) gnat_tree_code_length,
+         ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
+          * sizeof (int)));
+
+  memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
+         (char *) gnat_tree_code_name,
+         ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
+          * sizeof (char *)));
+
+  gnat_init_decl_processing ();
+
   /* Add the input filename as the last argument.  */
-  gnat_argv [gnat_argc] = (char *) input_filename;
+  gnat_argv [gnat_argc] = (char *) filename;
   gnat_argc++;
   gnat_argv [gnat_argc] = 0;
 
-#ifdef DO_INTERNAL_ERROR_FUNCTION
   set_internal_error_function (internal_error_function);
-#endif
 
   /* Show that REFERENCE_TYPEs are internal and should be Pmode.  */
   internal_reference_types ();
@@ -358,14 +387,11 @@ gnat_init ()
 #if defined(MIPS_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO)
   dwarf2out_set_demangle_name_func (convert_ada_name_to_qualified_name);
 #endif
-}
 
-/* Return a short string identifying this language to the debugger.  */
+  if (filename == 0)
+    filename = "";
 
-const char *
-lang_identify ()
-{
-  return "ada";
+  return filename;
 }
 
 /* If DECL has a cleanup, build and return that cleanup here.
@@ -379,20 +405,6 @@ maybe_build_cleanup (decl)
   return NULL_TREE;
 }
 
-/* Print any language-specific compilation statistics.  */
-
-void
-print_lang_statistics ()
-{}
-
-void
-lang_print_xnode (file, node, indent)
-     FILE *file ATTRIBUTE_UNUSED;
-     tree node ATTRIBUTE_UNUSED;
-     int indent ATTRIBUTE_UNUSED;
-{
-}
-
 /* integrate_decl_tree calls this function, but since we don't use the
    DECL_LANG_SPECIFIC field, this is a no-op.  */
 
@@ -404,8 +416,8 @@ copy_lang_decl (node)
 
 /* Hooks for print-tree.c:  */
 
-void
-print_lang_decl (file, node, indent)
+static void
+gnat_print_decl (file, node, indent)
      FILE *file;
      tree node;
      int indent;
@@ -427,8 +439,8 @@ print_lang_decl (file, node, indent)
     }
 }
 
-void
-print_lang_type (file, node, indent)
+static void
+gnat_print_type (file, node, indent)
      FILE *file;
      tree node;
      int indent;
@@ -479,13 +491,6 @@ print_lang_type (file, node, indent)
     }
 }
 
-void
-print_lang_identifier (file, node, indent)
-     FILE *file ATTRIBUTE_UNUSED;
-     tree node ATTRIBUTE_UNUSED;
-     int indent ATTRIBUTE_UNUSED;
-{}
-
 /* Expands GNAT-specific GCC tree nodes.  The only ones we support
    here are TRANSFORM_EXPR, UNCHECKED_CONVERT_EXPR, ALLOCATE_EXPR,
    USE_EXPR and NULL_EXPR.  */
@@ -573,26 +578,11 @@ gnat_expand_expr (exp, target, tmode, modifier)
       else if ((TYPE_MODE (type) == BLKmode
                || TYPE_MODE (inner_type) == BLKmode)
               && align_ok)
-       {
-         new = build_unary_op (INDIRECT_REF, NULL_TREE,
-                               convert
-                               (build_pointer_type (type),
-                                build_unary_op (ADDR_EXPR, NULL_TREE,
-                                                TREE_OPERAND (exp, 0))));
-         result = expand_expr (new, target, tmode, modifier);
-
-         if (GET_CODE (result) != MEM)
-           gigi_abort (204);
-
-         /* Since this is really the underlying object, set the flags from
-            the underlying type.
-
-            ??? Note that this is very dubious because it may change the
-            attributes for a temporary location, which is not allowed.  */
-         set_mem_alias_set (result, 0);
-         set_mem_attributes (result, TREE_OPERAND (exp, 0), 0);
-         return result;
-       }
+       new = build_unary_op (INDIRECT_REF, NULL_TREE,
+                             convert
+                             (build_pointer_type (type),
+                              build_unary_op (ADDR_EXPR, NULL_TREE,
+                                              TREE_OPERAND (exp, 0))));
 
       /* Otherwise make a union of the two types, convert to the union, and
         extract the other value.  */
@@ -648,9 +638,11 @@ gnat_expand_expr (exp, target, tmode, modifier)
       /* We aren't going to be doing anything with this memory, but allocate
         it anyway.  If it's variable size, make a bogus address.  */
       if (! host_integerp (TYPE_SIZE_UNIT (type), 1))
-       return gen_rtx_MEM (BLKmode, virtual_stack_vars_rtx);
+       result = gen_rtx_MEM (BLKmode, virtual_stack_vars_rtx);
       else
-       return assign_temp (type, 0, TREE_ADDRESSABLE (exp), 1);
+       result = assign_temp (type, 0, TREE_ADDRESSABLE (exp), 1);
+
+      return result;
 
     case ALLOCATE_EXPR:
       return
@@ -884,50 +876,6 @@ insert_code_for (gnat_node)
     }
 }
 
-/* Performs whatever initialization steps needed by the language-dependent
-   lexical analyzer.
-
-   Define the additional tree codes here.  This isn't the best place to put
-   it, but it's where g++ does it.  */
-
-const char *
-init_parse (filename)
-     const char *filename;
-{
-  lang_expand_expr = gnat_expand_expr;
-  lang_expand_constant = gnat_expand_constant;
-
-  memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
-         (char *) gnat_tree_code_type,
-         ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-          * sizeof (char *)));
-
-  memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
-         (char *) gnat_tree_code_length,
-         ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-          * sizeof (int)));
-
-  memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
-         (char *) gnat_tree_code_name,
-         ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-          * sizeof (char *)));
-
-  return filename;
-}
-
-void
-finish_parse ()
-{
-}
-
-/* Sets some debug flags for the parsed. It does nothing here.  */
-
-void
-set_yydebug (value)
-     int value ATTRIBUTE_UNUSED;
-{
-}
-
 #if 0
 
 /* Return the alignment for GNAT_TYPE.  */
@@ -942,8 +890,8 @@ get_type_alignment (gnat_type)
 
 /* Get the alias set corresponding to a type or expression.  */
 
-HOST_WIDE_INT
-lang_get_alias_set (type)
+static HOST_WIDE_INT
+gnat_get_alias_set (type)
      tree type;
 {
   /* If this is a padding type, use the type of the first field.  */
This page took 0.046092 seconds and 5 git commands to generate.