c++: -Wdangling-reference tweak to unbreak aarch64
My recent -Wdangling-reference change to not warn on std::span-like classes unfortunately caused a new warning: extending reference_like_class_p also opens the door to new warnings since we use reference_like_class_p for checking the return type of the function: either it must be a reference or a reference_like_class_p. We can consider even non-templates as std::span-like to get rid of the warning here. gcc/cp/ChangeLog: * call.cc (reference_like_class_p): Consider even non-templates for std::span-like classes. gcc/ChangeLog: * doc/invoke.texi: Update -Wdangling-reference documentation. gcc/testsuite/ChangeLog: * g++.dg/warn/Wdangling-reference21.C: New test.
This commit is contained in:
parent
44764984cf
commit
8efcdbf59b
3 changed files with 48 additions and 6 deletions
|
@ -14082,8 +14082,8 @@ reference_like_class_p (tree ctype)
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Avoid warning if CTYPE looks like std::span: it's a class template,
|
||||
has a T* member, and a trivial destructor. For example,
|
||||
/* Avoid warning if CTYPE looks like std::span: it has a T* member and
|
||||
a trivial destructor. For example,
|
||||
|
||||
template<typename T>
|
||||
struct Span {
|
||||
|
@ -14092,9 +14092,7 @@ reference_like_class_p (tree ctype)
|
|||
};
|
||||
|
||||
is considered std::span-like. */
|
||||
if (NON_UNION_CLASS_TYPE_P (ctype)
|
||||
&& CLASSTYPE_TEMPLATE_INSTANTIATION (ctype)
|
||||
&& TYPE_HAS_TRIVIAL_DESTRUCTOR (ctype))
|
||||
if (NON_UNION_CLASS_TYPE_P (ctype) && TYPE_HAS_TRIVIAL_DESTRUCTOR (ctype))
|
||||
for (tree field = next_aggregate_field (TYPE_FIELDS (ctype));
|
||||
field; field = next_aggregate_field (DECL_CHAIN (field)))
|
||||
if (TYPE_PTR_P (TREE_TYPE (field)))
|
||||
|
|
|
@ -3929,7 +3929,7 @@ struct Span @{
|
|||
@};
|
||||
@end smallexample
|
||||
|
||||
as @code{std::span}-like; that is, the class is a non-union class template
|
||||
as @code{std::span}-like; that is, the class is a non-union class
|
||||
that has a pointer data member and a trivial destructor.
|
||||
|
||||
This warning is enabled by @option{-Wall}.
|
||||
|
|
44
gcc/testsuite/g++.dg/warn/Wdangling-reference21.C
Normal file
44
gcc/testsuite/g++.dg/warn/Wdangling-reference21.C
Normal file
|
@ -0,0 +1,44 @@
|
|||
// { dg-do compile { target c++11 } }
|
||||
// { dg-options "-Wdangling-reference" }
|
||||
// Reduced from config/aarch64/aarch64-early-ra.cc.
|
||||
|
||||
template <typename T> struct array_slice {
|
||||
using iterator = T *;
|
||||
iterator begin();
|
||||
iterator end();
|
||||
iterator m_base;
|
||||
};
|
||||
|
||||
struct allocno_group_info { };
|
||||
|
||||
char recog_data_2;
|
||||
int record_constraints_op;
|
||||
struct early_ra {
|
||||
using operand_mask = int;
|
||||
struct allocno_info {
|
||||
int is_earlyclobbered;
|
||||
};
|
||||
struct allocno_subgroup {
|
||||
array_slice<allocno_info> allocnos();
|
||||
allocno_group_info *group;
|
||||
};
|
||||
allocno_subgroup get_allocno_subgroup(int);
|
||||
void record_constraints();
|
||||
};
|
||||
void early_ra::record_constraints() {
|
||||
operand_mask earlyclobber_operands, matched_operands, unmatched_operands,
|
||||
matches_operands, op_mask = operand_mask();
|
||||
auto record_operand = [&](int, int) {
|
||||
operand_mask overlaps;
|
||||
matches_operands |= overlaps;
|
||||
};
|
||||
for (int opno = 0; recog_data_2; ++opno) {
|
||||
operand_mask op_mask = earlyclobber_operands |= op_mask;
|
||||
if (0)
|
||||
record_operand(1, 0);
|
||||
}
|
||||
if (op_mask || (matched_operands & unmatched_operands && 0))
|
||||
for (auto &allocno : get_allocno_subgroup(record_constraints_op).allocnos())
|
||||
allocno.is_earlyclobbered = true;
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue