ipa-utils.h (polymorphic_call_context): Add metdhos dump, debug and clear_outer_type.
[official-gcc.git] / gcc / c / c-errors.c
blobc1f9c3570d2d8f444b98b5f1b6d9d50bedc816ba
1 /* Various diagnostic subroutines for the GNU C language.
2 Copyright (C) 2000-2014 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "tree.h"
26 #include "c-tree.h"
27 #include "tm_p.h"
28 #include "flags.h"
29 #include "diagnostic.h"
30 #include "opts.h"
32 /* Issue an ISO C99 pedantic warning MSGID if -pedantic outside C11 mode,
33 otherwise issue warning MSGID if -Wc99-c11-compat is specified.
34 This function is supposed to be used for matters that are allowed in
35 ISO C11 but not supported in ISO C99, thus we explicitly don't pedwarn
36 when C11 is specified. */
38 bool
39 pedwarn_c99 (location_t location, int opt, const char *gmsgid, ...)
41 diagnostic_info diagnostic;
42 va_list ap;
43 bool warned = false;
45 va_start (ap, gmsgid);
46 /* If desired, issue the C99/C11 compat warning, which is more specific
47 than -pedantic. */
48 if (warn_c99_c11_compat > 0)
50 diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
51 (pedantic && !flag_isoc11)
52 ? DK_PEDWARN : DK_WARNING);
53 diagnostic.option_index = OPT_Wc99_c11_compat;
54 warned = report_diagnostic (&diagnostic);
56 /* -Wno-c99-c11-compat suppresses even the pedwarns. */
57 else if (warn_c99_c11_compat == 0)
59 /* For -pedantic outside C11, issue a pedwarn. */
60 else if (pedantic && !flag_isoc11)
62 diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN);
63 diagnostic.option_index = opt;
64 warned = report_diagnostic (&diagnostic);
66 va_end (ap);
67 return warned;
70 /* Issue an ISO C90 pedantic warning MSGID if -pedantic outside C99 mode,
71 otherwise issue warning MSGID if -Wc90-c99-compat is specified, or if
72 a specific option such as -Wlong-long is specified.
73 This function is supposed to be used for matters that are allowed in
74 ISO C99 but not supported in ISO C90, thus we explicitly don't pedwarn
75 when C99 is specified. (There is no flag_c90.) */
77 void
78 pedwarn_c90 (location_t location, int opt, const char *gmsgid, ...)
80 diagnostic_info diagnostic;
81 va_list ap;
83 va_start (ap, gmsgid);
84 /* Warnings such as -Wvla are the most specific ones. */
85 if (opt != OPT_Wpedantic)
87 int opt_var = *(int *) option_flag_var (opt, &global_options);
88 if (opt_var == 0)
89 goto out;
90 else if (opt_var > 0)
92 diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
93 (pedantic && !flag_isoc99)
94 ? DK_PEDWARN : DK_WARNING);
95 diagnostic.option_index = opt;
96 report_diagnostic (&diagnostic);
97 goto out;
100 /* Maybe we want to issue the C90/C99 compat warning, which is more
101 specific than -pedantic. */
102 if (warn_c90_c99_compat > 0)
104 diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
105 (pedantic && !flag_isoc99)
106 ? DK_PEDWARN : DK_WARNING);
107 diagnostic.option_index = OPT_Wc90_c99_compat;
108 report_diagnostic (&diagnostic);
110 /* -Wno-c90-c99-compat suppresses the pedwarns. */
111 else if (warn_c90_c99_compat == 0)
113 /* For -pedantic outside C99, issue a pedwarn. */
114 else if (pedantic && !flag_isoc99)
116 diagnostic_set_info (&diagnostic, gmsgid, &ap, location, DK_PEDWARN);
117 diagnostic.option_index = opt;
118 report_diagnostic (&diagnostic);
120 out:
121 va_end (ap);