OSDN Git Service

[pf3gnuchains/gcc-fork.git] / gcc / dwarfout.c
index ce9df47..4ab2747 100644 (file)
@@ -50,7 +50,7 @@ extern time_t time PROTO ((time_t *)); /* FIXME: use NEED_DECLARATION_TIME */
 # define assert(e) do { if (! (e)) abort (); } while (0)
 #endif
 
-extern char *getpwd ();
+extern char *getpwd PROTO((void));
 
 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
    regarding the GNU implementation of Dwarf.  */
@@ -362,7 +362,9 @@ static inline void body_begin_attribute     PROTO((char *));
 static inline void body_end_attribute  PROTO((char *));
 static inline void language_attribute  PROTO((unsigned));
 static inline void member_attribute    PROTO((tree));
+#if 0
 static inline void string_length_attribute PROTO((tree));
+#endif
 static inline void comp_dir_attribute  PROTO((char *));
 static inline void sf_names_attribute  PROTO((char *));
 static inline void src_info_attribute  PROTO((char *));
@@ -431,6 +433,10 @@ static void generate_new_sfname_entry      PROTO((void));
 static unsigned lookup_filename                PROTO((char *));
 static void generate_srcinfo_entry     PROTO((unsigned, unsigned));
 static void generate_macinfo_entry     PROTO((char *, char *));
+static int is_pseudo_reg               PROTO((rtx));
+static tree type_main_variant          PROTO((tree));
+static int is_tagged_type              PROTO((tree));
+static int is_redundant_typedef                PROTO((tree));
 \f
 /* Definitions of defaults for assembler-dependent names of various
    pseudo-ops and section names.
@@ -851,14 +857,24 @@ static void generate_macinfo_entry        PROTO((char *, char *));
   } while (0)
 #endif
 
+/* ASM_OUTPUT_DWARF_STRING is defined to output an ascii string, but to
+   NOT issue a trailing newline. We define ASM_OUTPUT_DWARF_STRING_NEWLINE
+   based on whether ASM_OUTPUT_DWARF_STRING is defined or not. If it is
+   defined, we call it, then issue the line feed. If not, we supply a
+   default defintion of calling ASM_OUTPUT_ASCII */
+
 #ifndef ASM_OUTPUT_DWARF_STRING
-#define ASM_OUTPUT_DWARF_STRING(FILE,P) \
+#define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
   ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
+#else
+#define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
+  ASM_OUTPUT_DWARF_STRING (FILE,P), ASM_OUTPUT_DWARF_STRING (FILE,"\n") 
 #endif
+
 \f
 /************************ general utility functions **************************/
 
-inline int
+inline static int
 is_pseudo_reg (rtl)
      register rtx rtl;
 {
@@ -867,7 +883,7 @@ is_pseudo_reg (rtl)
              && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
 }
 
-inline tree
+inline static tree
 type_main_variant (type)
      register tree type;
 {
@@ -889,7 +905,7 @@ type_main_variant (type)
 
 /* Return non-zero if the given type node represents a tagged type.  */
 
-inline int
+inline static int
 is_tagged_type (type)
      register tree type;
 {
@@ -1144,23 +1160,14 @@ static tree
 decl_ultimate_origin (decl)
      register tree decl;
 {
-  register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl);
-
-  if (immediate_origin == NULL)
-    return NULL;
-  else
-    {
-      register tree ret_val;
-      register tree lookahead = immediate_origin;
+#ifdef ENABLE_CHECKING 
+  if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
+    /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
+       most distant ancestor, this should never happen.  */
+    abort ();
+#endif
 
-      do
-       {
-         ret_val = lookahead;
-         lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
-       }
-      while (lookahead != NULL && lookahead != ret_val);
-      return ret_val;
-    }
+  return DECL_ABSTRACT_ORIGIN (decl);
 }
 
 /* Determine the "ultimate origin" of a block.  The block may be an
@@ -1415,7 +1422,16 @@ fundamental_type_code (type)
          }
 
        if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
-         return FT_dbl_prec_float;
+         {
+           /* On the SH, when compiling with -m3e or -m4-single-only, both
+              float and double are 32 bits.  But since the debugger doesn't
+              know about the subtarget, it always thinks double is 64 bits.
+              So we have to tell the debugger that the type is float to
+              make the output of the 'print' command etc. readable.  */
+           if (DOUBLE_TYPE_SIZE == FLOAT_TYPE_SIZE && FLOAT_TYPE_SIZE == 32)
+             return FT_float;
+           return FT_dbl_prec_float;
+         }
        if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
          return FT_float;
 
@@ -1887,7 +1903,7 @@ output_enumeral_list (link)
       output_enumeral_list (TREE_CHAIN (link));
       ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
                              (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
-      ASM_OUTPUT_DWARF_STRING (asm_out_file,
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
                               IDENTIFIER_POINTER (TREE_PURPOSE (link)));
     }
 }
@@ -2250,7 +2266,7 @@ const_value_attribute (rtl)
        break;
 
       case CONST_STRING:
-       ASM_OUTPUT_DWARF_STRING (asm_out_file, XSTR (rtl, 0));
+       ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, XSTR (rtl, 0));
        break;
 
       case SYMBOL_REF:
