Hi, when operand of a noexcept operator in a friend function definition involves a member of a template class enclosing the friend definition, Clang casts current context to either a CXXMethodDecl or a CXXRecordDecl. Since friend function is neither of these, cast fails. The same test in a non-template class works fine.
The first patch tries to retrieve the lexical parent of the function
definition (per class.friend/p6-7), which is expected to be a record
type. A test is also provided (also, pasting below for reference).
template<typename T>
class noexcept_member_operand_at_friend_definition {
T v_;
friend int add_to_v(noexcept_member_operand_at_friend_definition &t)
noexcept(noexcept(v_ + 42))
{
return t.v_ + 42;
}
};
void this_expr()
{
noexcept_member_operand_at_friend_definition<int> t;
add_to_v(t);
}
The second patch is a minor one; it merges two if statements that have
the same condition.
0001-Fix-for-Bug-15290-Segmentation-fault-during-template.patch
Description: Binary data
0002-Merged-two-subsequent-if-statements.patch
Description: Binary data
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
