static tree check_noexcept_r (tree *tp, int * /*walk_subtrees*/, void * /*data*/) { tree t = *tp; enum tree_code code = TREE_CODE (t); if ((code == CALL_EXPR && CALL_EXPR_FN (t)) || code == AGGR_INIT_EXPR) { /* We can only use the exception specification of the called function for determining the value of a noexcept expression; we can't use TREE_NOTHROW, as it might have a different value in another translation unit, creating ODR problems. We could use TREE_NOTHROW (t) for !TREE_PUBLIC fns, though... */ tree fn = (code == AGGR_INIT_EXPR ? AGGR_INIT_EXPR_FN (t) : CALL_EXPR_FN (t)); tree type = TREE_TYPE (fn); gcc_assert (POINTER_TYPE_P (type)); type = TREE_TYPE (type); STRIP_NOPS (fn); if (TREE_CODE (fn) == ADDR_EXPR) fn = TREE_OPERAND (fn, 0); if (TREE_CODE (fn) == FUNCTION_DECL) { /* We do use TREE_NOTHROW for ABI internals like __dynamic_cast, and for C library functions known not to throw. */ if (DECL_EXTERN_C_P (fn) && (DECL_ARTIFICIAL (fn) || nothrow_libfn_p (fn))) return TREE_NOTHROW (fn) ? NULL_TREE : fn; /* A call to a constexpr function is noexcept if the call is a constant expression. */ if (DECL_DECLARED_CONSTEXPR_P (fn) && is_sub_constant_expr (t)) return NULL_TREE; } if (!TYPE_NOTHROW_P (type)) return fn; } return NULL_TREE; }
/* Return -1 if dwarf ATTR shouldn't be added for DECL, or the attribute value otherwise. */ int cp_decl_dwarf_attribute (const_tree decl, int attr) { if (decl == NULL_TREE) return -1; switch (attr) { case DW_AT_explicit: if (TREE_CODE (decl) == FUNCTION_DECL && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl)) && DECL_NONCONVERTING_P (decl)) return 1; break; case DW_AT_deleted: if (TREE_CODE (decl) == FUNCTION_DECL && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl)) && DECL_DELETED_FN (decl)) return 1; break; case DW_AT_defaulted: if (TREE_CODE (decl) == FUNCTION_DECL && DECL_LANG_SPECIFIC (STRIP_TEMPLATE (decl)) && DECL_DEFAULTED_FN (decl)) { if (DECL_DEFAULTED_IN_CLASS_P (decl)) return DW_DEFAULTED_in_class; if (DECL_DEFAULTED_OUTSIDE_CLASS_P (decl)) return DW_DEFAULTED_out_of_class; } break; case DW_AT_const_expr: if (VAR_OR_FUNCTION_DECL_P (decl) && DECL_DECLARED_CONSTEXPR_P (decl)) return 1; break; case DW_AT_reference: if (TREE_CODE (decl) == FUNCTION_DECL && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl) && FUNCTION_REF_QUALIFIED (TREE_TYPE (decl)) && !FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (decl))) return 1; break; case DW_AT_rvalue_reference: if (TREE_CODE (decl) == FUNCTION_DECL && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl) && FUNCTION_REF_QUALIFIED (TREE_TYPE (decl)) && FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (decl))) return 1; break; case DW_AT_inline: if (VAR_P (decl) && DECL_INLINE_VAR_P (decl)) { if (DECL_VAR_DECLARED_INLINE_P (decl)) return DW_INL_declared_inlined; else return DW_INL_inlined; } break; case DW_AT_export_symbols: if (TREE_CODE (decl) == NAMESPACE_DECL && (DECL_NAMESPACE_INLINE_P (decl) || (DECL_NAME (decl) == NULL_TREE && dwarf_version >= 5))) return 1; break; default: break; } return -1; }