this-f names a member function, which isn't an addressable lvalue. Give a
helpful error instead of crashing. The first hunk makes the error range
cover the whole expression.
PR c++/106858
gcc/cp/ChangeLog:
* parser.cc (cp_parser_omp_var_list_no_open): Pass the
initial token location down.
* semantics.cc (finish_omp_clauses): Check
invalid_nonstatic_memfn_p.
* typeck.cc (invalid_nonstatic_memfn_p): Handle null TREE_TYPE.
gcc/testsuite/ChangeLog:
* g++.dg/gomp/map-3.C: New test.
cp_id_kind idk = CP_ID_KIND_NONE;
cp_lexer_consume_token (parser->lexer);
decl = convert_from_reference (decl);
- decl
- = cp_parser_postfix_dot_deref_expression (parser, ttype,
- decl, false,
- &idk, loc);
+ decl = (cp_parser_postfix_dot_deref_expression
+ (parser, ttype, cp_expr (decl, token->location),
+ false, &idk, loc));
}
/* FALLTHROUGH. */
case OMP_CLAUSE_AFFINITY:
t = TREE_OPERAND (t, 1);
STRIP_NOPS (t);
}
+ if (TREE_CODE (t) == COMPONENT_REF
+ && invalid_nonstatic_memfn_p (EXPR_LOCATION (t), t,
+ tf_warning_or_error))
+ remove = true;
indir_component_ref_p = false;
if (TREE_CODE (t) == COMPONENT_REF
&& (TREE_CODE (TREE_OPERAND (t, 0)) == INDIRECT_REF
return false;
if (is_overloaded_fn (expr) && !really_overloaded_fn (expr))
expr = get_first_fn (expr);
- if (DECL_NONSTATIC_MEMBER_FUNCTION_P (expr))
+ if (TREE_TYPE (expr)
+ && DECL_NONSTATIC_MEMBER_FUNCTION_P (expr))
{
if (complain & tf_error)
{
--- /dev/null
+// PR c++/106858
+// { dg-additional-options "-fopenmp -fsanitize=undefined" }
+
+class A {
+ void f() {
+ #pragma omp target map(this->f) // { dg-error "member function" }
+ ;
+ }
+};