diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d8416864178..428ec29b107 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-01-14 Jason Merrill + PR c++/46903 + * typeck2.c (check_narrowing): Only check arithmetic types. + PR c++/46688 * tree.c (build_vec_init_expr): Handle flexible array properly. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 3d6593929a1..82218f0b806 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -717,6 +717,9 @@ check_narrowing (tree type, tree init) bool ok = true; REAL_VALUE_TYPE d; + if (!ARITHMETIC_TYPE_P (type)) + return; + init = maybe_constant_value (init); if (TREE_CODE (type) == INTEGER_TYPE diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9851be44253..fa8f110964f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-01-14 Jason Merrill + * g++.dg/cpp0x/constexpr-regress1.C: New. + * g++.dg/ext/flexary2.C: New. 2011-01-14 Richard Guenther diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-regress1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-regress1.C new file mode 100644 index 00000000000..a6fe3999c98 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-regress1.C @@ -0,0 +1,10 @@ +// PR c++/46903 +// This isn't C++0x code, but it was breaking in C++0x mode. +// { dg-options -std=c++0x } + +struct A {}; +struct B { + void *(*a)(); +}; +template void *CreateA() {} +B b = {CreateA};