mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-03 07:00:27 +08:00
re PR c++/36963 (Bogus narrowing conversion error in initializer list with -std=c++0x)
PR c++/36963 * typeck2.c (check_narrowing): Allow narrowing conversion from an explicit floating-point constant. From-SVN: r138652
This commit is contained in:
parent
52fb73c2bf
commit
a53b09faa5
@ -1,5 +1,9 @@
|
||||
2008-08-04 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/36963
|
||||
* typeck2.c (check_narrowing): Allow narrowing conversion
|
||||
from an explicit floating-point constant.
|
||||
|
||||
PR c++/37006
|
||||
* pt.c (tsubst_decl): Leave DECL_INITIAL set on deleted
|
||||
instantiations.
|
||||
|
@ -640,9 +640,13 @@ check_narrowing (tree type, tree init)
|
||||
tree ftype = TREE_TYPE (init);
|
||||
bool ok = true;
|
||||
REAL_VALUE_TYPE d;
|
||||
bool was_decl = false;
|
||||
|
||||
if (DECL_P (init))
|
||||
init = decl_constant_value (init);
|
||||
{
|
||||
was_decl = true;
|
||||
init = decl_constant_value (init);
|
||||
}
|
||||
|
||||
if (TREE_CODE (type) == INTEGER_TYPE
|
||||
&& TREE_CODE (ftype) == REAL_TYPE)
|
||||
@ -664,7 +668,12 @@ check_narrowing (tree type, tree init)
|
||||
if (TREE_CODE (init) == REAL_CST)
|
||||
{
|
||||
d = TREE_REAL_CST (init);
|
||||
if (exact_real_truncate (TYPE_MODE (type), &d))
|
||||
if (exact_real_truncate (TYPE_MODE (type), &d)
|
||||
/* FIXME: As a temporary workaround for PR 36963, don't
|
||||
complain about narrowing from a floating
|
||||
literal. Hopefully this will be resolved at the
|
||||
September 2008 C++ meeting. */
|
||||
|| !was_decl)
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
@ -19,3 +19,7 @@ C c2 = { 1.1, 2 }; // { dg-error "narrowing" }
|
||||
|
||||
int j { 1 }; // initialize to 1
|
||||
int k {}; // initialize to 0
|
||||
|
||||
// PR c++/39693
|
||||
double d = 1.1;
|
||||
float fa[] = { d, 1.1 }; // { dg-error "narrowing conversion of 'd'" }
|
||||
|
Loading…
x
Reference in New Issue
Block a user