diff options
author | Jason Merrill <jason@gcc.gnu.org> | 2011-11-02 16:16:43 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-11-02 16:16:43 -0400 |
commit | 25339f1097a119662a4989964f32143ad44edbd3 (patch) | |
tree | 883396e26db08ff838de9608ab092c69fcce8870 /gcc/c-family | |
parent | 24748eb48e44ae268686a795149edc03af0e4310 (diff) | |
download | gcc-25339f1097a119662a4989964f32143ad44edbd3.tar.gz |
re PR c++/50810 (c++0x-compat does not warn about narrowing conversions)
PR c++/50810
gcc/c-family
* c-opts.c (c_common_handle_option): Enable -Wnarrowing as part
of -Wall; include -Wnarrowing in -Wc++0x-compat; adjust default
Wnarrowing for C++0x and C++98.
* c.opt ([Wnarrowing]): Update.
gcc/cp
* typeck2.c (check_narrowing): Adjust OPT_Wnarrowing diagnostics.
(digest_init_r): Call check_narrowing irrespective of the C++ dialect.
* decl.c (check_initializer): Likewise.
* semantics.c (finish_compound_literal): Likewise.
gcc/
* configure.ac: Add -Wno-narrowing to warning options.
libcpp/
* configure.ac: Add -Wno-narrowing to warning options.
From-SVN: r180794
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/c-family/c-opts.c | 18 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 4 |
3 files changed, 25 insertions, 5 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 472ed282d5e..4a452c34951 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,11 @@ +2011-11-02 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/50810 + * c-opts.c (c_common_handle_option): Enable -Wnarrowing as part + of -Wall; include -Wnarrowing in -Wc++0x-compat; adjust default + Wnarrowing for C++0x and C++98. + * c.opt ([Wnarrowing]): Update. + 2011-11-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/44277 diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index b56aec79906..465bce35de3 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -406,6 +406,7 @@ c_common_handle_option (size_t scode, const char *arg, int value, warn_reorder = value; warn_cxx0x_compat = value; warn_delnonvdtor = value; + warn_narrowing = value; } cpp_opts->warn_trigraphs = value; @@ -436,6 +437,10 @@ c_common_handle_option (size_t scode, const char *arg, int value, cpp_opts->warn_cxx_operator_names = value; break; + case OPT_Wc__0x_compat: + warn_narrowing = value; + break; + case OPT_Wdeprecated: cpp_opts->cpp_warn_deprecated = value; break; @@ -997,10 +1002,17 @@ c_common_post_options (const char **pfilename) if (warn_implicit_function_declaration == -1) warn_implicit_function_declaration = flag_isoc99; - /* If we're allowing C++0x constructs, don't warn about C++0x - compatibility problems. */ if (cxx_dialect == cxx0x) - warn_cxx0x_compat = 0; + { + /* If we're allowing C++0x constructs, don't warn about C++98 + identifiers which are keywords in C++0x. */ + warn_cxx0x_compat = 0; + + if (warn_narrowing == -1) + warn_narrowing = 1; + } + else if (warn_narrowing == -1) + warn_narrowing = 0; if (flag_preprocess_only) { diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 438b8b003e9..0d7dc88b1ca 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -494,8 +494,8 @@ C ObjC C++ ObjC++ Warning Warn about use of multi-character character constants Wnarrowing -C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(1) --Wno-narrowing In C++0x mode, ignore ill-formed narrowing conversions within { } +C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(-1) +Warn about narrowing conversions within { } that are ill-formed in C++11 Wnested-externs C ObjC Var(warn_nested_externs) Warning |