From: Marek Polacek Date: Wed, 4 Jan 2017 17:47:04 +0000 (+0000) Subject: re PR c++/77545 (ICE on valid C++11 code: in potential_constant_expression_1, at... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=baf9ebc8cc9c34becea5be1146c48e2cb99d2ea5;p=gcc.git re PR c++/77545 (ICE on valid C++11 code: in potential_constant_expression_1, at cp/constexpr.c:5480) PR c++/77545 PR c++/77284 * constexpr.c (potential_constant_expression_1): Handle CLEANUP_STMT. * g++.dg/cpp0x/range-for32.C: New test. * g++.dg/cpp0x/range-for33.C: New test. From-SVN: r244062 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 71aada7970c..48061a02f8b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2017-01-04 Marek Polacek + + PR c++/77545 + PR c++/77284 + * constexpr.c (potential_constant_expression_1): Handle CLEANUP_STMT. + 2017-01-04 Nathan Sidwell PR c++/66735 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 1e83b0b0b86..a3dec6884ab 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5661,6 +5661,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, /* We can see these in statement-expressions. */ return true; + case CLEANUP_STMT: case EMPTY_CLASS_EXPR: return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8ad30173c77..d8ff32fb05e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-01-04 Marek Polacek + + PR c++/77545 + PR c++/77284 + * g++.dg/cpp0x/range-for32.C: New test. + * g++.dg/cpp0x/range-for33.C: New test. + 2017-01-04 David Malcolm * gcc.dg/Wmissing-braces-fixits.c: New test case. diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for32.C b/gcc/testsuite/g++.dg/cpp0x/range-for32.C new file mode 100644 index 00000000000..375a7073a41 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for32.C @@ -0,0 +1,16 @@ +// PR c++/77545 +// { dg-do compile { target c++11 } } +// { dg-options "-Wno-pedantic" } + +template < typename T > struct A +{ + A (); + ~A (); + T t; +}; + +void f (A < int > a) +{ + for (auto x : (A[]) { a }) + ; +} diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for33.C b/gcc/testsuite/g++.dg/cpp0x/range-for33.C new file mode 100644 index 00000000000..206f36e481e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for33.C @@ -0,0 +1,14 @@ +// PR c++/77284 +// { dg-do compile { target c++11 } } + +#include + +struct A +{ + ~A () {} +}; + +void foo (A & v) +{ + for (A a : { v }) {}; +}