diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2011-10-23 20:59:43 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2011-10-23 20:59:43 +0000 |
commit | 5f53c2438d7ab612645c5355a344e7fbf483bdf3 (patch) | |
tree | 6419cf048cf3419e6cced14babbb3920789c4edf | |
parent | be98aaf0bccea7960914007a08ca822713f5c60d (diff) | |
download | gcc-5f53c2438d7ab612645c5355a344e7fbf483bdf3.zip gcc-5f53c2438d7ab612645c5355a344e7fbf483bdf3.tar.gz gcc-5f53c2438d7ab612645c5355a344e7fbf483bdf3.tar.bz2 |
re PR c++/50841 (bootstrap failure: narrowing conversion of '-0x00000000000000001' from 'int' in tree-object-size.c)
/c-family
2011-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50841
Revert:
2011-10-23 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.
/cp
2011-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50841
Revert:
2011-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50810
* 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.
/testsuite
2011-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50841
Revert:
2011-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50810
* g++.dg/cpp0x/warn_cxx0x2.C: New.
* g++.dg/cpp0x/warn_cxx0x3.C: Likewise.
2011-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50841
Revert:
2011-10-23 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50810
* doc/invoke.texi ([-Wnarrowing], [-Wc++0x-compat]): Update.
From-SVN: r180348
-rw-r--r-- | gcc/c-family/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/c-family/c-opts.c | 18 | ||||
-rw-r--r-- | gcc/c-family/c.opt | 4 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/cp/decl.c | 2 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 8 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/warn_cxx0x2.C | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/warn_cxx0x3.C | 4 |
11 files changed, 49 insertions, 39 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9cd0b83..d1c2c49 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,5 +1,17 @@ 2011-10-23 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/50841 + Revert: + 2011-10-23 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-10-23 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 diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 14e4933..6869d5c 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -406,7 +406,6 @@ 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; @@ -437,10 +436,6 @@ 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; @@ -1002,17 +997,10 @@ 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) - { - /* 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; + warn_cxx0x_compat = 0; if (flag_preprocess_only) { diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 0b9e44a..bfc1a7c 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -490,8 +490,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) Warning -Warn about ill-formed narrowing conversions within { } +C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(1) +-Wno-narrowing In C++0x mode, ignore ill-formed narrowing conversions within { } Wnested-externs C ObjC Var(warn_nested_externs) Warning diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index de5fab9..e48091f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,17 @@ 2011-10-23 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/50841 + Revert: + 2011-10-23 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/50810 + * 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. + +2011-10-23 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/50810 * typeck2.c (check_narrowing): Adjust OPT_Wnarrowing diagnostics. (digest_init_r): Call check_narrowing irrespective of the C++ dialect. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index f1ecca2..a21cf46 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5523,7 +5523,7 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) else { init = reshape_init (type, init, tf_warning_or_error); - if (SCALAR_TYPE_P (type)) + if (cxx_dialect >= cxx0x && SCALAR_TYPE_P (type)) check_narrowing (type, init); } } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9fec334..42195be 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2369,7 +2369,7 @@ finish_compound_literal (tree type, tree compound_literal, && check_array_initializer (NULL_TREE, type, compound_literal)) return error_mark_node; compound_literal = reshape_init (type, compound_literal, complain); - if (SCALAR_TYPE_P (type) + if (cxx_dialect >= cxx0x && SCALAR_TYPE_P (type) && !BRACE_ENCLOSED_INITIALIZER_P (compound_literal)) check_narrowing (type, compound_literal); if (TREE_CODE (type) == ARRAY_TYPE diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 76006b6..0cb1104 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -803,10 +803,8 @@ check_narrowing (tree type, tree init) } if (!ok) - emit_diagnostic ((cxx_dialect != cxx98) ? DK_PEDWARN : DK_WARNING, - input_location, OPT_Wnarrowing, - "narrowing conversion of %qE from %qT to %qT inside { }", - init, ftype, type); + pedwarn (input_location, OPT_Wnarrowing, "narrowing conversion of %qE " + "from %qT to %qT inside { }", init, ftype, type); } /* Process the initializer INIT for a variable of type TYPE, emitting @@ -903,7 +901,7 @@ digest_init_r (tree type, tree init, bool nested, int flags, { tree *exp; - if (nested) + if (cxx_dialect != cxx98 && nested) check_narrowing (type, init); init = convert_for_initialization (0, type, init, flags, ICR_INIT, NULL_TREE, 0, diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 42f0651..9791a8f 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -2365,18 +2365,17 @@ an instance of a derived class through a pointer to a base class if the base class does not have a virtual destructor. This warning is enabled by @option{-Wall}. -@item -Wnarrowing @r{(C++ and Objective-C++ only)} +@item -Wno-narrowing @r{(C++ and Objective-C++ only)} @opindex Wnarrowing @opindex Wno-narrowing -Warn when a narrowing conversion occurs within @samp{@{ @}}, e.g. +With -std=c++0x, suppress the diagnostic required by the standard for +narrowing conversions within @samp{@{ @}}, e.g. @smallexample int i = @{ 2.2 @}; // error: narrowing from double to int @end smallexample -This flag is included in @option{-Wall} and @option{-Wc++0x-compat}. -With -std=c++0x, @option{-Wno-narrowing} suppresses the diagnostic -required by the standard. +This flag can be useful for compiling valid C++98 code in C++0x mode @item -Wnoexcept @r{(C++ and Objective-C++ only)} @opindex Wnoexcept @@ -4067,8 +4066,7 @@ ISO C and ISO C++, e.g.@: request for implicit conversion from @item -Wc++0x-compat @r{(C++ and Objective-C++ only)} Warn about C++ constructs whose meaning differs between ISO C++ 1998 and ISO C++ 200x, e.g., identifiers in ISO C++ 1998 that will become keywords -in ISO C++ 200x. This warning turns on @option{-Wnarrowing} and is -enabled by @option{-Wall}. +in ISO C++ 200x. This warning is enabled by @option{-Wall}. @item -Wcast-qual @opindex Wcast-qual diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0393eec..5e5ef94 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,15 @@ 2011-10-23 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/50841 + Revert: + 2011-10-23 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/50810 + * g++.dg/cpp0x/warn_cxx0x2.C: New. + * g++.dg/cpp0x/warn_cxx0x3.C: Likewise. + +2011-10-23 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/50810 * g++.dg/cpp0x/warn_cxx0x2.C: New. * g++.dg/cpp0x/warn_cxx0x3.C: Likewise. diff --git a/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x2.C b/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x2.C deleted file mode 100644 index 1fc9c6b..0000000 --- a/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x2.C +++ /dev/null @@ -1,4 +0,0 @@ -// PR c++/50810 -// { dg-options "-std=gnu++98 -Wc++0x-compat" } - -signed char data[] = { 0xff }; // { dg-warning "narrowing" } diff --git a/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x3.C b/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x3.C deleted file mode 100644 index 91faf12..0000000 --- a/gcc/testsuite/g++.dg/cpp0x/warn_cxx0x3.C +++ /dev/null @@ -1,4 +0,0 @@ -// PR c++/50810 -// { dg-options "-std=gnu++98 -Wc++0x-compat -Wno-narrowing" } - -signed char data[] = { 0xff }; |