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]

PATCH to toplev.c: Guard use of "extern inline"


The use of the GNU C extension "extern inline" conflicts with the C++ One
Definition Rule.  Consequently, we must make sure we do not provide an
alternate definition when compiling with a C++ compiler.
Bootstrapped and regtested on an i686-pc-linux-gnu.

-- Gaby
2006-01-29  Gabriel Dos Reis  <gdr@integrable-solutions.net>
	    Marcin Dalecki  <martin@dalecki.de>

	* toplev.c (floor_log2, exact_log2): Don't define if __cplusplus.
	(push_srcloc): Use XNEW.
	(init_asm_output, default_get_pch_validity): Use XNEWVEC.
 
*** toplev.c	(revision 110374)
--- toplev.c	(local)
*************** read_integral_parameter (const char *p, 
*** 516,521 ****
--- 516,527 ----
    return atoi (p);
  }
  
+ /* When compiling with a recent enough GCC, we use the GNU C "extern inline"
+    for floor_log2 and exact_log2; see toplev.h.  That construct, however,
+    conflicts with the ISO C++ One Definition Rule.   */
+ 
+ #if !defined (__cplusplus)
+ 
  /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
     If X is 0, return -1.  */
  
*************** exact_log2 (unsigned HOST_WIDE_INT x)
*** 566,571 ****
--- 572,579 ----
  #endif
  }
  
+ #endif /* !defined (__cplusplus)  */
+ 
  /* Handler for fatal signals, such as SIGSEGV.  These are transformed
     into ICE messages, which is much more user friendly.  In case the
     error printer crashes, reset the signal to prevent infinite recursion.  */
*************** push_srcloc (const char *file, int line)
*** 942,948 ****
  {
    struct file_stack *fs;
  
!   fs = xmalloc (sizeof (struct file_stack));
    fs->location = input_location;
    fs->next = input_file_stack;
  #ifdef USE_MAPPED_LOCATION
--- 950,956 ----
  {
    struct file_stack *fs;
  
!   fs = XNEW (struct file_stack);
    fs->location = input_location;
    fs->next = input_file_stack;
  #ifdef USE_MAPPED_LOCATION
*************** init_asm_output (const char *name)
*** 1233,1239 ****
        if (asm_file_name == 0)
  	{
  	  int len = strlen (dump_base_name);
! 	  char *dumpname = xmalloc (len + 6);
  	  memcpy (dumpname, dump_base_name, len + 1);
  	  strip_off_ending (dumpname, len);
  	  strcat (dumpname, ".s");
--- 1241,1247 ----
        if (asm_file_name == 0)
  	{
  	  int len = strlen (dump_base_name);
! 	  char *dumpname = XNEWVEC (char, len + 6);
  	  memcpy (dumpname, dump_base_name, len + 1);
  	  strip_off_ending (dumpname, len);
  	  strcat (dumpname, ".s");
*************** default_get_pch_validity (size_t *len)
*** 1299,1305 ****
      if (option_affects_pch_p (i, &state))
        *len += state.size;
  
!   result = r = xmalloc (*len);
    r[0] = flag_pic;
    r[1] = flag_pie;
    r += 2;
--- 1307,1313 ----
      if (option_affects_pch_p (i, &state))
        *len += state.size;
  
!   result = r = XNEWVEC (char, *len);
    r[0] = flag_pic;
    r[1] = flag_pie;
    r += 2;


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