const bool val_dep_p = value_dependent_expression_p (expr);
if (val_dep_p)
expr = canonicalize_expr_argument (expr, complain);
+ else
+ STRIP_ANY_LOCATION_WRAPPER (expr);
/* 14.3.2/5: The null pointer{,-to-member} conversion is applied
to a non-type argument of "nullptr". */
}
exp = cp_build_addr_expr_strict (xarg, complain);
+
+ if (TREE_CODE (exp) == PTRMEM_CST)
+ exp = maybe_wrap_with_location (exp, loc);
+ else
+ protected_set_expr_location (exp, loc);
}
if (processing_template_decl && exp != error_mark_node)
if (!(complain & tf_warning_or_error))
return error_mark_node;
+ location_t loc = cp_expr_loc_or_input_loc (expr);
+
if (pedantic || warn_pmf2ptr)
- pedwarn (input_location, pedantic ? OPT_Wpedantic : OPT_Wpmf_conversions,
+ pedwarn (loc, pedantic ? OPT_Wpedantic : OPT_Wpmf_conversions,
"converting from %qH to %qI", intype, type);
+ STRIP_ANY_LOCATION_WRAPPER (expr);
+
if (TREE_CODE (intype) == METHOD_TYPE)
expr = build_addr_func (expr, complain);
else if (TREE_CODE (expr) == PTRMEM_CST)
if (expr == error_mark_node)
return error_mark_node;
- return build_nop (type, expr);
+ expr = build_nop (type, expr);
+ SET_EXPR_LOCATION (expr, loc);
+ return expr;
}
/* Build a NOP_EXPR to TYPE, but mark it as a reinterpret_cast so that
template<T> void foo(); // { dg-error "type" "" { target c++17_down } }
};
-template<T N = 0.0, void (A::*)() = &A::foo<N> > struct B {}; // { dg-error "type|declared" "" { target c++17_down } }
+template<T N = 0.0, void (A::*)() = &A::foo<N> > struct B {}; // { dg-error "type|declared|could not convert" "" { target c++17_down } }
-B<> b; // { dg-error "(could not convert|no matches)" "" { target c++17_down } }
+B<> b; // { dg-message "" "" { target c++17_down } }