aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorJoseph Myers <jsm28@cam.ac.uk>2000-10-18 08:33:04 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2000-10-18 08:33:04 +0100
commitade7d3cc1db7b0c8e398fb9b3a5b065c4e7d3cec (patch)
tree68b6e159ffb83ef19f2cc09e7a7fc0ca9e546205 /gcc/c-common.c
parent8682223f1d6bee4de096176ba4b3d389fce23d7d (diff)
downloadgcc-ade7d3cc1db7b0c8e398fb9b3a5b065c4e7d3cec.zip
gcc-ade7d3cc1db7b0c8e398fb9b3a5b065c4e7d3cec.tar.gz
gcc-ade7d3cc1db7b0c8e398fb9b3a5b065c4e7d3cec.tar.bz2
c-common.c (CPLUSPLUS_STD_VER, [...]): Define.
* c-common.c (CPLUSPLUS_STD_VER, C_STD_VER, C_STD_NAME): Define. (maybe_read_dollar_number, check_format_info_main): Use them for pedantic warning messages. From-SVN: r36931
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c74
1 files changed, 38 insertions, 36 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 221f4eb..e9548dc 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -1265,6 +1265,23 @@ enum format_std_version
STD_EXT
};
+/* The C standard version C++ is treated as equivalent to
+ or inheriting from, for the purpose of format features supported. */
+#define CPLUSPLUS_STD_VER STD_C89
+/* The C standard version we are checking formats against when pedantic. */
+#define C_STD_VER (c_language == clk_cplusplus \
+ ? CPLUSPLUS_STD_VER \
+ : (flag_isoc99 \
+ ? STD_C99 \
+ : (flag_isoc94 ? STD_C94 : STD_C89)))
+/* The name to give to the standard version we are warning about when
+ pedantic. FEATURE_VER is the version in which the feature warned out
+ appeared, which is higher than C_STD_VER. */
+#define C_STD_NAME(FEATURE_VER) (c_language == clk_cplusplus \
+ ? "ISO C++" \
+ : ((FEATURE_VER) == STD_EXT \
+ ? "ISO C" \
+ : "ISO C89"))
/* Flags that may apply to a particular kind of format checked by GCC. */
enum
@@ -2113,7 +2130,9 @@ maybe_read_dollar_number (status, format, dollar_needed, params, param_ptr,
*format = fcp + 1;
if (pedantic && !dollar_format_warned)
{
- status_warning (status, "ISO C does not support %%n$ operand number formats");
+ status_warning (status,
+ "%s does not support %%n$ operand number formats",
+ C_STD_NAME (STD_EXT));
dollar_format_warned = 1;
}
if (overflow_flag || argnum == 0
@@ -2755,13 +2774,10 @@ check_format_info_main (status, res, info, format_chars, format_length,
if (pedantic)
{
/* Warn if the length modifier is non-standard. */
- if (length_chars_std == STD_EXT)
- status_warning (status, "ISO C does not support the `%s' %s length modifier",
- length_chars, fki->name);
- else if ((length_chars_std == STD_C99 && !flag_isoc99)
- || (length_chars_std == STD_C94 && !flag_isoc94))
- status_warning (status, "ISO C89 does not support the `%s' %s length modifier",
- length_chars, fki->name);
+ if (length_chars_std > C_STD_VER)
+ status_warning (status, "%s does not support the `%s' %s length modifier",
+ C_STD_NAME (length_chars_std), length_chars,
+ fki->name);
}
}
@@ -2828,13 +2844,9 @@ check_format_info_main (status, res, info, format_chars, format_length,
}
if (pedantic)
{
- if (fci->std == STD_EXT)
- status_warning (status, "ISO C does not support the `%%%c' %s format",
- format_char, fki->name);
- else if ((fci->std == STD_C99 && !flag_isoc99)
- || (fci->std == STD_C94 && !flag_isoc94))
- status_warning (status, "ISO C89 does not support the `%%%c' %s format",
- format_char, fki->name);
+ if (fci->std > C_STD_VER)
+ status_warning (status, "%s does not support the `%%%c' %s format",
+ C_STD_NAME (fci->std), format_char, fki->name);
}
/* Validate the individual flags used, removing any that are invalid. */
@@ -2857,26 +2869,19 @@ check_format_info_main (status, res, info, format_chars, format_length,
if (pedantic)
{
const format_flag_spec *t;
- if (s->std == STD_EXT)
- status_warning (status, "ISO C does not support %s",
- _(s->long_name));
- else if ((s->std == STD_C99 && !flag_isoc99)
- || (s->std == STD_C94 && !flag_isoc94))
- status_warning (status, "ISO C89 does not support %s",
- _(s->long_name));
+ if (s->std > C_STD_VER)
+ status_warning (status, "%s does not support %s",
+ C_STD_NAME (s->std), _(s->long_name));
t = get_flag_spec (flag_specs, flag_chars[i], fci->flags2);
if (t != NULL && t->std > s->std)
{
const char *long_name = (t->long_name != NULL
? t->long_name
: s->long_name);
- if (t->std == STD_EXT)
- status_warning (status, "ISO C does not support %s with the `%%%c' %s format",
- _(long_name), format_char, fki->name);
- else if ((t->std == STD_C99 && !flag_isoc99)
- || (t->std == STD_C94 && !flag_isoc94))
- status_warning (status, "ISO C89 does not support %s with the `%%%c' %s format",
- _(long_name), format_char, fki->name);
+ if (t->std > C_STD_VER)
+ status_warning (status, "%s does not support %s with the `%%%c' %s format",
+ C_STD_NAME (t->std), _(long_name),
+ format_char, fki->name);
}
}
}
@@ -2991,13 +2996,10 @@ check_format_info_main (status, res, info, format_chars, format_length,
&& wanted_type_std > length_chars_std
&& wanted_type_std > fci->std)
{
- if (wanted_type_std == STD_EXT)
- status_warning (status, "ISO C does not support the `%%%s%c' %s format",
- length_chars, format_char, fki->name);
- else if ((wanted_type_std == STD_C99 && !flag_isoc99)
- || (wanted_type_std == STD_C94 && !flag_isoc94))
- status_warning (status, "ISO C89 does not support the `%%%s%c' %s format",
- length_chars, format_char, fki->name);
+ if (wanted_type_std > C_STD_VER)
+ status_warning (status, "%s does not support the `%%%s%c' %s format",
+ C_STD_NAME (wanted_type_std), length_chars,
+ format_char, fki->name);
}
}