re PR c++/66387 (ICE in make_decl_rtl with lambda)

PR c++/66387
	* semantics.c (process_outer_var_ref): Make sure the value is
	actually constant before returning it.
	* typeck.c (cp_build_array_ref): Allow subscripting non-lvalue
	array.

From-SVN: r224287
This commit is contained in:
Jason Merrill 2015-06-09 11:27:01 -04:00 committed by Jason Merrill
parent ebcf592c84
commit 5af874fb65
4 changed files with 29 additions and 10 deletions

View File

@ -1,3 +1,11 @@
2015-06-09 Jason Merrill <jason@redhat.com>
PR c++/66387
* semantics.c (process_outer_var_ref): Make sure the value is
actually constant before returning it.
* typeck.c (cp_build_array_ref): Allow subscripting non-lvalue
array.
2015-06-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/65815

View File

@ -3128,7 +3128,11 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain)
form, so wait until instantiation time. */
return decl;
else if (decl_constant_var_p (decl))
return scalar_constant_value (decl);
{
tree t = maybe_constant_value (convert_from_reference (decl));
if (TREE_CONSTANT (t))
return t;
}
}
if (parsing_nsdmi ())

View File

@ -3141,15 +3141,6 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
return error_mark_node;
}
if (!lvalue_p (array))
{
if (complain & tf_error)
pedwarn (loc, OPT_Wpedantic,
"ISO C++ forbids subscripting non-lvalue array");
else
return error_mark_node;
}
/* Note in C++ it is valid to subscript a `register' array, since
it is valid to take the address of something with that
storage specification. */

View File

@ -0,0 +1,16 @@
// PR c++/66387
// { dg-do compile { target c++11 } }
template <typename T>
void
bar (T x)
{
x ();
}
void
foo ()
{
constexpr int a[1] = { 1 };
bar ([&]{ return a[0]; });
}