|
GCC Middle and Back End API Reference
|
#include "config.h"#include "system.h"#include "coretypes.h"#include "target.h"#include "function.h"#include "tree.h"#include "stringpool.h"#include "attribs.h"#include "attr-handlers.h"#include "diagnostic-core.h"#include "options.h"#include "cgraph.h"#include "varasm.h"#include "common/common-target.h"#include "tree-pretty-print.h"
Macros | |
| #define | ATTR_EXCL(name, function, type, variable) |
Functions | |
| static tree | decl_or_type_attrs (tree node) |
| bool | validate_attr_args (tree node[2], tree name, tree newargs[2]) |
| bool | validate_attr_arg (tree node[2], tree name, tree newarg) |
| tree | handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args, bool *no_add_attrs) |
| tree | ignore_attribute (tree *ARG_UNUSED(node), tree ARG_UNUSED(name), tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_leaf_attribute (tree *node, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_const_attribute (tree *node, tree name, tree ARG_UNUSED(args), int flags, bool *no_add_attrs) |
| tree | handle_pure_attribute (tree *node, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_novops_attribute (tree *node, tree ARG_UNUSED(name), tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *ARG_UNUSED(no_add_attrs)) |
| tree | handle_nothrow_attribute (tree *node, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_type_generic_attribute (tree *node, tree ARG_UNUSED(name), tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *ARG_UNUSED(no_add_attrs)) |
| tree | handle_returns_twice_attribute (tree *node, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_fnspec_attribute (tree *node, tree ARG_UNUSED(name), tree args, int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_visibility_attribute (tree *node, tree name, tree args, int ARG_UNUSED(flags), bool *ARG_UNUSED(no_add_attrs)) |
| tree | handle_always_inline_attribute (tree *node, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_noinline_attribute (tree *node, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_weak_attribute (tree *node, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *ARG_UNUSED(no_add_attrs)) |
| tree | handle_target_attribute (tree *node, tree name, tree args, int flags, bool *no_add_attrs) |
| tree | handle_used_attribute (tree *pnode, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_alias_attribute (tree *node, tree name, tree args, int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_section_attribute (tree *node, tree name, tree args, int flags, bool *no_add_attrs) |
| tree | handle_retain_attribute (tree *pnode, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
| tree | handle_malloc_common (tree *node, tree name, tree ARG_UNUSED(args), int ARG_UNUSED(flags), bool *no_add_attrs) |
Variables | |
| const struct attribute_spec::exclusions | attr_noreturn_exclusions [] |
| const struct attribute_spec::exclusions | attr_returns_twice_exclusions [] |
| const struct attribute_spec::exclusions | attr_alloc_exclusions [] |
| const struct attribute_spec::exclusions | attr_const_pure_exclusions [] |
| const struct attribute_spec::exclusions | attr_always_inline_exclusions [] |
| const struct attribute_spec::exclusions | attr_cold_hot_exclusions [] |
| const struct attribute_spec::exclusions | attr_noinline_exclusions [] |
| const struct attribute_spec::exclusions | attr_target_exclusions [] |
| const struct attribute_spec::exclusions | attr_section_exclusions [] |
Language-independent attribute handlers shared across front ends. Copyright (C) 2026 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Helper to define attribute exclusions.
Return the first of DECL or TYPE attributes installed in NODE if it's a DECL, or TYPE attributes if it's a TYPE, or null otherwise.
References DECL_ATTRIBUTES, decl_or_type_attrs(), DECL_P, error_mark_node, NULL_TREE, TREE_TYPE, TYPE_ATTRIBUTES, and TYPE_P.
Referenced by decl_or_type_attrs(), and validate_attr_args().
| tree handle_alias_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | args, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle an "alias" or "ifunc" attribute; arguments as in struct attribute_spec.handler.
References handle_alias_attribute(), handle_alias_ifunc_attribute(), and symtab_node::name().
Referenced by handle_alias_attribute(), and handle_alias_attribute().
| tree handle_alias_ifunc_attribute | ( | bool | is_alias, |
| tree * | node, | ||
| tree | name, | ||
| tree | args, | ||
| bool * | no_add_attrs ) |
Handle an "alias" or "ifunc" attribute; arguments as in struct attribute_spec.handler, except that IS_ALIAS tells us whether this is an alias as opposed to ifunc attribute.
Attribute handlers.
References current_function_decl, DECL_ATTRIBUTES, DECL_EXTERNAL, decl_function_context(), decl_in_symtab_p(), DECL_INITIAL, error(), error_mark_node, symtab_node::get(), get_identifier(), handle_alias_ifunc_attribute(), lookup_attribute(), NULL, NULL_TREE, TREE_CODE, tree_cons(), TREE_PUBLIC, TREE_STATIC, TREE_STRING_POINTER, TREE_USED, TREE_VALUE, VAR_P, and warning().
Referenced by handle_alias_attribute(), and handle_alias_ifunc_attribute().
| tree handle_always_inline_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "always_inline" attribute; arguments as in struct attribute_spec.handler.
References DECL_DISREGARD_INLINE_LIMITS, handle_always_inline_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, and warning().
Referenced by handle_always_inline_attribute(), and handle_always_inline_attribute().
| tree handle_const_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | flags, | ||
| bool * | no_add_attrs ) |
Handle a "const" attribute; arguments as in struct attribute_spec.handler.
References ATTR_FLAG_BUILT_IN, build_pointer_type(), build_qualified_type(), build_type_variant, handle_const_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, TREE_READONLY, TREE_THIS_VOLATILE, TREE_TYPE, TYPE_QUALS, VOID_TYPE_P, and warning().
Referenced by handle_const_attribute(), and handle_const_attribute().
| tree handle_fnspec_attribute | ( | tree * | node, |
| tree | ARG_UNUSEDname, | ||
| tree | args, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "fn spec" attribute; arguments as in struct attribute_spec.handler.
References gcc_assert, handle_fnspec_attribute(), NULL_TREE, TREE_CHAIN, TREE_CODE, and TREE_VALUE.
Referenced by handle_fnspec_attribute(), and handle_fnspec_attribute().
| tree handle_leaf_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "leaf" attribute; arguments as in struct attribute_spec.handler.
References handle_leaf_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, TREE_PUBLIC, and warning().
Referenced by handle_leaf_attribute(), and handle_leaf_attribute().
| tree handle_malloc_common | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Part of the `malloc` attribute handling which is shared by libgccjit and the C-family front-end.
References DECL_IS_MALLOC, handle_malloc_common(), symtab_node::name(), NULL_TREE, POINTER_TYPE_P, TREE_CODE, TREE_TYPE, and warning().
Referenced by handle_malloc_common(), and handle_malloc_common().
| tree handle_noinline_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "noinline" attribute; arguments as in struct attribute_spec.handler.
References DECL_UNINLINABLE, handle_noinline_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, and warning().
Referenced by handle_noinline_attribute(), and handle_noinline_attribute().
| tree handle_nothrow_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "nothrow" attribute; arguments as in struct attribute_spec.handler.
References handle_nothrow_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, TREE_NOTHROW, and warning().
Referenced by handle_nothrow_attribute(), and handle_nothrow_attribute().
| tree handle_novops_attribute | ( | tree * | node, |
| tree | ARG_UNUSEDname, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | ARG_UNUSEDno_add_attrs ) |
Handle a "no vops" attribute; arguments as in struct attribute_spec.handler.
References DECL_IS_NOVOPS, gcc_assert, handle_novops_attribute(), NULL_TREE, and TREE_CODE.
Referenced by handle_novops_attribute(), and handle_novops_attribute().
| tree handle_pure_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "pure" attribute; arguments as in struct attribute_spec.handler.
References DECL_PURE_P, handle_pure_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, TREE_TYPE, VOID_TYPE_P, and warning().
Referenced by handle_pure_attribute(), and handle_pure_attribute().
| tree handle_retain_attribute | ( | tree * | pnode, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "retain" attribute; arguments as in struct attribute_spec.handler.
References handle_retain_attribute(), symtab_node::name(), NULL_TREE, SUPPORTS_SHF_GNU_RETAIN, TREE_CODE, TREE_STATIC, VAR_P, and warning().
Referenced by handle_retain_attribute(), and handle_retain_attribute().
| tree handle_returns_twice_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "returns_twice" attribute.
References DECL_IS_RETURNS_TWICE, handle_returns_twice_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, and warning().
Referenced by handle_returns_twice_attribute(), and handle_returns_twice_attribute().
Handle a "section" attribute; arguments as in struct attribute_spec.handler.
References current_function_decl, DECL_SECTION_NAME, DECL_SOURCE_LOCATION, DECL_THREAD_LOCAL_P, error(), error_at(), handle_section_attribute(), symtab_node::name(), NULL_TREE, set_decl_section_name(), targetm, TREE_CODE, TREE_STATIC, TREE_STRING_POINTER, TREE_VALUE, validate_attr_arg(), VAR_OR_FUNCTION_DECL_P, and VAR_P.
Referenced by handle_returns_twice_attribute(), and handle_section_attribute().
Handle a "target" attribute.
References handle_target_attribute(), symtab_node::name(), NULL_TREE, targetm, TREE_CHAIN, TREE_CODE, TREE_STRING_LENGTH, TREE_STRING_POINTER, TREE_VALUE, and warning().
Referenced by handle_returns_twice_attribute(), and handle_target_attribute().
| tree handle_type_generic_attribute | ( | tree * | node, |
| tree | ARG_UNUSEDname, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | ARG_UNUSEDno_add_attrs ) |
Handle a "type_generic" attribute.
References gcc_assert, handle_type_generic_attribute(), NULL_TREE, prototype_p(), stdarg_p(), and TREE_CODE.
Referenced by handle_type_generic_attribute(), and handle_type_generic_attribute().
| tree handle_used_attribute | ( | tree * | pnode, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Handle a "used" attribute; arguments as in struct attribute_spec.handler.
References DECL_PRESERVE_P, DECL_READ_P, handle_used_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, TREE_STATIC, TREE_USED, VAR_P, and warning().
Referenced by handle_used_attribute(), and handle_used_attribute().
| tree handle_visibility_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | args, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | ARG_UNUSEDno_add_attrs ) |
Handle an "visibility" attribute; arguments as in struct attribute_spec.handler.
References DECL_ATTRIBUTES, decl_function_context(), DECL_VISIBILITY, DECL_VISIBILITY_SPECIFIED, error(), handle_visibility_attribute(), lookup_attribute(), symtab_node::name(), NULL_TREE, RECORD_OR_UNION_TYPE_P, TARGET_DLLIMPORT_DECL_ATTRIBUTES, TREE_CODE, TREE_PUBLIC, TREE_STRING_POINTER, TREE_VALUE, TYPE_ATTRIBUTES, TYPE_FIELDS, TYPE_NAME, TYPE_P, VISIBILITY_DEFAULT, VISIBILITY_HIDDEN, VISIBILITY_INTERNAL, VISIBILITY_PROTECTED, and warning().
Referenced by handle_visibility_attribute(), and handle_visibility_attribute().
| tree handle_weak_attribute | ( | tree * | node, |
| tree | name, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | ARG_UNUSEDno_add_attrs ) |
Handle a "weak" attribute; arguments as in struct attribute_spec.handler.
References DECL_ATTRIBUTES, DECL_DECLARED_INLINE_P, declare_weak(), error(), handle_weak_attribute(), lookup_attribute(), symtab_node::name(), NULL_TREE, TREE_CODE, VAR_OR_FUNCTION_DECL_P, and warning().
Referenced by handle_weak_attribute(), and handle_weak_attribute().
| tree ignore_attribute | ( | tree * | ARG_UNUSEDnode, |
| tree | ARG_UNUSEDname, | ||
| tree | ARG_UNUSEDargs, | ||
| int | ARG_UNUSEDflags, | ||
| bool * | no_add_attrs ) |
Ignore the given attribute. Used when this attribute may be usefully overridden by the target, but is not used generically.
References ignore_attribute(), and NULL_TREE.
Referenced by ignore_attribute(), and ignore_attribute().
Convenience wrapper for validate_attr_args to validate a single attribute argument. Used by handlers for attributes that take just a single argument.
References NULL_TREE, validate_attr_arg(), and validate_attr_args().
Referenced by handle_section_attribute(), and validate_attr_arg().
Given a pair of NODEs for arbitrary DECLs or TYPEs, validate one or two integral or string attribute arguments NEWARGS to be applied to NODE[0] for the absence of conflicts with the same attribute arguments already applied to NODE[1]. Issue a warning for conflicts and return false. Otherwise, when no conflicts are found, return true.
Shared helpers used by the handlers.
References decl_or_type_attrs(), DECL_P, DECL_SOURCE_LOCATION, gcc_unreachable, IDENTIFIER_POINTER, inform(), input_location, lookup_attribute(), print_generic_expr_to_str(), TREE_CHAIN, TREE_CODE, tree_int_cst_equal(), TREE_STRING_POINTER, TREE_VALUE, validate_attr_args(), and warning_at().
Referenced by validate_attr_arg(), and validate_attr_args().
| const struct attribute_spec::exclusions attr_alloc_exclusions[] |
Exclusions that apply to attribute alloc_align, alloc_size, and malloc.
| const struct attribute_spec::exclusions attr_always_inline_exclusions[] |
| const struct attribute_spec::exclusions attr_cold_hot_exclusions[] |
| const struct attribute_spec::exclusions attr_const_pure_exclusions[] |
| const struct attribute_spec::exclusions attr_noinline_exclusions[] |
| const struct attribute_spec::exclusions attr_noreturn_exclusions[] |
Define attributes that are mutually exclusive with one another.
Language-independent attribute handlers shared across front ends. Copyright (C) 2026 Free Software Foundation, Inc. This file is part of GCC. GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see <http://www.gnu.org/licenses/>.
Attribute exclusion tables used by `c-family` and `libgccjit`.
| const struct attribute_spec::exclusions attr_returns_twice_exclusions[] |
| const struct attribute_spec::exclusions attr_section_exclusions[] |
| const struct attribute_spec::exclusions attr_target_exclusions[] |