diff options
| author | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2009-04-20 22:12:52 +0000 |
|---|---|---|
| committer | Manuel López-Ibáñez <manu@gcc.gnu.org> | 2009-04-20 22:12:52 +0000 |
| commit | 9c650d90abf690ca3d66ece71c69778c0eec05b7 (patch) | |
| tree | fd9591c53025bec4c451b0619535e1e5e33a2a4d /gcc/cp | |
| parent | 37041295f5ded2ee556e2b98f28402b6f35d1459 (diff) | |
| download | gcc-9c650d90abf690ca3d66ece71c69778c0eec05b7.zip gcc-9c650d90abf690ca3d66ece71c69778c0eec05b7.tar.gz gcc-9c650d90abf690ca3d66ece71c69778c0eec05b7.tar.bz2 | |
re PR c++/13358 (long long and C++ do not mix well)
2009-04-21 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
PR c++/13358
* doc/invoke.texi (-Wlong-long): Update description.
* c-lex (interpret_integer): Only warn if there was no previous
overflow and -Wlong-long is enabled.
* c-decl.c (declspecs_add_type): Drop redundant flags.
* c.opt (Wlong-long): Init to -1.
* c-opts.c (sanitize_cpp_opts): Synchronize cpp's warn_long_long
and front-end warn_long_long. Wlong-long only depends on other
flags if it is uninitialized.
* c-parser.c (disable_extension_diagnostics): warn_long_long is
the same for CPP and FE.
(restore_extension_diagnostics): Likewise.
libcpp/
* init.c (cpp_create_reader): Wlong_long is disabled by default.
* expr.c (cpp_classify_number): Give different messages for C and
C++ front-ends.
cp/
* parser.c (cp_parser_check_decl_spec): Drop redundant flags.
* error.c (pedwarn_cxx98): New.
* cp-tree.h (pedwarn_cxx98): Declare.
testsuite/
* gcc.dg/wtr-int-type-1.c: Use two dg-warning to match two
messages. Test for "long long" in system headers.
* gcc.dg/c99-longlong-2.c: New.
* g++.dg/warn/pr13358.C: New.
* g++.dg/warn/pr13358-2.C: New.
* g++.dg/warn/pr13358-3.C: New.
* g++.dg/warn/pr13358-4.C: New.
From-SVN: r146459
Diffstat (limited to 'gcc/cp')
| -rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
| -rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
| -rw-r--r-- | gcc/cp/error.c | 19 | ||||
| -rw-r--r-- | gcc/cp/parser.c | 7 |
4 files changed, 30 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 15f83d9..df0a91a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2009-04-21 Manuel Lopez-Ibanez <manu@gcc.gnu.org> + + PR c++/13358 + * parser.c (cp_parser_check_decl_spec): Drop redundant flags. + * error.c (pedwarn_cxx98): New. + * cp-tree.h (pedwarn_cxx98): Declare. + 2009-04-20 Le-Chun Wu <lcwu@google.com> PR c++/39803 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e3fed77..c80037d 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4462,6 +4462,7 @@ extern const char *class_key_or_enum_as_string (tree); extern void print_instantiation_context (void); extern void maybe_warn_variadic_templates (void); extern void maybe_warn_cpp0x (const char *); +extern bool pedwarn_cxx98 (location_t, int, const char *, ...) ATTRIBUTE_GCC_CXXDIAG(3,4); /* in except.c */ extern void init_exception_processing (void); diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 9c2e7e5..4e7e9ec 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2804,3 +2804,22 @@ maybe_warn_variadic_templates (void) { maybe_warn_cpp0x ("variadic templates"); } + + +/* Issue an ISO C++98 pedantic warning at LOCATION, conditional on + option OPT with text GMSGID. Use this function to report + diagnostics for constructs that are invalid C++98, but valid + C++0x. */ +bool +pedwarn_cxx98 (location_t location, int opt, const char *gmsgid, ...) +{ + diagnostic_info diagnostic; + va_list ap; + + va_start (ap, gmsgid); + diagnostic_set_info (&diagnostic, gmsgid, &ap, location, + (cxx_dialect == cxx98) ? DK_PEDWARN : DK_WARNING); + diagnostic.option_index = opt; + va_end (ap); + return report_diagnostic (&diagnostic); +} diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b640033..b6b8bf5 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2167,10 +2167,9 @@ cp_parser_check_decl_spec (cp_decl_specifier_seq *decl_specs, { if (count > 2) error ("%H%<long long long%> is too long for GCC", &location); - else if (pedantic && !in_system_header && warn_long_long - && cxx_dialect == cxx98) - pedwarn (location, OPT_Wlong_long, - "ISO C++ 1998 does not support %<long long%>"); + else + pedwarn_cxx98 (location, OPT_Wlong_long, + "ISO C++ 1998 does not support %<long long%>"); } else if (count > 1) { |
