Commit 4930c53e by Marek Polacek Committed by Marek Polacek

re PR c++/85258 (ICE with invalid range-based for-loop)

	PR c++/85258
	* constexpr.c (reduced_constant_expression_p): Return false for null
	trees.

	* g++.dg/parse/error61.C: New test.

From-SVN: r259355
parent ed086e7e
2018-04-12 Marek Polacek <polacek@redhat.com>
PR c++/85258
* constexpr.c (reduced_constant_expression_p): Return false for null
trees.
2018-04-11 Marek Polacek <polacek@redhat.com>
PR c++/85032
......
......@@ -1773,6 +1773,9 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
bool
reduced_constant_expression_p (tree t)
{
if (t == NULL_TREE)
return false;
switch (TREE_CODE (t))
{
case PTRMEM_CST:
......@@ -1794,9 +1797,8 @@ reduced_constant_expression_p (tree t)
field = NULL_TREE;
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), i, idx, val)
{
if (!val)
/* We're in the middle of initializing this element. */
return false;
/* If VAL is null, we're in the middle of initializing this
element. */
if (!reduced_constant_expression_p (val))
return false;
if (field)
......
2018-04-12 Marek Polacek <polacek@redhat.com>
PR c++/85258
* g++.dg/parse/error61.C: New test.
2018-04-12 Cesar Philippidis <cesar@codesourcery.com>
* testsuite/libgomp.oacc-c-c++-common/pr84955.c: Revert 259346.
......
// PR c++/85258
// { dg-do compile { target c++11 } }
template<int> void foo()
{
int x[8];
for (int& i, j : x) // { dg-error "multiple" }
i = 0; // { dg-error "local variable" }
}
void bar()
{
foo<0>();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment