This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/6] Emit macro expansion related diagnostics


"H.J. Lu" <hjl.tools@gmail.com> writes:

> There are at least 2 bootstrap problems:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50760

The patch below should address those issues.

The first two hunks are to fix bootstrap for targets that have
!NO_IMPLICIT_EXTERN_C.  To test it, I built the compiler with
--target=avr.

The next hunk is to fix one part of the issue reported in the PR.  It's
because size_t on ia32 is unsigned int, while being unsigned long int on
x86_64.  To fix ia32 in a portable way I am casting size_t to long as
it's done in other parts of the compiler when fprinting.

The last hunk is because it appears to me that after
macro_arg_token_iter_init gets inlined into replace_args,
from->token_ptr appears possibly uninitialized.  So I am unconditionally
initializing it.

For the ia32 fixes, as I don't have any such target at hand, I ran
configure i686-pc-linux-gnu on my x86_64 host and the bootstrap is
underway.  It's taking time, sorry.

I ran a full bootstrap of the changes which went up to the comparison
failure we are currently having on trunk.

OK if this appears to fix the raised issues and passes bootstraps on the
i686 target?

Author: Dodji Seketeli <dodji@redhat.com>
Date:   Mon Oct 17 22:33:46 2011 +0200

    Fix bootstrap on !NO_IMPLICIT_EXTERN_C and ia32 targets
    
    libcpp/
    
    	* macro.c (macro_arg_token_iter_init): Unconditionally initialize
    	iter->location_ptr.
    
    gcc/c-family/
    
    	* c-lex.c (fe_file_change): Use LINEMAP_SYSP when
    	!NO_IMPLICIT_EXTERN_C.
    
    gcc/
    	* input.c (dump_line_table_statistics): Cast size_t to long for
    	printing.

diff --git a/gcc/c-family/c-lex.c b/gcc/c-family/c-lex.c
index be83b61..b151564 100644
--- a/gcc/c-family/c-lex.c
+++ b/gcc/c-family/c-lex.c
@@ -211,7 +211,7 @@ fe_file_change (const struct line_map *new_map)
 #ifndef NO_IMPLICIT_EXTERN_C
 	  if (c_header_level)
 	    ++c_header_level;
-	  else if (new_map->sysp == 2)
+	  else if (LINEMAP_SYSP (new_map) == 2)
 	    {
 	      c_header_level = 1;
 	      ++pending_lang_change;
@@ -224,7 +224,7 @@ fe_file_change (const struct line_map *new_map)
 #ifndef NO_IMPLICIT_EXTERN_C
       if (c_header_level && --c_header_level == 0)
 	{
-	  if (new_map->sysp == 2)
+	  if (LINEMAP_SYSP (new_map) == 2)
 	    warning (0, "badly nested C headers from preprocessor");
 	  --pending_lang_change;
 	}
diff --git a/gcc/input.c b/gcc/input.c
index 41842b7..8138a65 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -99,46 +99,46 @@ dump_line_table_statistics (void)
     + s.macro_maps_used_size
     + s.macro_maps_locations_size;
 
-  fprintf (stderr, "Number of expanded macros:                     %5lu\n",
-           s.num_expanded_macros);
+  fprintf (stderr, "Number of expanded macros:                     %5ld\n",
+           (long)s.num_expanded_macros);
   if (s.num_expanded_macros != 0)
-    fprintf (stderr, "Average number of tokens per macro expansion:  %5lu\n",
-             s.num_macro_tokens / s.num_expanded_macros);
+    fprintf (stderr, "Average number of tokens per macro expansion:  %5ld\n",
+             (long)s.num_macro_tokens / s.num_expanded_macros);
   fprintf (stderr,
            "\nLine Table allocations during the "
            "compilation process\n");
-  fprintf (stderr, "Number of ordinary maps used:        %5lu%c\n",
-           SCALE (s.num_ordinary_maps_used),
+  fprintf (stderr, "Number of ordinary maps used:        %5ld%c\n",
+           (long)SCALE (s.num_ordinary_maps_used),
            STAT_LABEL (s.num_ordinary_maps_used));
-  fprintf (stderr, "Ordinary map used size:              %5lu%c\n",
-           SCALE (s.ordinary_maps_used_size),
+  fprintf (stderr, "Ordinary map used size:              %5ld%c\n",
+           (long)SCALE (s.ordinary_maps_used_size),
            STAT_LABEL (s.ordinary_maps_used_size));
-  fprintf (stderr, "Number of ordinary maps allocated:   %5lu%c\n",
-           SCALE (s.num_ordinary_maps_allocated),
+  fprintf (stderr, "Number of ordinary maps allocated:   %5ld%c\n",
+           (long)SCALE (s.num_ordinary_maps_allocated),
            STAT_LABEL (s.num_ordinary_maps_allocated));
-  fprintf (stderr, "Ordinary maps allocated size:        %5lu%c\n",
-           SCALE (s.ordinary_maps_allocated_size),
+  fprintf (stderr, "Ordinary maps allocated size:        %5ld%c\n",
+           (long)SCALE (s.ordinary_maps_allocated_size),
            STAT_LABEL (s.ordinary_maps_allocated_size));
-  fprintf (stderr, "Number of macro maps used:           %5lu%c\n",
-           SCALE (s.num_macro_maps_used),
+  fprintf (stderr, "Number of macro maps used:           %5ld%c\n",
+           (long)SCALE (s.num_macro_maps_used),
            STAT_LABEL (s.num_macro_maps_used));
-  fprintf (stderr, "Macro maps used size:                %5lu%c\n",
-           SCALE (s.macro_maps_used_size),
+  fprintf (stderr, "Macro maps used size:                %5ld%c\n",
+           (long)SCALE (s.macro_maps_used_size),
            STAT_LABEL (s.macro_maps_used_size));
-  fprintf (stderr, "Macro maps locations size:           %5lu%c\n",
-           SCALE (s.macro_maps_locations_size),
+  fprintf (stderr, "Macro maps locations size:           %5ld%c\n",
+           (long)SCALE (s.macro_maps_locations_size),
            STAT_LABEL (s.macro_maps_locations_size));
-  fprintf (stderr, "Macro maps size:                     %5lu%c\n",
-           SCALE (macro_maps_size),
+  fprintf (stderr, "Macro maps size:                     %5ld%c\n",
+           (long)SCALE (macro_maps_size),
            STAT_LABEL (macro_maps_size));
-  fprintf (stderr, "Duplicated maps locations size:      %5lu%c\n",
-           SCALE (s.duplicated_macro_maps_locations_size),
+  fprintf (stderr, "Duplicated maps locations size:      %5ld%c\n",
+           (long)SCALE (s.duplicated_macro_maps_locations_size),
            STAT_LABEL (s.duplicated_macro_maps_locations_size));
-  fprintf (stderr, "Total allocated maps size:           %5lu%c\n",
-           SCALE (total_allocated_map_size),
+  fprintf (stderr, "Total allocated maps size:           %5ld%c\n",
+           (long)SCALE (total_allocated_map_size),
            STAT_LABEL (total_allocated_map_size));
-  fprintf (stderr, "Total used maps size:                %5lu%c\n",
-           SCALE (total_used_map_size),
+  fprintf (stderr, "Total used maps size:                %5ld%c\n",
+           (long)SCALE (total_used_map_size),
            STAT_LABEL (total_used_map_size));
   fprintf (stderr, "\n");
 }
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 2d0eeaa..f313959 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -1278,6 +1278,10 @@ macro_arg_token_iter_init (macro_arg_token_iter *iter,
   iter->track_macro_exp_p = track_macro_exp_p;
   iter->kind = kind;
   iter->token_ptr = token_ptr;
+  /* Unconditionally initialize this so that the compiler doesn't warn
+     about iter->location_ptr being possibly uninitialized later after
+     this code has been inlined somewhere.  */
+  iter->location_ptr = NULL;
   if (track_macro_exp_p)
     iter->location_ptr = get_arg_token_location (arg, kind);
 #ifdef ENABLE_CHECKING
-- 
		Dodji


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]