From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Kaveh R. Ghazi" To: gdr@codesourcery.com Cc: gcc@gcc.gnu.org Subject: Silently checking whether diagnostics would occur Date: Wed, 13 Sep 2000 08:50:00 -0000 Message-id: <200009131550.LAA13911@caip.rutgers.edu> X-SW-Source: 2000-09/msg00260.html Hi Gabriel, While writing a __builtin_printf expander, I found that it would be useful to be able to call the printf format checking routines silently from builtins.c to see if the printf call being expanded passed format checks before I try to optimize it. (This needs to happen regardless of, and independent of, whether the user specifies -Wformat.) The current format checking routines are setup to emit warnings at random points, not to return a handy status code. (See check_format_info in c-common.c.) So rather than do a complete restructuring of the format checking function, I though it would be much easier and cleaner to be able to call the checks conceptually like this: > check_diagnostics_silently = 1; /* new global vars */ > diagnostic_occurred = 0; > > > > if (diagnostic_occurred) > check_diagnostics_silently = 0; and modify diagnostic.c:count_error to do this before anything else: > if (check_diagnostics_silently) > { > diagnostic_occurred = 1; > return 0; > } This would fool gcc into keeping quiet about the warnings while still letting me know whether some kind of diagnostic would have issued. Note the current controls like inhibit_warnings don't seem to do what quite I want. It would silence the warnings without me being able to tell that a warning would have occured. I also don't want to worry about side effects modifying gcc's internal state, e.g. errorcount, or whether the user specified -Werror. My approach seems to solve all of these issues. First of all, I wanted to know if there was already something in there that I missed which allows me to do this. Second, if nothing exists is this approach something you feel would be acceptable into diagnostic.c? I'll provide a patch if you react positively. Thanks, --Kaveh -- Kaveh R. Ghazi Engagement Manager / Project Services ghazi@caip.rutgers.edu Qwest Internet Solutions