+2019-05-10 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * call.c (build_call_a): Use FUNC_OR_METHOD_TYPE_P.
+ * cp-gimplify.c (cp_fold): Likewise.
+ * cp-objcp-common.c (cp_type_dwarf_attribute): Likewise.
+ * cp-tree.h (TYPE_OBJ_P, TYPE_PTROBV_P): Likewise.
+ * cvt.c (perform_qualification_conversions): Likewise.
+ * decl.c (grokdeclarator): Likewise.
+ * decl2.c (build_memfn_type): Likewise.
+ * mangle.c (canonicalize_for_substitution, write_type): Likewise.
+ * parser.c (cp_parser_omp_declare_reduction): Likewise.
+ * pt.c (check_explicit_specialization, uses_deducible_template_parms,
+ check_cv_quals_for_unify, dependent_type_p_r): Likewise.
+ * rtti.c (ptr_initializer): Likewise.
+ * semantics.c (finish_asm_stmt, finish_offsetof,
+ cp_check_omp_declare_reduction): Likewise.
+ * tree.c (cp_build_qualified_type_real,
+ cp_build_type_attribute_variant, cxx_type_hash_eq,
+ cxx_copy_lang_qualifiers, cp_free_lang_data): Likewise.
+ * typeck.c (structural_comptypes, convert_arguments,
+ cp_build_addr_expr_1, unary_complex_lvalue, cp_build_c_cast,
+ cp_build_modify_expr, comp_ptr_ttypes_real, type_memfn_rqual):
+ Likewise.
+
2019-05-10 Marek Polacek <polacek@redhat.com>
PR c++/78010 - bogus -Wsuggest-override warning on final function.
gcc_assert (TYPE_PTR_P (TREE_TYPE (function)));
fntype = TREE_TYPE (TREE_TYPE (function));
- gcc_assert (TREE_CODE (fntype) == FUNCTION_TYPE
- || TREE_CODE (fntype) == METHOD_TYPE);
+ gcc_assert (FUNC_OR_METHOD_TYPE_P (fntype));
result_type = TREE_TYPE (fntype);
/* An rvalue has no cv-qualifiers. */
if (SCALAR_TYPE_P (result_type) || VOID_TYPE_P (result_type))
/* Cope with user tricks that amount to offsetof. */
if (op0 != error_mark_node
- && TREE_CODE (TREE_TYPE (op0)) != FUNCTION_TYPE
- && TREE_CODE (TREE_TYPE (op0)) != METHOD_TYPE)
+ && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (op0)))
{
tree val = get_base_address (op0);
if (val
switch (attr)
{
case DW_AT_reference:
- if ((TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (type)
&& FUNCTION_REF_QUALIFIED (type)
&& !FUNCTION_RVALUE_QUALIFIED (type))
return 1;
break;
case DW_AT_rvalue_reference:
- if ((TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (type)
&& FUNCTION_REF_QUALIFIED (type)
&& FUNCTION_RVALUE_QUALIFIED (type))
return 1;
#define TYPE_OBJ_P(NODE) \
(!TYPE_REF_P (NODE) \
&& !VOID_TYPE_P (NODE) \
- && TREE_CODE (NODE) != FUNCTION_TYPE \
- && TREE_CODE (NODE) != METHOD_TYPE)
+ && !FUNC_OR_METHOD_TYPE_P (NODE))
/* Returns true if NODE is a pointer to an object. Keep these checks
in ascending tree code order. */
void. Keep these checks in ascending tree code order. */
#define TYPE_PTROBV_P(NODE) \
(TYPE_PTR_P (NODE) \
- && !(TREE_CODE (TREE_TYPE (NODE)) == FUNCTION_TYPE \
- || TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE))
+ && !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (NODE)))
/* Returns true if NODE is a pointer to function type. */
#define TYPE_PTRFN_P(NODE) \
bool
tx_safe_fn_type_p (tree t)
{
- if (TREE_CODE (t) != FUNCTION_TYPE
- && TREE_CODE (t) != METHOD_TYPE)
+ if (!FUNC_OR_METHOD_TYPE_P (t))
return false;
return !!lookup_attribute ("transaction_safe", TYPE_ATTRIBUTES (t));
}
}
if (unqualified_id && TREE_CODE (unqualified_id) == TEMPLATE_ID_EXPR
- && TREE_CODE (type) != FUNCTION_TYPE
- && TREE_CODE (type) != METHOD_TYPE
+ && !FUNC_OR_METHOD_TYPE_P (type)
&& !variable_template_p (TREE_OPERAND (unqualified_id, 0)))
{
error ("template-id %qD used as a declarator",
name);
storage_class = sc_none;
}
- else if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE)
+ else if (FUNC_OR_METHOD_TYPE_P (type))
{
error_at (sloc, "function %qs cannot be declared %<mutable%>",
name);
declspecs->locations);
}
}
- else if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE)
+ else if (FUNC_OR_METHOD_TYPE_P (type))
{
tree original_name;
int publicp = 0;
if (fntype == error_mark_node || ctype == error_mark_node)
return error_mark_node;
- gcc_assert (TREE_CODE (fntype) == FUNCTION_TYPE
- || TREE_CODE (fntype) == METHOD_TYPE);
+ gcc_assert (FUNC_OR_METHOD_TYPE_P (fntype));
cp_cv_quals type_quals = quals & ~TYPE_QUAL_RESTRICT;
ctype = cp_build_qualified_type (ctype, type_quals);
else
node = cp_build_qualified_type (TYPE_MAIN_VARIANT (node),
cp_type_quals (node));
- if (TREE_CODE (node) == FUNCTION_TYPE
- || TREE_CODE (node) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (node))
{
node = build_ref_qualified_type (node, type_memfn_rqual (orig));
tree r = canonical_eh_spec (TYPE_RAISES_EXCEPTIONS (orig));
t = cp_build_type_attribute_variant (t, attrs);
}
gcc_assert (t != type);
- if (TREE_CODE (t) == FUNCTION_TYPE
- || TREE_CODE (t) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (t))
{
t = build_ref_qualified_type (t, type_memfn_rqual (type));
if (flag_noexcept_type)
/* See through any typedefs. */
type = TYPE_MAIN_VARIANT (type);
- if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (type))
type = cxx_copy_lang_qualifiers (type, type_orig);
/* According to the C++ ABI, some library classes are passed the
|| id_equal (orig_reduc_id, "max")))))
error_at (loc, "predeclared arithmetic type %qT in "
"%<#pragma omp declare reduction%>", type);
- else if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE
+ else if (FUNC_OR_METHOD_TYPE_P (type)
|| TREE_CODE (type) == ARRAY_TYPE)
error_at (loc, "function or array type %qT in "
"%<#pragma omp declare reduction%>", type);
if ((specialization || member_specialization)
/* This doesn't apply to variable templates. */
- && (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE))
+ && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (decl)))
{
tree t = TYPE_ARG_TYPES (TREE_TYPE (decl));
for (; t; t = TREE_CHAIN (t))
/* type (T)
T()
T(T) */
- if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (type))
{
if (uses_deducible_template_parms (TREE_TYPE (type)))
return true;
It is ok when we're allowing additional CV qualifiers
at the outer level [14.8.2.1]/3,1st bullet. */
if ((TYPE_REF_P (arg)
- || TREE_CODE (arg) == FUNCTION_TYPE
- || TREE_CODE (arg) == METHOD_TYPE)
+ || FUNC_OR_METHOD_TYPE_P (arg))
&& (parm_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)))
return 0;
(type)));
else if (INDIRECT_TYPE_P (type))
return dependent_type_p (TREE_TYPE (type));
- else if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE)
+ else if (FUNC_OR_METHOD_TYPE_P (type))
{
tree arg_type;
to = tx_unsafe_fn_variant (to);
}
if (flag_noexcept_type
- && (TREE_CODE (to) == FUNCTION_TYPE
- || TREE_CODE (to) == METHOD_TYPE)
+ && FUNC_OR_METHOD_TYPE_P (to)
&& TYPE_NOTHROW_P (to))
{
flags |= 0x40;
|| CP_TYPE_CONST_P (TREE_TYPE (operand))
/* Functions are not modifiable, even though they are
lvalues. */
- || TREE_CODE (TREE_TYPE (operand)) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (operand)) == METHOD_TYPE
+ || FUNC_OR_METHOD_TYPE_P (TREE_TYPE (operand))
/* If it's an aggregate and any field is const, then it is
effectively const. */
|| (CLASS_TYPE_P (TREE_TYPE (operand))
TREE_OPERAND (expr, 2));
return error_mark_node;
}
- if (TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
+ if (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (expr))
|| TREE_TYPE (expr) == unknown_type_node)
{
while (TREE_CODE (expr) == COMPONENT_REF
return;
}
}
- else if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE
+ else if (FUNC_OR_METHOD_TYPE_P (type)
|| TREE_CODE (type) == ARRAY_TYPE)
{
error_at (loc, "function or array type %qT in "
(in CD1) we always ignore extra cv-quals on functions. */
if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
&& (TYPE_REF_P (type)
- || TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE))
+ || FUNC_OR_METHOD_TYPE_P (type)))
{
if (TYPE_REF_P (type))
bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
tree new_type;
new_type = build_type_attribute_variant (type, attributes);
- if (TREE_CODE (new_type) == FUNCTION_TYPE
- || TREE_CODE (new_type) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (new_type))
gcc_checking_assert (cxx_type_hash_eq (type, new_type));
/* Making a new main variant of a class type is broken. */
bool
cxx_type_hash_eq (const_tree typea, const_tree typeb)
{
- gcc_assert (TREE_CODE (typea) == FUNCTION_TYPE
- || TREE_CODE (typea) == METHOD_TYPE);
+ gcc_assert (FUNC_OR_METHOD_TYPE_P (typea));
if (type_memfn_rqual (typea) != type_memfn_rqual (typeb))
return false;
cxx_copy_lang_qualifiers (const_tree typea, const_tree typeb)
{
tree type = CONST_CAST_TREE (typea);
- if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (type))
type = build_cp_fntype_variant (type, type_memfn_rqual (typeb),
TYPE_RAISES_EXCEPTIONS (typeb),
TYPE_HAS_LATE_RETURN_TYPE (typeb));
void
cp_free_lang_data (tree t)
{
- if (TREE_CODE (t) == METHOD_TYPE
- || TREE_CODE (t) == FUNCTION_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (t))
{
/* Default args are not interesting anymore. */
tree argtypes = TYPE_ARG_TYPES (t);
return false;
/* Need to check this before TYPE_MAIN_VARIANT.
FIXME function qualifiers should really change the main variant. */
- if (TREE_CODE (t1) == FUNCTION_TYPE
- || TREE_CODE (t1) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (t1))
{
if (type_memfn_rqual (t1) != type_memfn_rqual (t2))
return false;
if (type == 0 || !TYPE_REF_P (type))
{
if (TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE
- || TREE_CODE (TREE_TYPE (val)) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (val)) == METHOD_TYPE)
+ || FUNC_OR_METHOD_TYPE_P (TREE_TYPE (val)))
val = decay_conversion (val, complain);
}
/* Anything not already handled and not a true memory reference
is an error. */
- if (TREE_CODE (argtype) != FUNCTION_TYPE
- && TREE_CODE (argtype) != METHOD_TYPE)
+ if (!FUNC_OR_METHOD_TYPE_P (argtype))
{
cp_lvalue_kind kind = lvalue_kind (arg);
if (kind == clk_none)
return arg;
}
- if (TREE_CODE (TREE_TYPE (arg)) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (arg)) == METHOD_TYPE
+ if (FUNC_OR_METHOD_TYPE_P (TREE_TYPE (arg))
|| TREE_CODE (arg) == OFFSET_REF)
return NULL_TREE;
}
}
- if (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE)
+ if (FUNC_OR_METHOD_TYPE_P (type))
{
if (complain & tf_error)
error ("invalid cast to function type %qT", type);
&& (TREE_READONLY (lhs) || CP_TYPE_CONST_P (lhstype)
/* Functions are not modifiable, even though they are
lvalues. */
- || TREE_CODE (TREE_TYPE (lhs)) == FUNCTION_TYPE
- || TREE_CODE (TREE_TYPE (lhs)) == METHOD_TYPE
+ || FUNC_OR_METHOD_TYPE_P (TREE_TYPE (lhs))
/* If it's an aggregate and any field is const, then it is
effectively const. */
|| (CLASS_TYPE_P (lhstype)
/* Const and volatile mean something different for function types,
so the usual checks are not appropriate. */
- if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE)
+ if (!FUNC_OR_METHOD_TYPE_P (to))
{
if (!at_least_as_qualified_p (to, from))
return 0;
cp_ref_qualifier
type_memfn_rqual (const_tree type)
{
- gcc_assert (TREE_CODE (type) == FUNCTION_TYPE
- || TREE_CODE (type) == METHOD_TYPE);
+ gcc_assert (FUNC_OR_METHOD_TYPE_P (type));
if (!FUNCTION_REF_QUALIFIED (type))
return REF_QUAL_NONE;