@@ -2460,7 +2476,7 @@ name_attribute (name_string)
   if (name_string && *name_string)
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, name_string);
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, name_string);
     }
 }
 
@@ -2875,6 +2891,7 @@ member_attribute (context)
     }
 }
 
+#if 0
 static inline void
 string_length_attribute (upper_bound)
      register tree upper_bound;
@@ -2890,13 +2907,14 @@ string_length_attribute (upper_bound)
   output_bound_representation (upper_bound, 0, 'u');
   ASM_OUTPUT_LABEL (asm_out_file, end_label);
 }
+#endif
 
 static inline void
 comp_dir_attribute (dirname)
      register char *dirname;
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
-  ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
+  ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
 }
 
 static inline void
@@ -2934,7 +2952,7 @@ prototyped_attribute (func_type)
       && (TYPE_ARG_TYPES (func_type) != NULL))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
 }
 
@@ -2943,7 +2961,7 @@ producer_attribute (producer)
      register char *producer;
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
-  ASM_OUTPUT_DWARF_STRING (asm_out_file, producer);
+  ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, producer);
 }
 
 static inline void
@@ -2953,7 +2971,7 @@ inline_attribute (decl)
   if (DECL_INLINE (decl))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
 }
 
@@ -3016,7 +3034,7 @@ pure_or_virtual_attribute (func_decl)
       else
 #endif
         ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
 }
 
@@ -3743,17 +3761,17 @@ output_inheritance_die (arg)
   if (TREE_VIA_VIRTUAL (binfo))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
   if (TREE_VIA_PUBLIC (binfo))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
   else if (TREE_VIA_PROTECTED (binfo))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
 }  
 
@@ -4652,7 +4670,7 @@ output_decls_for_scope (stmt, depth)
 
 /* Is this a typedef we can avoid emitting?  */
 
-inline int
+inline static int
 is_redundant_typedef (decl)
      register tree decl;
 {
@@ -4993,7 +5011,7 @@ output_decl (decl, containing_scope)
         function.  */
 
       {
-        register void (*func) ();
+        register void (*func) PROTO((void *));
        register tree origin = decl_ultimate_origin (decl);
 
        if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
@@ -5113,7 +5131,7 @@ dwarfout_file_scope_decl (decl, set_finalizing)
          ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
          sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
          ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
-         ASM_OUTPUT_DWARF_STRING (asm_out_file,
+         ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
                                   IDENTIFIER_POINTER (DECL_NAME (decl)));
          ASM_OUTPUT_POP_SECTION (asm_out_file);
        }
@@ -5151,7 +5169,7 @@ dwarfout_file_scope_decl (decl, set_finalizing)
              ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
              sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
              ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
-             ASM_OUTPUT_DWARF_STRING (asm_out_file,
+             ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
                                       IDENTIFIER_POINTER (DECL_NAME (decl)));
              ASM_OUTPUT_POP_SECTION (asm_out_file);
            }
@@ -5239,10 +5257,16 @@ dwarfout_file_scope_decl (decl, set_finalizing)
 
   output_pending_types_for_scope (NULL_TREE);
 
-  /* The above call should have totally emptied the pending_types_list.  */
-
-  if (pending_types != 0)
-    abort ();
+  /* The above call should have totally emptied the pending_types_list
+     if this is not a nested function or class.  If this is a nested type,
+     then the remaining pending_types will be emitted when the containing type
+     is handled.  */
+  
+  if (! DECL_CONTEXT (decl))
+    {
+      if (pending_types != 0)
+       abort ();
+    }
 
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -5378,7 +5402,7 @@ generate_new_sfname_entry ()
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
   sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
   ASM_OUTPUT_LABEL (asm_out_file, label);
-  ASM_OUTPUT_DWARF_STRING (asm_out_file,
+  ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
                           filename_table[0].name
                             ? filename_table[0].name
                             : "");
@@ -5551,7 +5575,7 @@ generate_macinfo_entry (type_and_offset, string)
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
   fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset);
-  ASM_OUTPUT_DWARF_STRING (asm_out_file, string);
+  ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, string);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 }
 
@@ -5732,7 +5756,7 @@ dwarfout_init (asm_out_file, main_input_filename)
     
            strcpy (dirname, pwd);
            strcpy (dirname + len, "/");
-           ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
+           ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
            free (dirname);
          }
          ASM_OUTPUT_POP_SECTION (asm_out_file);
@@ -5936,7 +5960,7 @@ dwarfout_finish ()
          fputc ('\n', asm_out_file);
          ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
          ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
-         ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+         ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
          ASM_OUTPUT_POP_SECTION (asm_out_file);
        }
     
@@ -5945,7 +5969,7 @@ dwarfout_finish ()
       fputc ('\n', asm_out_file);
       ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
       ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
       ASM_OUTPUT_POP_SECTION (asm_out_file);
     
       /* Generate the terminating entries for the .debug_aranges section.
@@ -5995,6 +6019,12 @@ dwarfout_finish ()
 
       ASM_OUTPUT_POP_SECTION (asm_out_file);
     }
+
+  /* There should not be any pending types left at the end.  We need
+     this now because it may not have been checked on the last call to
+     dwarfout_file_scope_decl.  */
+  if (pending_types != 0)
+    abort ();
 }
 
 #endif /* DWARF_DEBUGGING_INFO */