c++: unresolved overload with comma op [PR115430]
This works: template<typename T> int Func(T); typedef int (*funcptrtype)(int); funcptrtype fp0 = &Func<int>; but this doesn't: funcptrtype fp2 = (0, &Func<int>); because we only call resolve_nondeduced_context on the LHS (via convert_to_void) but not on the RHS, so cp_build_compound_expr's type_unknown_p check issues an error. PR c++/115430 gcc/cp/ChangeLog: * typeck.cc (cp_build_compound_expr): Call resolve_nondeduced_context on RHS. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/noexcept41.C: Remove dg-error. * g++.dg/overload/addr3.C: New test.
This commit is contained in:
parent
52d71b6b1f
commit
c847dcf944
3 changed files with 28 additions and 2 deletions
|
@ -8157,6 +8157,8 @@ cp_build_compound_expr (tree lhs, tree rhs, tsubst_flags_t complain)
|
|||
return rhs;
|
||||
}
|
||||
|
||||
rhs = resolve_nondeduced_context (rhs, complain);
|
||||
|
||||
if (type_unknown_p (rhs))
|
||||
{
|
||||
if (complain & tf_error)
|
||||
|
@ -8164,7 +8166,7 @@ cp_build_compound_expr (tree lhs, tree rhs, tsubst_flags_t complain)
|
|||
"no context to resolve type of %qE", rhs);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
|
||||
tree ret = build2 (COMPOUND_EXPR, TREE_TYPE (rhs), lhs, rhs);
|
||||
if (eptype)
|
||||
ret = build1 (EXCESS_PRECISION_EXPR, eptype, ret);
|
||||
|
|
|
@ -9,4 +9,4 @@ template <typename> struct a {
|
|||
};
|
||||
template <typename d, typename c> auto f(d &&, c &&) -> decltype(declval<c>);
|
||||
struct e {};
|
||||
static_assert((e{}, declval<a<int>>),""); // { dg-error "no context to resolve type" }
|
||||
static_assert((e{}, declval<a<int>>),"");
|
||||
|
|
24
gcc/testsuite/g++.dg/overload/addr3.C
Normal file
24
gcc/testsuite/g++.dg/overload/addr3.C
Normal file
|
@ -0,0 +1,24 @@
|
|||
// PR c++/115430
|
||||
// { dg-do compile }
|
||||
|
||||
template<typename T>
|
||||
int Func(T);
|
||||
typedef int (*funcptrtype)(int);
|
||||
funcptrtype fp0 = &Func<int>;
|
||||
funcptrtype fp1 = +&Func<int>;
|
||||
funcptrtype fp2 = (0, &Func<int>);
|
||||
funcptrtype fp3 = (0, +&Func<int>);
|
||||
funcptrtype fp4 = (0, 1, &Func<int>);
|
||||
|
||||
template<typename T>
|
||||
void
|
||||
g ()
|
||||
{
|
||||
funcptrtype fp5 = (0, &Func<T>);
|
||||
}
|
||||
|
||||
void
|
||||
f ()
|
||||
{
|
||||
g<int>();
|
||||
}
|
Loading…
Add table
Reference in a new issue