[PATCH] fix int vs enum issues with in stabs support

Olivier Hainque hainque@adacore.com
Tue May 5 16:18:00 GMT 2009


Bootstrap on powerpc-aix currently stops in stage2 on:

    << [...]
    cc1: warnings being treated as errors
    ../src/gcc/dbxout.c: In function 'dbxout_symbol':
    .../dbxout.c:2685: error: enum conversion when passing argument 2 of
     'dbxout_finish_complex_stabs' is invalid in C++
    .../dbxout.c:845: note: expected 'enum __stab_debug_code' but argument is
     of type 'int'
    ...
    .../dbxout.c:3368: error: enum conversion in assignment is invalid in C++
    ...
    >>

Despite 

  #define STAB_CODE_TYPE enum __stab_debug_code

in a couple of places, stab codes really are processed as integers
with convenient names. For instance, xcoffout.c:

  << /* Conversion routine from BSD stabs to AIX storage classes.  */
     int
     stab_to_sclass (int stab)
     [...]
  >>

or xcoffout.h:

  << /* These are IBM XCOFF extensions we need to reference in dbxout.c
        and xcoffout.c.  */

     /* AIX XCOFF uses this for typedefs.  This can have any value, since it is
	only used for translation into a C_DECL storage class.  */
     #ifndef N_DECL
     #define N_DECL 0x8c
     #endif
  >>

The attached patch is a suggestion to address the build failure by
introducing a stab_code_t typedef to int, to replace STAB_CODE_TYPE
where used so that all the pieces agree on a consistent view.

Tested on powerpc-ibm-aix5.3.0.0 by first verifying that the bootstrap
proceeds past the failure point after the change. I also checked that
basic debugging capabilities were still OK. They were except for a
problem with local variables (registered stack locations off the real
ones), which I think is unrelated.

Thanks in advance,

Olivier

2009-05-05  Olivier Hainque  <hainque@adacore.com>

	* gstab.h (stab_code_t): Define, to be used instead of the
	__stab_debug_code enum, made anonymous.
	* dbxout.c (STAB_CODE_TYPE): Remove #define and replace use
	occurrences by stab_code_t.
	* mips-tfile.c (STAB_CODE_TYPE): Remove #define, unused.

-------------- next part --------------
Index: gstab.h
===================================================================
*** gstab.h	(revision 147125)
--- gstab.h	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 21,32 ****
  
  #define __define_stab(NAME, CODE, STRING) NAME=CODE,
  
! enum __stab_debug_code
  {
  #include "stab.def"
  LAST_UNUSED_STAB_CODE
  };
  
  #undef __define_stab
  
  #endif /* ! GCC_GSTAB_H */
--- 21,35 ----
  
  #define __define_stab(NAME, CODE, STRING) NAME=CODE,
  
! enum
  {
  #include "stab.def"
  LAST_UNUSED_STAB_CODE
  };
  
+ /* stabs debug codes really are integers with convenient names.  */
+ typedef int stab_code_t;
+ 
  #undef __define_stab
  
  #endif /* ! GCC_GSTAB_H */
Index: mips-tfile.c
===================================================================
*** mips-tfile.c	(revision 147091)
--- mips-tfile.c	(working copy)
*************** main (void)
*** 675,682 ****
  
  #include "gstab.h"
  
- #define STAB_CODE_TYPE enum __stab_debug_code
- 
  #ifndef MALLOC_CHECK
  #ifdef	__SABER__
  #define MALLOC_CHECK
--- 675,680 ----
Index: dbxout.c
===================================================================
*** dbxout.c	(revision 147125)
--- dbxout.c	(working copy)
*************** static const char *base_input_file;
*** 275,282 ****
  
  #include "gstab.h"
  
- #define STAB_CODE_TYPE enum __stab_debug_code
- 
  /* 1 if PARM is passed to this function in memory.  */
  
  #define PARM_PASSED_IN_MEMORY(PARM) \
--- 275,280 ----
*************** static void dbxout_type_name (tree);
*** 326,332 ****
  static void dbxout_class_name_qualifiers (tree);
  static int dbxout_symbol_location (tree, tree, const char *, rtx);
  static void dbxout_symbol_name (tree, const char *, int);
! static void dbxout_common_name (tree, const char *, STAB_CODE_TYPE);
  static const char *dbxout_common_check (tree, int *);
  static void dbxout_global_decl (tree);
  static void dbxout_type_decl (tree, int);
--- 324,330 ----
  static void dbxout_class_name_qualifiers (tree);
  static int dbxout_symbol_location (tree, tree, const char *, rtx);
  static void dbxout_symbol_name (tree, const char *, int);
! static void dbxout_common_name (tree, const char *, stab_code_t);
  static const char *dbxout_common_check (tree, int *);
  static void dbxout_global_decl (tree);
  static void dbxout_type_decl (tree, int);
*************** do {								\
*** 842,848 ****
     to DBX_FINISH_STABS; see above for details.  */
     
  static void
! dbxout_finish_complex_stabs (tree sym, STAB_CODE_TYPE code,
  			     rtx addr, const char *label, int number)
  {
    int line ATTRIBUTE_UNUSED;
--- 840,846 ----
     to DBX_FINISH_STABS; see above for details.  */
     
  static void
! dbxout_finish_complex_stabs (tree sym, stab_code_t code,
  			     rtx addr, const char *label, int number)
  {
    int line ATTRIBUTE_UNUSED;
*************** static int
*** 2838,2844 ****
  dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
  {
    int letter = 0;
!   STAB_CODE_TYPE code;
    rtx addr = 0;
    int number = 0;
    int regno = -1;
--- 2836,2842 ----
  dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
  {
    int letter = 0;
!   stab_code_t code;
    rtx addr = 0;
    int number = 0;
    int regno = -1;
*************** dbxout_symbol_name (tree decl, const cha
*** 3143,3149 ****
     emits the N_BCOMM and N_ECOMM stabs.  */
  
  static void
! dbxout_common_name (tree decl, const char *name, STAB_CODE_TYPE op)
  {
    dbxout_begin_complex_stabs ();
    stabstr_S (name);
--- 3141,3147 ----
     emits the N_BCOMM and N_ECOMM stabs.  */
  
  static void
! dbxout_common_name (tree decl, const char *name, stab_code_t op)
  {
    dbxout_begin_complex_stabs ();
    stabstr_S (name);
*************** dbxout_parms (tree parms)
*** 3311,3317 ****
        {
  	tree eff_type;
  	char letter;
! 	STAB_CODE_TYPE code;
  	int number;
  
  	/* Perform any necessary register eliminations on the parameter's rtl,
--- 3309,3315 ----
        {
  	tree eff_type;
  	char letter;
! 	stab_code_t code;
  	int number;
  
  	/* Perform any necessary register eliminations on the parameter's rtl,


More information about the Gcc-patches mailing list