Commit 44b2dc6c by Jason Merrill Committed by Jason Merrill

call.c (type_decays_to): Check MAYBE_CLASS_TYPE_P instead of CLASS_TYPE_P.

	* call.c (type_decays_to): Check MAYBE_CLASS_TYPE_P instead of
	CLASS_TYPE_P.
	* parser.c (cp_parser_lambda_expression): Complain about lambda in
	unevaluated context.
	* pt.c (iterative_hash_template_arg): Don't crash on lambda.

From-SVN: r158277
parent 4867a0c6
2010-04-13 Jason Merrill <jason@redhat.com>
* call.c (type_decays_to): Check MAYBE_CLASS_TYPE_P instead of
CLASS_TYPE_P.
* parser.c (cp_parser_lambda_expression): Complain about lambda in
unevaluated context.
* pt.c (iterative_hash_template_arg): Don't crash on lambda.
2010-04-12 Jason Merrill <jason@redhat.com>
PR c++/43641
......
......@@ -2263,7 +2263,7 @@ type_decays_to (tree type)
return build_pointer_type (TREE_TYPE (type));
if (TREE_CODE (type) == FUNCTION_TYPE)
return build_pointer_type (type);
if (!CLASS_TYPE_P (type))
if (!MAYBE_CLASS_TYPE_P (type))
type = cv_unqualified (type);
return type;
}
......
......@@ -7081,6 +7081,10 @@ cp_parser_lambda_expression (cp_parser* parser)
LAMBDA_EXPR_LOCATION (lambda_expr)
= cp_lexer_peek_token (parser->lexer)->location;
if (cp_unevaluated_operand)
error_at (LAMBDA_EXPR_LOCATION (lambda_expr),
"lambda-expression in unevaluated context");
/* We may be in the middle of deferred access check. Disable
it now. */
push_deferring_access_checks (dk_no_deferred);
......
......@@ -1563,6 +1563,12 @@ iterative_hash_template_arg (tree arg, hashval_t val)
val = iterative_hash_template_arg (TREE_TYPE (arg), val);
return iterative_hash_template_arg (TYPE_DOMAIN (arg), val);
case LAMBDA_EXPR:
/* A lambda can't appear in a template arg, but don't crash on
erroneous input. */
gcc_assert (errorcount > 0);
return val;
default:
switch (tclass)
{
......
2010-04-13 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/lambda/lambda-deduce2.C: Remove.
* g++.dg/cpp0x/lambda/lambda-uneval.C: New.
2010-04-13 Manuel López-Ibáñez <manu@gcc.gnu.org>
* gcc.dg/cpp/cpp.exp: Test also c-c++-common/cpp.
......
// Test that cv-quals are dropped from non-class return type
// { dg-options "-std=c++0x" }
template <class T, class U>
struct assert_same_type;
template <class T>
struct assert_same_type<T,T> { };
struct A
{
int i;
};
extern const int i;
assert_same_type <decltype ([]{ return i; }()), int> x;
// 5.1.2/2: A lambda-expression shall not appear in an unevaluated operand.
// { dg-options "-std=c++0x" }
template <class T>
struct A { };
A<decltype([]{ return 1; }())> a; // { dg-error "lambda.*unevaluated context" }
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