This is the mail archive of the gcc-bugs@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]

Re: egcs-980315 bug report with patch


	My reading of K&R 2, page 245 suggests that 'L' is a permitted
	character in a % specifier.

L is permitted for floating point numbers to specify long double, but it
is not permitted for integral numbers to specify long long int.  It looks like
someone tried to fix the latter and accidentally broke the former.

Your patch doesn't deal with this subtlety.  Also, your patch breaks support
for the 'q' length modifier by unconditionally emitting a warning for it
instead of only emitting a warning when pedantic.

I wrote a slightly different patch to address these problems.

Wed Mar 25 13:35:39 1998  Jim Wilson  <wilson@cygnus.com>

	* c-common.c (check_format_info): Initialize type, is_type.  New local
	integral_format.  Don't warn for 'L' when pedantic.  Do warn for 'L'
	when pedantic if used with integral format specifier.

Index: c-common.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-common.c,v
retrieving revision 1.6
diff -p -r1.6 c-common.c
*** c-common.c	1998/03/20 14:57:35	1.6
--- c-common.c	1998/03/25 21:35:32
*************** void
*** 379,386 ****
  decl_attributes (node, attributes, prefix_attributes)
       tree node, attributes, prefix_attributes;
  {
!   tree decl = 0, type;
!   int is_type;
    tree a;
  
    if (attrtab_idx == 0)
--- 379,386 ----
  decl_attributes (node, attributes, prefix_attributes)
       tree node, attributes, prefix_attributes;
  {
!   tree decl = 0, type = 0;
!   int is_type = 0;
    tree a;
  
    if (attrtab_idx == 0)
*************** check_format_info (info, params)
*** 1185,1190 ****
--- 1185,1191 ----
    int length_char;
    int format_char;
    int format_length;
+   int integral_format;
    tree format_tree;
    tree cur_param;
    tree cur_type;
*************** check_format_info (info, params)
*** 1448,1454 ****
        else if (*format_chars == 'q' || *format_chars == 'L')
  	{
  	  length_char = *format_chars++;
! 	  if (pedantic)
  	    pedwarn ("ANSI C does not support the `%c' length modifier",
  		     length_char);
  	}
--- 1449,1455 ----
        else if (*format_chars == 'q' || *format_chars == 'L')
  	{
  	  length_char = *format_chars++;
! 	  if (pedantic && length_char == 'q')
  	    pedwarn ("ANSI C does not support the `%c' length modifier",
  		     length_char);
  	}
*************** check_format_info (info, params)
*** 1557,1566 ****
  	      warning (message);
  	    }
  	}
!       if (precise && index (flag_chars, '0') != 0
! 	  && (format_char == 'd' || format_char == 'i'
! 	      || format_char == 'o' || format_char == 'u'
! 	      || format_char == 'x' || format_char == 'x'))
  	{
  	  sprintf (message,
  		   "`0' flag ignored with precision specifier and `%c' format",
--- 1558,1567 ----
  	      warning (message);
  	    }
  	}
!       integral_format = (format_char == 'd' || format_char == 'i'
! 			 || format_char == 'o' || format_char == 'u'
! 			 || format_char == 'x' || format_char == 'x');
!       if (precise && index (flag_chars, '0') != 0 && integral_format)
  	{
  	  sprintf (message,
  		   "`0' flag ignored with precision specifier and `%c' format",
*************** check_format_info (info, params)
*** 1575,1581 ****
  	case 'q': wanted_type = fci->qlen ? *(fci->qlen) : 0; break;
  	case 'L': wanted_type = fci->bigllen ? *(fci->bigllen) : 0; break;
  	}
!       if (wanted_type == 0)
  	{
  	  sprintf (message,
  		   "use of `%c' length character with `%c' type character",
--- 1576,1583 ----
  	case 'q': wanted_type = fci->qlen ? *(fci->qlen) : 0; break;
  	case 'L': wanted_type = fci->bigllen ? *(fci->bigllen) : 0; break;
  	}
!       if (wanted_type == 0
! 	  || (pedantic && length_char == 'L' && integral_format))
  	{
  	  sprintf (message,
  		   "use of `%c' length character with `%c' type character",


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