aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-errors.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c/c-errors.c')
-rw-r--r--gcc/c/c-errors.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/gcc/c/c-errors.c b/gcc/c/c-errors.c
index 89393b9..c1f9c35 100644
--- a/gcc/c/c-errors.c
+++ b/gcc/c/c-errors.c
@@ -29,20 +29,42 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic.h"
#include "opts.h"
-/* Issue an ISO C99 pedantic warning MSGID. */
+/* Issue an ISO C99 pedantic warning MSGID if -pedantic outside C11 mode,
+ otherwise issue warning MSGID if -Wc99-c11-compat is specified.
+ This function is supposed to be used for matters that are allowed in
+ ISO C11 but not supported in ISO C99, thus we explicitly don't pedwarn
+ when C11 is specified. */
-void
+bool
pedwarn_c99 (location_t location, int opt, const char *gmsgid, ...)
{
diagnostic_info diagnostic;
va_list ap;
+ bool warned = false;
va_start (ap, gmsgid);
- diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
- flag_isoc99 ? DK_PEDWARN : DK_WARNING);
- diagnostic.option_index = opt;
- report_diagnostic (&diagnostic);
+ /* If desired, issue the C99/C11 compat warning, which is more specific
+ than -pedantic. */
+ if (warn_c99_c11_compat > 0)
+ {
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
+ (pedantic && !flag_isoc11)
+ ? DK_PEDWARN : DK_WARNING);
+ diagnostic.option_index = OPT_Wc99_c11_compat;
+ warned = report_diagnostic (&diagnostic);
+ }
+ /* -Wno-c99-c11-compat suppresses even the pedwarns. */
+ else if (warn_c99_c11_compat == 0)
+ ;
+ /* For -pedantic outside C11, issue a pedwarn. */
+ else if (pedantic && !flag_isoc11)
+ {
+ diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN);
+ diagnostic.option_index = opt;
+ warned = report_diagnostic (&diagnostic);
+ }
va_end (ap);
+ return warned;
}
/* Issue an ISO C90 pedantic warning MSGID if -pedantic outside C99 mode,