invoke.texi ([Wnarrowing]): Update for non-constants in C++11.
2014-08-09 Paolo Carlini <paolo.carlini@oracle.com> * doc/invoke.texi ([Wnarrowing]): Update for non-constants in C++11. gcc/cp 2014-08-09 Paolo Carlini <paolo.carlini@oracle.com> * typeck2.c (check_narrowing): Add tsubst_flags_t parameter, change return type to bool; in C++11 for constants give errors, not pedwarns. * cp-tree.h (check_narrowing): Adjust declaration. * call.c (convert_like_real): Update calls. * semantics.c (finish_compound_literal): Likewise. gcc/testsuite 2014-08-09 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/Wnarrowing1.C: Adjust for errors. * g++.dg/cpp0x/enum29.C: Adjust. /libstdc++-v3 2014-08-09 Paolo Carlini <paolo.carlini@oracle.com> * include/ext/pod_char_traits.h (char_traits<__gnu_cxx:: character<_Value, _Int, _St> >::eof): Fix vs narrowing conversion. From-SVN: r213776
This commit is contained in:
parent
013078982d
commit
6a6bdc3d09
12 changed files with 81 additions and 40 deletions
|
@ -1,3 +1,7 @@
|
|||
2014-08-09 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* doc/invoke.texi ([Wnarrowing]): Update for non-constants in C++11.
|
||||
|
||||
2014-08-09 Roman Gareev <gareevroman@gmail.com>
|
||||
|
||||
* graphite-isl-ast-to-gimple.c:
|
||||
|
@ -20,7 +24,6 @@
|
|||
|
||||
* predict.c (expr_expected_value_1): Remove the redundant assignment.
|
||||
|
||||
|
||||
2014-08-08 Richard Biener <rguenther@suse.de>
|
||||
|
||||
* lto-streamer.h (struct lto_input_block): Make it a class
|
||||
|
@ -289,7 +292,7 @@
|
|||
|
||||
2014-08-07 Marek Polacek <polacek@redhat.com>
|
||||
|
||||
* fold-const.c (fold_binary_loc): Add folding of
|
||||
* fold-const.c (fold_binary_loc): Add folding of
|
||||
(PTR0 - (PTR1 p+ A) -> (PTR0 - PTR1) - A.
|
||||
|
||||
2013-08-07 Ilya Enkovich <ilya.enkovich@intel.com>
|
||||
|
@ -477,10 +480,10 @@
|
|||
2014-08-05 Roman Gareev <gareevroman@gmail.com>
|
||||
|
||||
* graphite-isl-ast-to-gimple.c: Add a new struct ast_build_info.
|
||||
(translate_isl_ast_for_loop): Add checking of the
|
||||
(translate_isl_ast_for_loop): Add checking of the
|
||||
flag_loop_parallelize_all.
|
||||
(ast_build_before_for): New function.
|
||||
(scop_to_isl_ast): Add checking of the
|
||||
(scop_to_isl_ast): Add checking of the
|
||||
flag_loop_parallelize_all.
|
||||
* graphite-dependences.c: Move the defenition of the
|
||||
scop_get_dependences from graphite-optimize-isl.c to this file.
|
||||
|
@ -612,7 +615,8 @@
|
|||
|
||||
2014-08-01 Jan Hubicka <hubicka@ucw.cz>
|
||||
|
||||
* doc/invoke.texi (Wsuggest-final-types, Wsuggest-final-methods): Document.
|
||||
* doc/invoke.texi (Wsuggest-final-types, Wsuggest-final-methods):
|
||||
Document.
|
||||
* ipa-devirt.c: Include hash-map.h
|
||||
(struct polymorphic_call_target_d): Add type_warning and decl_warning.
|
||||
(clear_speculation): Break out of ...
|
||||
|
@ -621,15 +625,16 @@
|
|||
(odr_type_warn_count, decl_warn_count): New structures.
|
||||
(final_warning_record): New structure.
|
||||
(final_warning_records): New static variable.
|
||||
(possible_polymorphic_call_targets): Cleanup handling of speculative info;
|
||||
do not build speculation when user do not care; record info about warnings
|
||||
when asked for.
|
||||
(possible_polymorphic_call_targets): Cleanup handling of
|
||||
speculative info; do not build speculation when user do not care;
|
||||
record info about warnings when asked for.
|
||||
(add_decl_warning): New function.
|
||||
(type_warning_cmp): New function.
|
||||
(decl_warning_cmp): New function.
|
||||
(ipa_devirt): Handle -Wsuggest-final-methods and -Wsuggest-final-types.
|
||||
(gate): Enable pass when warnings are requested.
|
||||
* common.opt (Wsuggest-final-types, Wsuggest-final-methods): New options.
|
||||
* common.opt (Wsuggest-final-types, Wsuggest-final-methods): New
|
||||
options.
|
||||
|
||||
2014-08-02 Trevor Saunders <tsaunders@mozilla.com>
|
||||
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
2014-08-09 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* typeck2.c (check_narrowing): Add tsubst_flags_t parameter, change
|
||||
return type to bool; in C++11 for constants give errors, not pedwarns.
|
||||
* cp-tree.h (check_narrowing): Adjust declaration.
|
||||
* call.c (convert_like_real): Update calls.
|
||||
* semantics.c (finish_compound_literal): Likewise.
|
||||
|
||||
2014-08-08 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* pt.c (lookup_template_class_1): Copy abi_tag.
|
||||
|
|
|
@ -6251,8 +6251,9 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
|
|||
1, false, false, complain);
|
||||
if (sub == error_mark_node)
|
||||
return sub;
|
||||
if (!BRACE_ENCLOSED_INITIALIZER_P (val))
|
||||
check_narrowing (TREE_TYPE (sub), val);
|
||||
if (!BRACE_ENCLOSED_INITIALIZER_P (val)
|
||||
&& !check_narrowing (TREE_TYPE (sub), val, complain))
|
||||
return error_mark_node;
|
||||
CONSTRUCTOR_APPEND_ELT (CONSTRUCTOR_ELTS (new_ctor), NULL_TREE, sub);
|
||||
if (!TREE_CONSTANT (sub))
|
||||
TREE_CONSTANT (new_ctor) = false;
|
||||
|
@ -6480,8 +6481,9 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
|
|||
break;
|
||||
}
|
||||
|
||||
if (convs->check_narrowing)
|
||||
check_narrowing (totype, expr);
|
||||
if (convs->check_narrowing
|
||||
&& !check_narrowing (totype, expr, complain))
|
||||
return error_mark_node;
|
||||
|
||||
if (issue_conversion_warnings)
|
||||
expr = cp_convert_and_check (totype, expr, complain);
|
||||
|
|
|
@ -6214,7 +6214,7 @@ extern int abstract_virtuals_error_sfinae (tree, tree, tsubst_flags_t);
|
|||
extern int abstract_virtuals_error_sfinae (abstract_class_use, tree, tsubst_flags_t);
|
||||
|
||||
extern tree store_init_value (tree, tree, vec<tree, va_gc>**, int);
|
||||
extern void check_narrowing (tree, tree);
|
||||
extern bool check_narrowing (tree, tree, tsubst_flags_t);
|
||||
extern tree digest_init (tree, tree, tsubst_flags_t);
|
||||
extern tree digest_init_flags (tree, tree, int);
|
||||
extern tree digest_nsdmi_init (tree, tree);
|
||||
|
|
|
@ -2597,8 +2597,8 @@ finish_compound_literal (tree type, tree compound_literal,
|
|||
compound_literal = reshape_init (type, compound_literal, complain);
|
||||
if (SCALAR_TYPE_P (type)
|
||||
&& !BRACE_ENCLOSED_INITIALIZER_P (compound_literal)
|
||||
&& (complain & tf_warning_or_error))
|
||||
check_narrowing (type, compound_literal);
|
||||
&& !check_narrowing (type, compound_literal, complain))
|
||||
return error_mark_node;
|
||||
if (TREE_CODE (type) == ARRAY_TYPE
|
||||
&& TYPE_DOMAIN (type) == NULL_TREE)
|
||||
{
|
||||
|
|
|
@ -842,27 +842,31 @@ store_init_value (tree decl, tree init, vec<tree, va_gc>** cleanups, int flags)
|
|||
}
|
||||
|
||||
|
||||
/* Give errors about narrowing conversions within { }. */
|
||||
/* Give diagnostic about narrowing conversions within { }. */
|
||||
|
||||
void
|
||||
check_narrowing (tree type, tree init)
|
||||
bool
|
||||
check_narrowing (tree type, tree init, tsubst_flags_t complain)
|
||||
{
|
||||
tree ftype = unlowered_expr_type (init);
|
||||
bool ok = true;
|
||||
REAL_VALUE_TYPE d;
|
||||
|
||||
if (!warn_narrowing || !ARITHMETIC_TYPE_P (type))
|
||||
return;
|
||||
if (((!warn_narrowing || !(complain & tf_warning))
|
||||
&& cxx_dialect == cxx98)
|
||||
|| !ARITHMETIC_TYPE_P (type))
|
||||
return ok;
|
||||
|
||||
if (BRACE_ENCLOSED_INITIALIZER_P (init)
|
||||
&& TREE_CODE (type) == COMPLEX_TYPE)
|
||||
{
|
||||
tree elttype = TREE_TYPE (type);
|
||||
if (CONSTRUCTOR_NELTS (init) > 0)
|
||||
check_narrowing (elttype, CONSTRUCTOR_ELT (init, 0)->value);
|
||||
ok &= check_narrowing (elttype, CONSTRUCTOR_ELT (init, 0)->value,
|
||||
complain);
|
||||
if (CONSTRUCTOR_NELTS (init) > 1)
|
||||
check_narrowing (elttype, CONSTRUCTOR_ELT (init, 1)->value);
|
||||
return;
|
||||
ok &= check_narrowing (elttype, CONSTRUCTOR_ELT (init, 1)->value,
|
||||
complain);
|
||||
return ok;
|
||||
}
|
||||
|
||||
init = maybe_constant_value (fold_non_dependent_expr_sfinae (init, tf_none));
|
||||
|
@ -917,15 +921,27 @@ check_narrowing (tree type, tree init)
|
|||
|
||||
if (!ok)
|
||||
{
|
||||
if (cxx_dialect >= cxx11)
|
||||
pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
|
||||
"narrowing conversion of %qE from %qT to %qT inside { }",
|
||||
init, ftype, type);
|
||||
else
|
||||
if (cxx_dialect == cxx98)
|
||||
warning_at (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
|
||||
"narrowing conversion of %qE from %qT to %qT inside { } "
|
||||
"is ill-formed in C++11", init, ftype, type);
|
||||
else if (!TREE_CONSTANT (init))
|
||||
{
|
||||
if (complain & tf_warning_or_error)
|
||||
{
|
||||
pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing,
|
||||
"narrowing conversion of %qE from %qT to %qT inside { }",
|
||||
init, ftype, type);
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
else if (complain & tf_error)
|
||||
error_at (EXPR_LOC_OR_LOC (init, input_location),
|
||||
"narrowing conversion of %qE from %qT to %qT inside { }",
|
||||
init, ftype, type);
|
||||
}
|
||||
|
||||
return cxx_dialect == cxx98 || ok;
|
||||
}
|
||||
|
||||
/* Process the initializer INIT for a variable of type TYPE, emitting
|
||||
|
|
|
@ -2622,10 +2622,10 @@ int i = @{ 2.2 @}; // error: narrowing from double to int
|
|||
|
||||
This flag is included in @option{-Wall} and @option{-Wc++11-compat}.
|
||||
|
||||
With @option{-std=c++11}, @option{-Wno-narrowing} suppresses the diagnostic
|
||||
required by the standard. Note that this does not affect the meaning
|
||||
of well-formed code; narrowing conversions are still considered
|
||||
ill-formed in SFINAE context.
|
||||
With @option{-std=c++11}, @option{-Wno-narrowing} suppresses for
|
||||
non-constants the diagnostic required by the standard. Note that this
|
||||
does not affect the meaning of well-formed code; narrowing conversions
|
||||
are still considered ill-formed in SFINAE context.
|
||||
|
||||
@item -Wnoexcept @r{(C++ and Objective-C++ only)}
|
||||
@opindex Wnoexcept
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2014-08-09 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* g++.dg/cpp0x/Wnarrowing1.C: Adjust for errors.
|
||||
* g++.dg/cpp0x/enum29.C: Adjust.
|
||||
|
||||
2014-08-08 Richard Biener <rguenther@suse.de>
|
||||
|
||||
* gcc.dg/strlenopt-8.c: Remove XFAIL.
|
||||
|
|
|
@ -9,10 +9,10 @@ struct X
|
|||
|
||||
int f() { return __INT_MAX__; }
|
||||
|
||||
signed char a { __INT_MAX__ }; // { dg-warning "narrowing conversion" }
|
||||
signed char a { __INT_MAX__ }; // { dg-error "narrowing conversion" }
|
||||
signed char b { f() }; // { dg-warning "narrowing conversion" }
|
||||
signed char c { X{} }; // { dg-warning "narrowing conversion" }
|
||||
signed char c { X{} }; // { dg-error "narrowing conversion" }
|
||||
|
||||
signed char ar[] { __INT_MAX__ }; // { dg-warning "narrowing conversion" }
|
||||
signed char ar[] { __INT_MAX__ }; // { dg-error "narrowing conversion" }
|
||||
signed char br[] { f() }; // { dg-warning "narrowing conversion" }
|
||||
signed char cr[] { X{} }; // { dg-warning "narrowing conversion" }
|
||||
signed char cr[] { X{} }; // { dg-error "narrowing conversion" }
|
||||
|
|
|
@ -51,8 +51,6 @@ enum F5 : int { f5 = X5() };
|
|||
enum G0 : signed char { g0 = X0() };
|
||||
enum G1 : signed char { g1 = X1() };
|
||||
enum G2 : signed char { g2 = X2() }; // { dg-error "narrowing" }
|
||||
// { dg-warning "overflow" "" { target *-*-* } 53 }
|
||||
enum G3 : signed char { g3 = X3() }; // { dg-error "narrowing" }
|
||||
// { dg-warning "overflow" "" { target *-*-* } 55 }
|
||||
enum G4 : signed char { g4 = X4() }; // { dg-error "narrowing" }
|
||||
enum G5 : signed char { g5 = X5() }; // { dg-error "ambiguous" }
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2014-08-08 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/ext/pod_char_traits.h (char_traits<__gnu_cxx::
|
||||
character<_Value, _Int, _St> >::eof): Fix vs narrowing conversion.
|
||||
|
||||
2014-08-09 François Dumont <fdumont@gcc.gnu.org>
|
||||
|
||||
PR libstdc++/61667
|
||||
|
|
|
@ -177,7 +177,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
static int_type
|
||||
eof()
|
||||
{
|
||||
int_type __r = { -1 };
|
||||
int_type __r = { static_cast<typename __gnu_cxx::__conditional_type
|
||||
<std::__is_integer<int_type>::__value,
|
||||
int_type, int>::__type>(-1) };
|
||||
return __r;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue