Commit 91d01bf4 by Jason Merrill Committed by Jason Merrill

PR c++/78337 - ICE on invalid with generic lambda

	* semantics.c (process_outer_var_ref): Check if containing_function
	is null.  Move inform call under complain test.

From-SVN: r244340
parent 73e32c47
2017-01-11 Jason Merrill <jason@redhat.com>
PR c++/78337 - ICE on invalid with generic lambda
* semantics.c (process_outer_var_ref): Check if containing_function
is null. Move inform call under complain test.
2017-01-11 Nathan Sidwell <nathan@acm.org> 2017-01-11 Nathan Sidwell <nathan@acm.org>
PR c++/77812 PR c++/77812
......
...@@ -3278,6 +3278,8 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain) ...@@ -3278,6 +3278,8 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain)
2. a non-lambda function, or 2. a non-lambda function, or
3. a non-default capturing lambda function. */ 3. a non-default capturing lambda function. */
while (context != containing_function while (context != containing_function
/* containing_function can be null with invalid generic lambdas. */
&& containing_function
&& LAMBDA_FUNCTION_P (containing_function)) && LAMBDA_FUNCTION_P (containing_function))
{ {
tree closure = DECL_CONTEXT (containing_function); tree closure = DECL_CONTEXT (containing_function);
...@@ -3365,10 +3367,13 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain) ...@@ -3365,10 +3367,13 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain)
else else
{ {
if (complain & tf_error) if (complain & tf_error)
error (VAR_P (decl) {
? G_("use of local variable with automatic storage from containing function") error (VAR_P (decl)
: G_("use of parameter from containing function")); ? G_("use of local variable with automatic storage from "
inform (DECL_SOURCE_LOCATION (decl), "%q#D declared here", decl); "containing function")
: G_("use of parameter from containing function"));
inform (DECL_SOURCE_LOCATION (decl), "%q#D declared here", decl);
}
return error_mark_node; return error_mark_node;
} }
return decl; return decl;
......
// PR c++/78337
// { dg-do compile { target c++14 } }
struct X {
static constexpr int foo (int b) {
return b;
}
};
template<int>
using Void = void;
template<typename F,typename A>
auto
bar(F f, A a) -> decltype( ( f(a) , 0 ) ) // { dg-error "no match" }
{ return {}; }
int main() {
//constexpr
int f = 3;
(void)f;
auto l = [](auto of_type_X)->
Void<(decltype(of_type_X)::foo(f), 0)> // { dg-error "variable" }
{return;};
bar(l , X{}); // { dg-error "no match" }
}
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