public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Unrecog attribute func handling change request + patch
@ 1998-02-02 17:14 Mumit Khan
  1998-02-04  2:25 ` Andreas Schwab
  1998-02-05 22:09 ` Jeffrey A Law
  0 siblings, 2 replies; 4+ messages in thread
From: Mumit Khan @ 1998-02-02 17:14 UTC (permalink / raw)
  To: egcs

While using a different stdio implementation that defines printf, etc
as macros, I ran into a problem where GCC flags unrecognized attribute
functions as errors. This seems rather too harsh, and I suggest warning
the user instead; after all, this is an extension.

To see the problem, use gas/as.h for example:

  #if (__GNUC__ >= 2) && !defined(VMS)
  /* for use with -Wformat */
  #define PRINTF_LIKE(FCN)  void FCN (const char *format, ...) \
                             __attribute__ ((format (printf, 1, 2)))
  #else 
  /* ... */
  #endif

SFIO (Safe/Fast I/O Library by David G. Korn and Kiem-Phong Vo) defines 
printf to be _stdprintf, so any code using this library and writing code 
like above, and there's lots of it, will fail.

Here's a patch:

Sun Feb  1 17:05:26 1998  Mumit Khan  <khan@xraylith.wisc.edu>
	
	* c-common.c (decl_attributes): Flag unrecognized attribute
	functions as warnings instead of as errors.

Index: c-common.c
===================================================================
RCS file: /usr/local/src/CVSROOT/egcs/gcc/c-common.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 c-common.c
--- c-common.c	1997/12/20 18:10:20	1.1.1.1
+++ c-common.c	1998/02/02 23:00:21
@@ -645,8 +645,8 @@ decl_attributes (node, attributes, prefi
 	      is_scan = 1;
 	    else if (TREE_CODE (format_type) == IDENTIFIER_NODE)
 	      {
-		error ("`%s' is an unrecognized format function type",
-		       IDENTIFIER_POINTER (format_type));
+		warning ("`%s' is an unrecognized format function type",
+		         IDENTIFIER_POINTER (format_type));
 		continue;
 	      }
 	    else

Regards,
Mumit -- khan@xraylith.wisc.edu
http://www.xraylith.wisc.edu/~khan/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unrecog attribute func handling change request + patch
  1998-02-02 17:14 Unrecog attribute func handling change request + patch Mumit Khan
@ 1998-02-04  2:25 ` Andreas Schwab
  1998-02-04  7:17   ` Mumit Khan
  1998-02-05 22:09 ` Jeffrey A Law
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 1998-02-04  2:25 UTC (permalink / raw)
  To: Mumit Khan; +Cc: egcs

Mumit Khan <khan@xraylith.wisc.edu> writes:

|> While using a different stdio implementation that defines printf, etc
|> as macros, I ran into a problem where GCC flags unrecognized attribute
|> functions as errors. This seems rather too harsh, and I suggest warning
|> the user instead; after all, this is an extension.

|> To see the problem, use gas/as.h for example:

|>   #if (__GNUC__ >= 2) && !defined(VMS)
|>   /* for use with -Wformat */
|>   #define PRINTF_LIKE(FCN)  void FCN (const char *format, ...) \
|>                              __attribute__ ((format (printf, 1, 2)))
|>   #else 
|>   /* ... */
|>   #endif

|> SFIO (Safe/Fast I/O Library by David G. Korn and Kiem-Phong Vo) defines 
|> printf to be _stdprintf, so any code using this library and writing code 
|> like above, and there's lots of it, will fail.

They should be using __attribute__ ((__format__ (__printf__, 1, 2))).

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"
schwab@gnu.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unrecog attribute func handling change request + patch
  1998-02-04  2:25 ` Andreas Schwab
@ 1998-02-04  7:17   ` Mumit Khan
  0 siblings, 0 replies; 4+ messages in thread
From: Mumit Khan @ 1998-02-04  7:17 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: egcs

Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> writes:
> 
> They should be using __attribute__ ((__format__ (__printf__, 1, 2))).
> 

Possibly yes, but most existing code take it straight out of the GCC
documentation, where it *doesn't* use __printf__ nor __format__.

In any event, it's simply wrong to flag it as an error.

Mumit


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Unrecog attribute func handling change request + patch
  1998-02-02 17:14 Unrecog attribute func handling change request + patch Mumit Khan
  1998-02-04  2:25 ` Andreas Schwab
@ 1998-02-05 22:09 ` Jeffrey A Law
  1 sibling, 0 replies; 4+ messages in thread
From: Jeffrey A Law @ 1998-02-05 22:09 UTC (permalink / raw)
  To: Mumit Khan; +Cc: egcs

  In message < 9802022306.AA14407@modi.xraylith.wisc.edu >you write:
  > While using a different stdio implementation that defines printf, etc
  > as macros, I ran into a problem where GCC flags unrecognized attribute
  > functions as errors. This seems rather too harsh, and I suggest warning
  > the user instead; after all, this is an extension.
  > 
  > To see the problem, use gas/as.h for example:
  > 
  >   #if (__GNUC__ >= 2) && !defined(VMS)
  >   /* for use with -Wformat */
  >   #define PRINTF_LIKE(FCN)  void FCN (const char *format, ...) \
  >                              __attribute__ ((format (printf, 1, 2)))
  >   #else 
  >   /* ... */
  >   #endif
  > 
  > SFIO (Safe/Fast I/O Library by David G. Korn and Kiem-Phong Vo) defines 
  > printf to be _stdprintf, so any code using this library and writing code 
  > like above, and there's lots of it, will fail.
  > 
  > Here's a patch:
  > 
  > Sun Feb  1 17:05:26 1998  Mumit Khan  <khan@xraylith.wisc.edu>
  > 	
  > 	* c-common.c (decl_attributes): Flag unrecognized attribute
  > 	functions as warnings instead of as errors.
I tend to agree that this shouldn't be an error...  I've seen somebody
that disagreed...    I've installed the patch, if we later think it should
be an error, we can always switch it back.

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-02-05 22:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-02 17:14 Unrecog attribute func handling change request + patch Mumit Khan
1998-02-04  2:25 ` Andreas Schwab
1998-02-04  7:17   ` Mumit Khan
1998-02-05 22:09 ` Jeffrey A Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).