gcc/gcc/attribs.c

487 lines
15 KiB
C
Raw Normal View History

/* Functions dealing with attribute handling, used by most front ends.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
Make-lang.in, [...]: Update copyright years. * ada/gcc-interface/Make-lang.in, alias.c, attribs.c, auto-inc-dec.c, basic-block.h, bb-reorder.c, calls.c, c-common.c, cgraph.h, collect2.h, config/alpha/alpha.c, config/alpha/alpha.md, config/alpha/predicates.md, config/arm/arm.md, config/arm/lib1funcs.asm, config/arm/neon-schedgen.ml, config/avr/avr.c, config/avr/avr.md, config/bfin/bfin.c, config/darwin9.h, config/darwin.c, config/darwin.h, config/h8300/h8300.c, config/i386/cpuid.h, config/i386/cygming.h, config/i386/cygwin.h, config/i386/mingw32.h, config/i386/msformat-c.c, config/i386/sol2-10.h, config/i386/xopintrin.h, config/ia64/ia64.c, config/ia64/ia64.md, config/ia64/sync.md, config/mep/mep.c, config/mips/mips.md, config/mn10300/mn10300.c, config/mn10300/mn10300.h, config/pa/pa.c, config/pa/pa.md, config/rs6000/aix.h, config/rs6000/dfp.md, config/rs6000/rs6000-builtin.def, config/rs6000/rs6000-c.c, config/rs6000/vector.md, config/rtems.h, config/rx/rx.md, config/s390/s390.md, config/sol2-c.c, config/sparc/sol2-bi.h, config/sparc/sol2-gas.h, config/sparc/sparc.h, config/sparc/sparc.md, config/sparc/sparc-protos.h, config/spu/spu.c, config/spu/spu-c.c, config/t-darwin, convert.c, c.opt, c-opts.c, cp/Make-lang.in, c-pretty-print.c, c-typeck.c, df-core.c, df-scan.c, diagnostic.c, diagnostic.h, doc/cppopts.texi, doc/cpp.texi, doc/extend.texi, doc/gimple.texi, doc/languages.texi, doc/plugins.texi, doc/rtl.texi, doc/standards.texi, doc/tree-ssa.texi, doc/trouble.texi, dominance.c, fold-const.c, fortran/Make-lang.in, fwprop.c, gcc-plugin.h, gensupport.c, gimple.h, gimple-iterator.c, graphite.c, graphite-clast-to-gimple.c, graphite-clast-to-gimple.h, graphite-dependences.c, graphite-poly.c, graphite-poly.h, graphite-ppl.c, graphite-ppl.h, graphite-scop-detection.c, graphite-sese-to-poly.c, graphite-sese-to-poly.h, ifcvt.c, intl.c, intl.h, ipa.c, ipa-cp.c, ipa-inline.c, ipa-prop.c, ipa-prop.h, ipa-pure-const.c, ipa-reference.c, ipa-type-escape.c, ira-color.c, ira-conflicts.c, ira-lives.c, java/Make-lang.in, lambda-code.c, loop-invariant.c, lto/Make-lang.in, lto-streamer.h, lto-streamer-in.c, objc/Make-lang.in, objcp/Make-lang.in, omp-low.c, optc-gen.awk, opt-functions.awk, opth-gen.awk, params.def, passes.c, postreload-gcse.c, print-tree.c, recog.c, regrename.c, reload.h, rtl.def, sched-int.h, sched-rgn.c, sel-sched-dump.c, sese.c, sese.h, store-motion.c, stor-layout.c, tree-cfgcleanup.c, tree-chrec.c, tree-complex.c, tree-data-ref.c, tree.def, tree-eh.c, tree-flow.h, tree-flow-inline.h, tree.h, tree-loop-distribution.c, tree-outof-ssa.c, tree-parloops.c, tree-pass.h, tree-predcom.c, tree-profile.c, tree-scalar-evolution.c, tree-ssa-address.c, tree-ssa-alias.c, tree-ssa-coalesce.c, tree-ssa-copy.c, tree-ssa-dce.c, tree-ssa-dom.c, tree-ssa-dse.c, tree-ssa-loop-im.c, tree-ssa-loop-ivcanon.c, tree-ssa-loop-manip.c, tree-ssa-math-opts.c, tree-ssa-operands.c, tree-ssa-pre.c, tree-ssa-sccvn.c, tree-ssa-structalias.c, tree-ssa-uncprop.c, tree-tailcall.c, tree-vect-data-refs.c, tree-vect-loop.c, tree-vectorizer.h, tree-vect-slp.c, tree-vrp.c, unwind-dw2-fde-darwin.c, varpool.c: Update copyright years. From-SVN: r157950
2010-04-02 21:54:46 +02:00
2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
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/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "flags.h"
toplev.h: Do not include diagnostic-core.h. 2010-07-08 Manuel López-Ibáñez <manu@gcc.gnu.org> * toplev.h: Do not include diagnostic-core.h. Include diagnostic-core.h in every file that includes toplev.h. * c-tree.h: Do not include toplev.h. * pretty-print.h: Update comment. * Makefile.in: Update dependencies. * alias.c: Include diagnostic-core.h in every file that includes toplev.h. * attribs.c: Likewise. * auto-inc-dec.c: Likewise. * bb-reorder.c: Likewise. * bt-load.c: Likewise. * caller-save.c: Likewise. * calls.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgbuild.c: Likewise. * cfgcleanup.c: Likewise. * cfghooks.c: Likewise. * cfgloop.c: Likewise. * combine.c: Likewise. * config/alpha/alpha.c: Likewise. * config/arc/arc.c: Likewise. * config/arm/arm.c: Likewise. * config/arm/pe.c: Likewise. * config/avr/avr.c: Likewise. * config/bfin/bfin.c: Likewise. * config/cris/cris.c: Likewise. * config/crx/crx.c: Likewise. * config/darwin-c.c: Likewise. * config/darwin.c: Likewise. * config/fr30/fr30.c: Likewise. * config/frv/frv.c: Likewise. * config/h8300/h8300.c: Likewise. * config/host-darwin.c: Likewise. * config/i386/i386.c: Likewise. * config/i386/netware.c: Likewise. * config/i386/nwld.c: Likewise. * config/i386/winnt-cxx.c: Likewise. * config/i386/winnt-stubs.c: Likewise. * config/i386/winnt.c: Likewise. * config/ia64/ia64-c.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/lm32/lm32.c: Likewise. * config/m32c/m32c-pragma.c: Likewise. * config/m32c/m32c.c: Likewise. * config/m32r/m32r.c: Likewise. * config/m68hc11/m68hc11.c: Likewise. * config/m68k/m68k.c: Likewise. * config/mcore/mcore.c: Likewise. * config/mep/mep-pragma.c: Likewise. * config/mep/mep.c: Likewise. * config/mmix/mmix.c: Likewise. * config/mn10300/mn10300.c: Likewise. * config/moxie/moxie.c: Likewise. * config/pa/pa.c: Likewise. * config/pdp11/pdp11.c: Likewise. * config/picochip/picochip.c: Likewise. * config/rs6000/rs6000-c.c: Likewise. * config/rs6000/rs6000.c: Likewise. * config/rx/rx.c: Likewise. * config/s390/s390.c: Likewise. * config/score/score.c: Likewise. * config/score/score3.c: Likewise. * config/score/score7.c: Likewise. * config/sh/sh.c: Likewise. * config/sh/symbian-base.c: Likewise. * config/sh/symbian-c.c: Likewise. * config/sh/symbian-cxx.c: Likewise. * config/sol2-c.c: Likewise. * config/sol2.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/v850/v850-c.c: Likewise. * config/v850/v850.c: Likewise. * config/vax/vax.c: Likewise. * config/vxworks.c: Likewise. * config/xtensa/xtensa.c: Likewise. * convert.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * dbgcnt.c: Likewise. * dbxout.c: Likewise. * ddg.c: Likewise. * dominance.c: Likewise. * emit-rtl.c: Likewise. * explow.c: Likewise. * expmed.c: Likewise. * fixed-value.c: Likewise. * fold-const.c: Likewise. * fwprop.c: Likewise. * gcse.c: Likewise. * ggc-common.c: Likewise. * ggc-page.c: Likewise. * ggc-zone.c: Likewise. * gimple-low.c: Likewise. * gimplify.c: Likewise. * graph.c: Likewise. * haifa-sched.c: Likewise. * ifcvt.c: Likewise. * implicit-zee.c: Likewise. * integrate.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * lists.c: Likewise. * loop-doloop.c: Likewise. * loop-iv.c: Likewise. * lto-opts.c: Likewise. * lto-symtab.c: Likewise. * main.c: Likewise. * modulo-sched.c: Likewise. * optabs.c: Likewise. * params.c: Likewise. * plugin.c: Likewise. * postreload-gcse.c: Likewise. * postreload.c: Likewise. * predict.c: Likewise. * profile.c: Likewise. * real.c: Likewise. * regcprop.c: Likewise. * reginfo.c: Likewise. * regmove.c: Likewise. * reorg.c: Likewise. * resource.c: Likewise. * rtl.c: Likewise. * rtlanal.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-rgn.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-ir.c: Likewise. * simplify-rtx.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * targhooks.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-dump.c: Likewise. * tree-eh.c: Likewise. * tree-inline.c: Likewise. * tree-nomudflap.c: Likewise. * tree-object-size.c: Likewise. * tree-optimize.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-phinodes.c: Likewise. * tree-profile.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-uninit.c: Likewise. * tree-ssa.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vrp.c: Likewise. * varasm.c: Likewise. * vec.c: Likewise. * web.c: Likewise. * xcoffout.c: Likewise. c-family/ * c-common.h: Include diagnostic-core.h. Error if already included. * c-semantics.c: Do not define GCC_DIAG_STYLE here. cp/ * cp-tree.h: Do not include toplev.h. java/ * boehm.c: Include diagnostic-core.h in every file that includes toplev.h. * class.c: Likewise. * constants.c: Likewise. * decl.c: Likewise. * except.c: Likewise. * expr.c: Likewise. * jcf-parse.c: Likewise. * mangle.c: Likewise. * mangle_name.c: Likewise. * resource.c: Likewise. * typeck.c: Likewise. * verify-glue.c: Likewise. ada/ * gcc-interface/utils.c: Include diagnostic-core.h in every file that includes toplev.h. lto/ * lto-coff.c: Include diagnostic-core.h in every file that includes toplev.h. * lto-elf.c: Likewise. * lto-lang.c: Likewise. * lto-macho.c: Likewise. From-SVN: r161943
2010-07-08 06:22:54 +02:00
#include "diagnostic-core.h"
#include "ggc.h"
#include "tm_p.h"
#include "cpplib.h"
#include "target.h"
#include "langhooks.h"
#include "hashtab.h"
#include "plugin.h"
attribs.c (c_common_attribute_table): Move table and handlers to c-common.c. * attribs.c (c_common_attribute_table): Move table and handlers to c-common.c. (format_attribute_table, lang_attribute_table, lang_attribute_common): Remove. (init_attributes): Replace NULL pointers with pointers to the empty table. (handle_packed_attribute, handle_nocommon_attribute, handle_common_attribute, handle_noreturn_attribute, handle_noinline_attribute, handle_always_inline_attribute, handle_used_attribute, handle_unused_attribute, handle_const_attribute, handle_transparent_union_attribute, handle_constructor_attribute, handle_destructor_attribute, handle_mode_attribute, handle_section_attribute, handle_aligned_attribute, handle_weak_attribute, handle_alias_attribute, handle_visibility_attribute, handle_no_instrument_function_attribute, handle_malloc_attribute, handle_no_limit_stack_attribute, handle_pure_attribute, handle_deprecated_attribute, handle_vector_size_attribute, vector_size_helper): Move to c-common.c. * c-common.c (c_common_attribute_table, handle_packed_attribute, handle_nocommon_attribute, handle_common_attribute, handle_noreturn_attribute, handle_noinline_attribute, handle_always_inline_attribute, handle_used_attribute, handle_unused_attribute, handle_const_attribute, handle_transparent_union_attribute, handle_constructor_attribute, handle_destructor_attribute, handle_mode_attribute, handle_section_attribute, handle_aligned_attribute, handle_weak_attribute, handle_alias_attribute, handle_visibility_attribute, handle_no_instrument_function_attribute, handle_malloc_attribute, handle_no_limit_stack_attribute, handle_pure_attribute, handle_deprecated_attribute, handle_vector_size_attribute, vector_size_helper): Move from attribs.c. * c-common.h (c_common_attribute_table, c_common_format_attribute_table): New. * c-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Redefine. * langhooks-def.h (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_ATTRIBUTE_TABLE): New. (LANG_HOOKS_INITIALIZER): Update. * langhooks.h (struct lang_hooks): 3 new attribute hooks. * target-def.h (TARGET_ATTRIBUTE_TABLE): Default to NULL. * target.h: Update comment. * tree.c (default_target_attribute_table): Remove. * tree.h (default_target_attribute_table, format_attribute_table, lang_attribute_table, lang_attribute_common): Remove. ada: * misc.c (gnat_init): Don't set lang_attribute_common. cp: * cp-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, LANG_HOOKS_ATTRIBUTE_TABLE): Redefine. * cp-tree.h (cp_attribute_table): Rename. * decl.c (lang_attribute_table): Remove declaration. (cxx_init_decl_processing): Don't set it. * tree.c (cp_attribute_table): Rename. objc: * objc-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Redefine. From-SVN: r52730
2002-04-24 22:41:04 +02:00
/* Table of the tables of attributes (common, language, format, machine)
searched. */
static const struct attribute_spec *attribute_tables[4];
/* Hashtable mapping names (represented as substrings) to attribute specs. */
static htab_t attribute_hash;
/* Substring representation. */
struct substring
{
const char *str;
int length;
};
static bool attributes_initialized = false;
/* Default empty table of attributes. */
static const struct attribute_spec empty_attribute_table[] =
{
ChangeLog gcc/ 2011-03-21 Kai Tietz <ktietz@redhat.com> PR target/12171 * doc/plugins.texi: Adjust documentation for plugin register_callback. * tree.h (attribute_spec): Add new member affects_type_identity. - Zitierten Text anzeigen - * attribs.c (empty_attribute_table): Adjust attribute_spec initializers. * config/alpha/alpha.c: Likewise. * config/arc/arc.c: Likewise. * config/arm/arm.c: Likewise. * config/avr/avr.c: Likewise. * config/bfin/bfin.c: Likewise. * config/crx/crx.c: Likewise. * config/darwin.h: Likewise. * config/h8300/h8300.c: Likewise. * config/i386/cygming.h: Likewise. * config/i386/i386.c: Likewise. * config/ia64/ia64.c: Likewise. * config/m32c/m32c.c: Likewise. * config/m32r/m32r.c: Likewise. * config/m68hc11/m68hc11.c: Likewise. * config/m68k/m68k.c: Likewise. * config/mcore/mcore.c: Likewise. * config/mep/mep.c: Likewise. * config/microblaze/microblaze.c: Likewise. * config/mips/mips.c: Likewise. * config/rs6000/rs6000.c: Likewise. * config/rx/rx.c: Likewise. * config/sh/sh.c: Likewise. * config/sol2.h: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/v850/v850.c: Likewise. ChangeLog gcc/cp 2011-03-21 Kai Tietz <ktietz@redhat.com> PR target/12171 * tree.c (cxx_attribute_table): Adjust table. ChangeLog gcc/testsuite 2011-03-21 Kai Tietz <ktietz@redhat.com> PR target/12171 * g++.dg/plugin/attribute_plugin.c: Adjust test. ChangeLog gcc/java 2011-03-21 Kai Tietz <ktietz@redhat.com> PR target/12171 * lang.c (java_attribute_table): Adjust table. ChangeLog gcc/lto 2011-03-21 Kai Tietz <ktietz@redhat.com> PR target/12171 * lto-lang.c (lto_attribute_table): Adjust table. ChangeLog gcc/ada 2011-03-21 Kai Tietz <ktietz@redhat.com> PR target/12171 * gcc-interface/utils.c (gnat_internal_attribute_table): Add new element. ChangeLog gcc/c-family 2011-03-17 Kai Tietz PR target/12171 * c-common.c (c_common_attribute_table): Add new element. (c_common_format_attribute_table): Likewise. From-SVN: r171209
2011-03-21 09:29:36 +01:00
{ NULL, 0, 0, false, false, false, NULL, false }
};
/* Return base name of the attribute. Ie '__attr__' is turned into 'attr'.
To avoid need for copying, we simply return length of the string. */
static void
extract_attribute_substring (struct substring *str)
{
if (str->length > 4 && str->str[0] == '_' && str->str[1] == '_'
&& str->str[str->length - 1] == '_' && str->str[str->length - 2] == '_')
{
str->length -= 4;
str->str += 2;
}
}
/* Simple hash function to avoid need to scan whole string. */
static inline hashval_t
substring_hash (const char *str, int l)
{
return str[0] + str[l - 1] * 256 + l * 65536;
}
/* Used for attribute_hash. */
static hashval_t
hash_attr (const void *p)
{
attribs.c (hash_attr, [...]): Constify. * attribs.c (hash_attr, eq_attr, init_attributes): Constify. * builtins.c (validate_arg, builtin_mathfn_code, validate_arglist): Likewise. * calls.c (call_expr_flags): Likewise. * combine.c (reg_nonzero_bits_for_combine, reg_num_sign_bit_copies_for_combine, get_last_value, reg_truncated_to_mode): Likewise. * emit-rtl.c (subreg_lowpart_p): Likewise. * expr.c (highest_pow2_factor_for_target, categorize_ctor_elements_1, categorize_ctor_elements, count_type_elements, contains_packed_reference, highest_pow2_factor, highest_pow2_factor_for_target): Likewise. * fold-const.c (may_negate_without_overflow_p, int_const_binop, fold_convertible_p, operand_equal_p, tree_swap_operands_p, native_encode_int, native_encode_real, native_encode_complex, native_encode_vector, native_encode_expr, native_interpret_int, native_interpret_real, native_interpret_complex, native_interpret_vector, native_interpret_expr): Likewise. * function.c (use_register_for_decl): Likewise. * gimplify.c (get_name): Likewise. * langhooks-def.h (lhd_return_null_const_tree): New. (LANG_HOOKS_GET_CALLEE_FNDECL): Use it. * langhooks.c (lhd_return_null_const_tree): New. * langhooks.h (lang_get_callee_fndecl): Constify. * output.h (constructor_static_from_elts_p): Likewise. * rtl-factoring.c (gen_symbol_ref_rtx_for_label): Likewise. * rtl.h (nonzero_bits, num_sign_bit_copies, truncated_to_mode, subreg_lowpart_p, noop_move_p, struct rtl_hooks): Likewise. * rtlanal.c (cached_nonzero_bits, nonzero_bits1, cached_num_sign_bit_copies, num_sign_bit_copies1, noop_move_p, nonzero_bits, num_sign_bit_copies, truncated_to_mode): Likewise. * rtlhooks-def.h (reg_nonzero_bits_general, reg_num_sign_bit_copies_general, reg_truncated_to_mode_general): Likewise. * rtlhooks.c (reg_num_sign_bit_copies_general, reg_nonzero_bits_general, reg_truncated_to_mode_general): Likewise. * stmt.c (warn_if_unused_value, is_body_block): Likewise. * stor-layout.c (mode_for_size_tree): Likewise. * tree-ssa-loop-im.c (memref_eq): Likewise. * tree-ssa-loop-ivopts.c (tree_int_cst_sign_bit): Likewise. * tree.c (contains_placeholder_p, type_list_equal, simple_cst_equal, get_callee_fndecl, operand_equal_for_phi_arg_p): Likewise. * tree.h (tree_int_cst_sign_bit, may_negate_without_overflow_p, mode_for_size_tree, categorize_ctor_elements, count_type_elements, contains_placeholder_p, contains_packed_reference, get_callee_fndecl, operand_equal_for_phi_arg_p, warn_if_unused_value, is_body_block, native_encode_expr, native_interpret_expr, fold_convertible_p, operand_equal_p, int_const_binop, tree_swap_operands_p, builtin_mathfn_code, validate_arglist, simple_cst_equal, type_list_equal, use_register_for_decl, call_expr_flags, get_name, highest_pow2_factor): Likewise. (const_call_expr_arg_iterator_d, init_const_call_expr_arg_iterator, next_const_call_expr_arg, first_const_call_expr_arg, more_const_call_expr_args_p, FOR_EACH_CONST_CALL_EXPR_ARG): New. * varasm.c (constructor_static_from_elts_p): Constify. cp: * parser.c (eof_token): Un-constify. (cp_lexer_new_main, cp_lexer_new_from_tokens, VEC_alloc, cp_lexer_consume_token, cp_lexer_purge_token): Remove spurious casts. java: * lang.c (java_get_callee_fndecl): Constify. objc: * objc-act.c (objc_get_callee_fndecl): Constify. * objc-act.h (objc_get_callee_fndecl): Likewise. From-SVN: r127036
2007-07-29 07:43:43 +02:00
const struct attribute_spec *const spec = (const struct attribute_spec *) p;
const int l = strlen (spec->name);
return substring_hash (spec->name, l);
}
/* Used for attribute_hash. */
static int
eq_attr (const void *p, const void *q)
{
attribs.c (hash_attr, [...]): Constify. * attribs.c (hash_attr, eq_attr, init_attributes): Constify. * builtins.c (validate_arg, builtin_mathfn_code, validate_arglist): Likewise. * calls.c (call_expr_flags): Likewise. * combine.c (reg_nonzero_bits_for_combine, reg_num_sign_bit_copies_for_combine, get_last_value, reg_truncated_to_mode): Likewise. * emit-rtl.c (subreg_lowpart_p): Likewise. * expr.c (highest_pow2_factor_for_target, categorize_ctor_elements_1, categorize_ctor_elements, count_type_elements, contains_packed_reference, highest_pow2_factor, highest_pow2_factor_for_target): Likewise. * fold-const.c (may_negate_without_overflow_p, int_const_binop, fold_convertible_p, operand_equal_p, tree_swap_operands_p, native_encode_int, native_encode_real, native_encode_complex, native_encode_vector, native_encode_expr, native_interpret_int, native_interpret_real, native_interpret_complex, native_interpret_vector, native_interpret_expr): Likewise. * function.c (use_register_for_decl): Likewise. * gimplify.c (get_name): Likewise. * langhooks-def.h (lhd_return_null_const_tree): New. (LANG_HOOKS_GET_CALLEE_FNDECL): Use it. * langhooks.c (lhd_return_null_const_tree): New. * langhooks.h (lang_get_callee_fndecl): Constify. * output.h (constructor_static_from_elts_p): Likewise. * rtl-factoring.c (gen_symbol_ref_rtx_for_label): Likewise. * rtl.h (nonzero_bits, num_sign_bit_copies, truncated_to_mode, subreg_lowpart_p, noop_move_p, struct rtl_hooks): Likewise. * rtlanal.c (cached_nonzero_bits, nonzero_bits1, cached_num_sign_bit_copies, num_sign_bit_copies1, noop_move_p, nonzero_bits, num_sign_bit_copies, truncated_to_mode): Likewise. * rtlhooks-def.h (reg_nonzero_bits_general, reg_num_sign_bit_copies_general, reg_truncated_to_mode_general): Likewise. * rtlhooks.c (reg_num_sign_bit_copies_general, reg_nonzero_bits_general, reg_truncated_to_mode_general): Likewise. * stmt.c (warn_if_unused_value, is_body_block): Likewise. * stor-layout.c (mode_for_size_tree): Likewise. * tree-ssa-loop-im.c (memref_eq): Likewise. * tree-ssa-loop-ivopts.c (tree_int_cst_sign_bit): Likewise. * tree.c (contains_placeholder_p, type_list_equal, simple_cst_equal, get_callee_fndecl, operand_equal_for_phi_arg_p): Likewise. * tree.h (tree_int_cst_sign_bit, may_negate_without_overflow_p, mode_for_size_tree, categorize_ctor_elements, count_type_elements, contains_placeholder_p, contains_packed_reference, get_callee_fndecl, operand_equal_for_phi_arg_p, warn_if_unused_value, is_body_block, native_encode_expr, native_interpret_expr, fold_convertible_p, operand_equal_p, int_const_binop, tree_swap_operands_p, builtin_mathfn_code, validate_arglist, simple_cst_equal, type_list_equal, use_register_for_decl, call_expr_flags, get_name, highest_pow2_factor): Likewise. (const_call_expr_arg_iterator_d, init_const_call_expr_arg_iterator, next_const_call_expr_arg, first_const_call_expr_arg, more_const_call_expr_args_p, FOR_EACH_CONST_CALL_EXPR_ARG): New. * varasm.c (constructor_static_from_elts_p): Constify. cp: * parser.c (eof_token): Un-constify. (cp_lexer_new_main, cp_lexer_new_from_tokens, VEC_alloc, cp_lexer_consume_token, cp_lexer_purge_token): Remove spurious casts. java: * lang.c (java_get_callee_fndecl): Constify. objc: * objc-act.c (objc_get_callee_fndecl): Constify. * objc-act.h (objc_get_callee_fndecl): Likewise. From-SVN: r127036
2007-07-29 07:43:43 +02:00
const struct attribute_spec *const spec = (const struct attribute_spec *) p;
const struct substring *const str = (const struct substring *) q;
return (!strncmp (spec->name, str->str, str->length) && !spec->name[str->length]);
}
/* Initialize attribute tables, and make some sanity checks
if --enable-checking. */
void
init_attributes (void)
{
size_t i;
int k;
if (attributes_initialized)
return;
attribs.c (c_common_attribute_table): Move table and handlers to c-common.c. * attribs.c (c_common_attribute_table): Move table and handlers to c-common.c. (format_attribute_table, lang_attribute_table, lang_attribute_common): Remove. (init_attributes): Replace NULL pointers with pointers to the empty table. (handle_packed_attribute, handle_nocommon_attribute, handle_common_attribute, handle_noreturn_attribute, handle_noinline_attribute, handle_always_inline_attribute, handle_used_attribute, handle_unused_attribute, handle_const_attribute, handle_transparent_union_attribute, handle_constructor_attribute, handle_destructor_attribute, handle_mode_attribute, handle_section_attribute, handle_aligned_attribute, handle_weak_attribute, handle_alias_attribute, handle_visibility_attribute, handle_no_instrument_function_attribute, handle_malloc_attribute, handle_no_limit_stack_attribute, handle_pure_attribute, handle_deprecated_attribute, handle_vector_size_attribute, vector_size_helper): Move to c-common.c. * c-common.c (c_common_attribute_table, handle_packed_attribute, handle_nocommon_attribute, handle_common_attribute, handle_noreturn_attribute, handle_noinline_attribute, handle_always_inline_attribute, handle_used_attribute, handle_unused_attribute, handle_const_attribute, handle_transparent_union_attribute, handle_constructor_attribute, handle_destructor_attribute, handle_mode_attribute, handle_section_attribute, handle_aligned_attribute, handle_weak_attribute, handle_alias_attribute, handle_visibility_attribute, handle_no_instrument_function_attribute, handle_malloc_attribute, handle_no_limit_stack_attribute, handle_pure_attribute, handle_deprecated_attribute, handle_vector_size_attribute, vector_size_helper): Move from attribs.c. * c-common.h (c_common_attribute_table, c_common_format_attribute_table): New. * c-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Redefine. * langhooks-def.h (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_ATTRIBUTE_TABLE): New. (LANG_HOOKS_INITIALIZER): Update. * langhooks.h (struct lang_hooks): 3 new attribute hooks. * target-def.h (TARGET_ATTRIBUTE_TABLE): Default to NULL. * target.h: Update comment. * tree.c (default_target_attribute_table): Remove. * tree.h (default_target_attribute_table, format_attribute_table, lang_attribute_table, lang_attribute_common): Remove. ada: * misc.c (gnat_init): Don't set lang_attribute_common. cp: * cp-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, LANG_HOOKS_ATTRIBUTE_TABLE): Redefine. * cp-tree.h (cp_attribute_table): Rename. * decl.c (lang_attribute_table): Remove declaration. (cxx_init_decl_processing): Don't set it. * tree.c (cp_attribute_table): Rename. objc: * objc-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Redefine. From-SVN: r52730
2002-04-24 22:41:04 +02:00
attribute_tables[0] = lang_hooks.common_attribute_table;
attribute_tables[1] = lang_hooks.attribute_table;
attribute_tables[2] = lang_hooks.format_attribute_table;
attribute_tables[3] = targetm.attribute_table;
attribs.c (c_common_attribute_table): Move table and handlers to c-common.c. * attribs.c (c_common_attribute_table): Move table and handlers to c-common.c. (format_attribute_table, lang_attribute_table, lang_attribute_common): Remove. (init_attributes): Replace NULL pointers with pointers to the empty table. (handle_packed_attribute, handle_nocommon_attribute, handle_common_attribute, handle_noreturn_attribute, handle_noinline_attribute, handle_always_inline_attribute, handle_used_attribute, handle_unused_attribute, handle_const_attribute, handle_transparent_union_attribute, handle_constructor_attribute, handle_destructor_attribute, handle_mode_attribute, handle_section_attribute, handle_aligned_attribute, handle_weak_attribute, handle_alias_attribute, handle_visibility_attribute, handle_no_instrument_function_attribute, handle_malloc_attribute, handle_no_limit_stack_attribute, handle_pure_attribute, handle_deprecated_attribute, handle_vector_size_attribute, vector_size_helper): Move to c-common.c. * c-common.c (c_common_attribute_table, handle_packed_attribute, handle_nocommon_attribute, handle_common_attribute, handle_noreturn_attribute, handle_noinline_attribute, handle_always_inline_attribute, handle_used_attribute, handle_unused_attribute, handle_const_attribute, handle_transparent_union_attribute, handle_constructor_attribute, handle_destructor_attribute, handle_mode_attribute, handle_section_attribute, handle_aligned_attribute, handle_weak_attribute, handle_alias_attribute, handle_visibility_attribute, handle_no_instrument_function_attribute, handle_malloc_attribute, handle_no_limit_stack_attribute, handle_pure_attribute, handle_deprecated_attribute, handle_vector_size_attribute, vector_size_helper): Move from attribs.c. * c-common.h (c_common_attribute_table, c_common_format_attribute_table): New. * c-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Redefine. * langhooks-def.h (LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_ATTRIBUTE_TABLE): New. (LANG_HOOKS_INITIALIZER): Update. * langhooks.h (struct lang_hooks): 3 new attribute hooks. * target-def.h (TARGET_ATTRIBUTE_TABLE): Default to NULL. * target.h: Update comment. * tree.c (default_target_attribute_table): Remove. * tree.h (default_target_attribute_table, format_attribute_table, lang_attribute_table, lang_attribute_common): Remove. ada: * misc.c (gnat_init): Don't set lang_attribute_common. cp: * cp-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, LANG_HOOKS_ATTRIBUTE_TABLE): Redefine. * cp-tree.h (cp_attribute_table): Rename. * decl.c (lang_attribute_table): Remove declaration. (cxx_init_decl_processing): Don't set it. * tree.c (cp_attribute_table): Rename. objc: * objc-lang.c (LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE): Redefine. From-SVN: r52730
2002-04-24 22:41:04 +02:00
/* Translate NULL pointers to pointers to the empty table. */
for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
if (attribute_tables[i] == NULL)
attribute_tables[i] = empty_attribute_table;
#ifdef ENABLE_CHECKING
/* Make some sanity checks on the attribute tables. */
for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
{
int j;
for (j = 0; attribute_tables[i][j].name != NULL; j++)
{
/* The name must not begin and end with __. */
const char *name = attribute_tables[i][j].name;
int len = strlen (name);
2006-05-19 00:16:23 +02:00
gcc_assert (!(name[0] == '_' && name[1] == '_'
&& name[len - 1] == '_' && name[len - 2] == '_'));
2006-05-19 00:16:23 +02:00
/* The minimum and maximum lengths must be consistent. */
gcc_assert (attribute_tables[i][j].min_length >= 0);
2006-05-19 00:16:23 +02:00
gcc_assert (attribute_tables[i][j].max_length == -1
|| (attribute_tables[i][j].max_length
>= attribute_tables[i][j].min_length));
2006-05-19 00:16:23 +02:00
/* An attribute cannot require both a DECL and a TYPE. */
gcc_assert (!attribute_tables[i][j].decl_required
|| !attribute_tables[i][j].type_required);
2006-05-19 00:16:23 +02:00
/* If an attribute requires a function type, in particular
it requires a type. */
gcc_assert (!attribute_tables[i][j].function_type_required
|| attribute_tables[i][j].type_required);
}
}
/* Check that each name occurs just once in each table. */
for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
{
int j, k;
for (j = 0; attribute_tables[i][j].name != NULL; j++)
for (k = j + 1; attribute_tables[i][k].name != NULL; k++)
gcc_assert (strcmp (attribute_tables[i][j].name,
attribute_tables[i][k].name));
}
/* Check that no name occurs in more than one table. */
for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
{
size_t j, k, l;
for (j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
for (k = 0; attribute_tables[i][k].name != NULL; k++)
for (l = 0; attribute_tables[j][l].name != NULL; l++)
gcc_assert (strcmp (attribute_tables[i][k].name,
attribute_tables[j][l].name));
}
#endif
attribute_hash = htab_create (200, hash_attr, eq_attr, NULL);
for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
for (k = 0; attribute_tables[i][k].name != NULL; k++)
{
register_attribute (&attribute_tables[i][k]);
}
invoke_plugin_callbacks (PLUGIN_ATTRIBUTES, NULL);
attributes_initialized = true;
}
/* Insert a single ATTR into the attribute table. */
void
Remove trailing white spaces. 2009-11-25 H.J. Lu <hongjiu.lu@intel.com> * alias.c: Remove trailing white spaces. * alloc-pool.c: Likewise. * alloc-pool.h: Likewise. * attribs.c: Likewise. * auto-inc-dec.c: Likewise. * basic-block.h: Likewise. * bb-reorder.c: Likewise. * bt-load.c: Likewise. * builtins.c: Likewise. * builtins.def: Likewise. * c-common.c: Likewise. * c-common.h: Likewise. * c-cppbuiltin.c: Likewise. * c-decl.c: Likewise. * c-format.c: Likewise. * c-lex.c: Likewise. * c-omp.c: Likewise. * c-opts.c: Likewise. * c-parser.c: Likewise. * c-pretty-print.c: Likewise. * c-tree.h: Likewise. * c-typeck.c: Likewise. * caller-save.c: Likewise. * calls.c: Likewise. * cfg.c: Likewise. * cfganal.c: Likewise. * cfgexpand.c: Likewise. * cfghooks.c: Likewise. * cfghooks.h: Likewise. * cfglayout.c: Likewise. * cfgloop.c: Likewise. * cfgloop.h: Likewise. * cfgloopmanip.c: Likewise. * cfgrtl.c: Likewise. * cgraph.c: Likewise. * cgraph.h: Likewise. * cgraphbuild.c: Likewise. * cgraphunit.c: Likewise. * cif-code.def: Likewise. * collect2.c: Likewise. * combine.c: Likewise. * convert.c: Likewise. * coverage.c: Likewise. * crtstuff.c: Likewise. * cse.c: Likewise. * cselib.c: Likewise. * dbgcnt.c: Likewise. * dbgcnt.def: Likewise. * dbgcnt.h: Likewise. * dbxout.c: Likewise. * dce.c: Likewise. * ddg.c: Likewise. * ddg.h: Likewise. * defaults.h: Likewise. * df-byte-scan.c: Likewise. * df-core.c: Likewise. * df-problems.c: Likewise. * df-scan.c: Likewise. * df.h: Likewise. * dfp.c: Likewise. * diagnostic.c: Likewise. * diagnostic.h: Likewise. * dominance.c: Likewise. * domwalk.c: Likewise. * double-int.c: Likewise. * double-int.h: Likewise. * dse.c: Likewise. * dwarf2asm.c: Likewise. * dwarf2asm.h: Likewise. * dwarf2out.c: Likewise. * ebitmap.c: Likewise. * ebitmap.h: Likewise. * emit-rtl.c: Likewise. * et-forest.c: Likewise. * except.c: Likewise. * except.h: Likewise. * expmed.c: Likewise. * expr.c: Likewise. * expr.h: Likewise. * final.c: Likewise. * flags.h: Likewise. * fold-const.c: Likewise. * function.c: Likewise. * function.h: Likewise. * fwprop.c: Likewise. * gcc.c: Likewise. * gcov-dump.c: Likewise. * gcov-io.c: Likewise. * gcov-io.h: Likewise. * gcov.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * genattrtab.c: Likewise. * genautomata.c: Likewise. * genchecksum.c: Likewise. * genconfig.c: Likewise. * genflags.c: Likewise. * gengtype-parse.c: Likewise. * gengtype.c: Likewise. * gengtype.h: Likewise. * genmddeps.c: Likewise. * genmodes.c: Likewise. * genopinit.c: Likewise. * genpreds.c: Likewise. * gensupport.c: Likewise. * ggc-common.c: Likewise. * ggc-page.c: Likewise. * ggc-zone.c: Likewise. * ggc.h: Likewise. * gimple-iterator.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimple.c: Likewise. * gimple.def: Likewise. * gimple.h: Likewise. * gimplify.c: Likewise. * graphds.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * gthr-nks.h: Likewise. * gthr-posix.c: Likewise. * gthr-posix.h: Likewise. * gthr-posix95.h: Likewise. * gthr-single.h: Likewise. * gthr-tpf.h: Likewise. * gthr-vxworks.h: Likewise. * gthr.h: Likewise. * haifa-sched.c: Likewise. * hard-reg-set.h: Likewise. * hooks.c: Likewise. * hooks.h: Likewise. * hosthooks.h: Likewise. * hwint.h: Likewise. * ifcvt.c: Likewise. * incpath.c: Likewise. * init-regs.c: Likewise. * integrate.c: Likewise. * ipa-cp.c: Likewise. * ipa-inline.c: Likewise. * ipa-prop.c: Likewise. * ipa-pure-const.c: Likewise. * ipa-reference.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa-struct-reorg.h: Likewise. * ipa-type-escape.c: Likewise. * ipa-type-escape.h: Likewise. * ipa-utils.c: Likewise. * ipa-utils.h: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-conflicts.c: Likewise. * ira-costs.c: Likewise. * ira-emit.c: Likewise. * ira-int.h: Likewise. * ira-lives.c: Likewise. * ira.c: Likewise. * jump.c: Likewise. * lambda-code.c: Likewise. * lambda-mat.c: Likewise. * lambda-trans.c: Likewise. * lambda.h: Likewise. * langhooks.c: Likewise. * lcm.c: Likewise. * libgcov.c: Likewise. * lists.c: Likewise. * loop-doloop.c: Likewise. * loop-init.c: Likewise. * loop-invariant.c: Likewise. * loop-iv.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lto-cgraph.c: Likewise. * lto-compress.c: Likewise. * lto-opts.c: Likewise. * lto-section-in.c: Likewise. * lto-section-out.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * lto-streamer.h: Likewise. * lto-symtab.c: Likewise. * lto-wpa-fixup.c: Likewise. * matrix-reorg.c: Likewise. * mcf.c: Likewise. * mode-switching.c: Likewise. * modulo-sched.c: Likewise. * omega.c: Likewise. * omega.h: Likewise. * omp-low.c: Likewise. * optabs.c: Likewise. * optabs.h: Likewise. * opts-common.c: Likewise. * opts.c: Likewise. * params.def: Likewise. * params.h: Likewise. * passes.c: Likewise. * plugin.c: Likewise. * postreload-gcse.c: Likewise. * postreload.c: Likewise. * predict.c: Likewise. * predict.def: Likewise. * pretty-print.c: Likewise. * pretty-print.h: Likewise. * print-rtl.c: Likewise. * print-tree.c: Likewise. * profile.c: Likewise. * read-rtl.c: Likewise. * real.c: Likewise. * recog.c: Likewise. * reg-stack.c: Likewise. * regcprop.c: Likewise. * reginfo.c: Likewise. * regmove.c: Likewise. * regrename.c: Likewise. * regs.h: Likewise. * regstat.c: Likewise. * reload.c: Likewise. * reload1.c: Likewise. * resource.c: Likewise. * rtl.c: Likewise. * rtl.def: Likewise. * rtl.h: Likewise. * rtlanal.c: Likewise. * sbitmap.c: Likewise. * sched-deps.c: Likewise. * sched-ebb.c: Likewise. * sched-int.h: Likewise. * sched-rgn.c: Likewise. * sched-vis.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-dump.h: Likewise. * sel-sched-ir.c: Likewise. * sel-sched-ir.h: Likewise. * sel-sched.c: Likewise. * sel-sched.h: Likewise. * sese.c: Likewise. * sese.h: Likewise. * simplify-rtx.c: Likewise. * stack-ptr-mod.c: Likewise. * stmt.c: Likewise. * stor-layout.c: Likewise. * store-motion.c: Likewise. * stringpool.c: Likewise. * stub-objc.c: Likewise. * sync-builtins.def: Likewise. * target-def.h: Likewise. * target.h: Likewise. * targhooks.c: Likewise. * targhooks.h: Likewise. * timevar.c: Likewise. * tlink.c: Likewise. * toplev.c: Likewise. * toplev.h: Likewise. * tracer.c: Likewise. * tree-affine.c: Likewise. * tree-affine.h: Likewise. * tree-browser.def: Likewise. * tree-call-cdce.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-chrec.h: Likewise. * tree-complex.c: Likewise. * tree-data-ref.c: Likewise. * tree-data-ref.h: Likewise. * tree-dfa.c: Likewise. * tree-dump.c: Likewise. * tree-dump.h: Likewise. * tree-eh.c: Likewise. * tree-flow-inline.h: Likewise. * tree-flow.h: Likewise. * tree-if-conv.c: Likewise. * tree-inline.c: Likewise. * tree-into-ssa.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-loop-linear.c: Likewise. * tree-mudflap.c: Likewise. * tree-nested.c: Likewise. * tree-nomudflap.c: Likewise. * tree-nrv.c: Likewise. * tree-object-size.c: Likewise. * tree-optimize.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-pass.h: Likewise. * tree-phinodes.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-profile.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-ssa-address.c: Likewise. * tree-ssa-alias.c: Likewise. * tree-ssa-ccp.c: Likewise. * tree-ssa-coalesce.c: Likewise. * tree-ssa-copy.c: Likewise. * tree-ssa-copyrename.c: Likewise. * tree-ssa-dce.c: Likewise. * tree-ssa-dom.c: Likewise. * tree-ssa-dse.c: Likewise. * tree-ssa-forwprop.c: Likewise. * tree-ssa-ifcombine.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-live.h: Likewise. * tree-ssa-loop-ch.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-loop-unswitch.c: Likewise. * tree-ssa-loop.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-operands.c: Likewise. * tree-ssa-operands.h: Likewise. * tree-ssa-phiopt.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-propagate.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-sink.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa-ter.c: Likewise. * tree-ssa-threadedge.c: Likewise. * tree-ssa-threadupdate.c: Likewise. * tree-ssa-uncprop.c: Likewise. * tree-ssa.c: Likewise. * tree-ssanames.c: Likewise. * tree-switch-conversion.c: Likewise. * tree-tailcall.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-generic.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vectorizer.c: Likewise. * tree-vectorizer.h: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * tree.def: Likewise. * tree.h: Likewise. * treestruct.def: Likewise. * unwind-compat.c: Likewise. * unwind-dw2-fde-glibc.c: Likewise. * unwind-dw2.c: Likewise. * value-prof.c: Likewise. * value-prof.h: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * varpool.c: Likewise. * vec.c: Likewise. * vec.h: Likewise. * vmsdbgout.c: Likewise. * web.c: Likewise. * xcoffout.c: Likewise. From-SVN: r154645
2009-11-25 11:55:54 +01:00
register_attribute (const struct attribute_spec *attr)
{
struct substring str;
void **slot;
str.str = attr->name;
str.length = strlen (str.str);
/* Attribute names in the table must be in the form 'text' and not
in the form '__text__'. */
gcc_assert (str.length > 0 && str.str[0] != '_');
slot = htab_find_slot_with_hash (attribute_hash, &str,
substring_hash (str.str, str.length),
INSERT);
gcc_assert (!*slot);
*slot = (void *) CONST_CAST (struct attribute_spec *, attr);
}
/* Return the spec for the attribute named NAME. */
const struct attribute_spec *
lookup_attribute_spec (const_tree name)
{
struct substring attr;
attr.str = IDENTIFIER_POINTER (name);
attr.length = IDENTIFIER_LENGTH (name);
extract_attribute_substring (&attr);
alias.c (record_alias_subset, [...]): Fix -Wc++-compat and/or -Wcast-qual warnings. * alias.c (record_alias_subset, init_alias_analysis): Fix -Wc++-compat and/or -Wcast-qual warnings. * attribs.c (lookup_attribute_spec): Likewise. * bb-reorder.c (find_traces, rotate_loop, find_traces_1_round, copy_bb, connect_traces, find_rarely_executed_basic_blocks_and_cr): Likewise. * bt-load.c (find_btr_def_group, add_btr_def, new_btr_user, note_btr_set, migrate_btr_defs): Likewise. * builtins.c (result_vector, expand_builtin_memcpy, expand_builtin_mempcpy_args, expand_builtin_strncpy, builtin_memset_read_str, expand_builtin_printf, fold_builtin_memchr, rewrite_call_expr, fold_builtin_printf): Likewise. * caller-save.c (mark_set_regs): Likewise. * calls.c (expand_call, emit_library_call_value_1): Likewise. * cgraph.c (cgraph_edge): Likewise. * combine.c (likely_spilled_retval_1): Likewise. * coverage.c (htab_counts_entry_hash, htab_counts_entry_eq, htab_counts_entry_del, get_coverage_counts): Likewise. * cselib.c (new_elt_list, new_elt_loc_list, entry_and_rtx_equal_p, new_cselib_val): Likewise. * dbgcnt.c (dbg_cnt_process_opt): Likewise. * dbxout.c (dbxout_init, dbxout_type, output_used_types_helper): Likewise. * df-core.c (df_compact_blocks): Likewise. * df-problems.c (df_grow_bb_info, df_chain_create): Likewise. * df-scan.c (df_grow_reg_info, df_ref_create, df_insn_create_insn_record, df_insn_rescan, df_notes_rescan, df_ref_compare, df_ref_create_structure, df_bb_refs_record, df_record_entry_block_defs, df_record_exit_block_uses, df_bb_verify): Likewise. * df.h (DF_REF_EXTRACT_WIDTH_CONST, DF_REF_EXTRACT_OFFSET_CONST, DF_REF_EXTRACT_MODE_CONST): New. * dominance.c (get_immediate_dominator, get_dominated_by, nearest_common_dominator, root_of_dom_tree, iterate_fix_dominators, first_dom_son, next_dom_son): Fix -Wc++-compat and/or -Wcast-qual warnings. * dse.c (clear_alias_set_lookup, get_group_info, gen_rtx_MEM, record_store, replace_read, check_mem_read_rtx, scan_insn, dse_step1, dse_record_singleton_alias_set): Likewise. * dwarf2asm.c (dw2_force_const_mem): Likewise. From-SVN: r137137
2008-06-26 02:28:15 +02:00
return (const struct attribute_spec *)
htab_find_with_hash (attribute_hash, &attr,
substring_hash (attr.str, attr.length));
}
/* Process the attributes listed in ATTRIBUTES and install them in *NODE,
which is either a DECL (including a TYPE_DECL) or a TYPE. If a DECL,
it should be modified in place; if a TYPE, a copy should be created
unless ATTR_FLAG_TYPE_IN_PLACE is set in FLAGS. FLAGS gives further
information, in the form of a bitwise OR of flags in enum attribute_flags
from tree.h. Depending on these flags, some attributes may be
returned to be applied at a later stage (for example, to apply
a decl attribute to the declaration rather than to its type). */
tree
decl_attributes (tree *node, tree attributes, int flags)
{
tree a;
tree returned_attrs = NULL_TREE;
if (TREE_TYPE (*node) == error_mark_node)
return NULL_TREE;
if (!attributes_initialized)
init_attributes ();
/* If this is a function and the user used #pragma GCC optimize, add the
options to the attribute((optimize(...))) list. */
if (TREE_CODE (*node) == FUNCTION_DECL && current_optimize_pragma)
{
tree cur_attr = lookup_attribute ("optimize", attributes);
tree opts = copy_list (current_optimize_pragma);
if (! cur_attr)
attributes
= tree_cons (get_identifier ("optimize"), opts, attributes);
else
TREE_VALUE (cur_attr) = chainon (opts, TREE_VALUE (cur_attr));
}
if (TREE_CODE (*node) == FUNCTION_DECL
&& optimization_current_node != optimization_default_node
&& !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node))
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = optimization_current_node;
/* If this is a function and the user used #pragma GCC target, add the
options to the attribute((target(...))) list. */
if (TREE_CODE (*node) == FUNCTION_DECL
&& current_target_pragma
&& targetm.target_option.valid_attribute_p (*node, NULL_TREE,
current_target_pragma, 0))
{
tree cur_attr = lookup_attribute ("target", attributes);
tree opts = copy_list (current_target_pragma);
if (! cur_attr)
attributes = tree_cons (get_identifier ("target"), opts, attributes);
else
TREE_VALUE (cur_attr) = chainon (opts, TREE_VALUE (cur_attr));
}
/* A "naked" function attribute implies "noinline" and "noclone" for
those targets that support it. */
if (TREE_CODE (*node) == FUNCTION_DECL
&& attributes
&& lookup_attribute_spec (get_identifier ("naked"))
&& lookup_attribute ("naked", attributes) != NULL)
{
if (lookup_attribute ("noinline", attributes) == NULL)
attributes = tree_cons (get_identifier ("noinline"), NULL, attributes);
if (lookup_attribute ("noclone", attributes) == NULL)
attributes = tree_cons (get_identifier ("noclone"), NULL, attributes);
}
targetm.insert_attributes (*node, &attributes);
for (a = attributes; a; a = TREE_CHAIN (a))
{
tree name = TREE_PURPOSE (a);
tree args = TREE_VALUE (a);
tree *anode = node;
const struct attribute_spec *spec = lookup_attribute_spec (name);
bool no_add_attrs = 0;
int fn_ptr_quals = 0;
tree fn_ptr_tmp = NULL_TREE;
if (spec == NULL)
{
attribs.c (decl_attributes): Use %qE for identifiers in diagnostics. * attribs.c (decl_attributes): Use %qE for identifiers in diagnostics. * cgraphunit.c (verify_cgraph_node): Translate function names to locale character set in diagnostics. * coverage.c (get_coverage_counts): Use %qE for identifiers in diagnostics. * doc/invoke.texi (-finstrument-functions-exclude-function-list): Document that functions are named in UTF-8. * expr.c (expand_expr_real_1): Translate function names to locale character set in diagnostics. * gimplify.c (omp_notice_variable, omp_is_private, gimplify_scan_omp_clauses): Use %qE for identifiers in diagnostics. * langhooks.c (lhd_print_error_function): Translate function names to locale character set. * langhooks.h (decl_printable_name): Document that return value is in internal character set. * stmt.c: Include pretty-print.h (tree_conflicts_with_clobbers_p): Use %qE for identifiers in diagnostics. (resolve_operand_name_1): Translate named operand name to locale character set. * stor-layout.c (finalize_record_size): Use %qE for identifiers in diagnostics. * toplev.c (announce_function): Translate function names to locale character set. (warn_deprecated_use): Use %qE for identifiers in diagnostics. (default_tree_printer): Use pp_identifier or translate identifiers to locale character set. Mark "<anonymous>" for translation. * tree-mudflap.c (mx_register_decls, mudflap_finish_file): Use %qE for identifiers in diagnostics. * tree.c (handle_dll_attribute): Use %qE for identifiers in diagnostics. * varasm.c (output_constructor): Use %qE for identifiers in diagnostics. testsuite: * gcc.dg/ucnid-11.c, gcc.dg/ucnid-12.c, gcc.dg/ucnid-13.c: New tests. From-SVN: r147111
2009-05-05 01:44:36 +02:00
warning (OPT_Wattributes, "%qE attribute directive ignored",
name);
continue;
}
else if (list_length (args) < spec->min_length
|| (spec->max_length >= 0
&& list_length (args) > spec->max_length))
{
attribs.c (decl_attributes): Use %qE for identifiers in diagnostics. * attribs.c (decl_attributes): Use %qE for identifiers in diagnostics. * cgraphunit.c (verify_cgraph_node): Translate function names to locale character set in diagnostics. * coverage.c (get_coverage_counts): Use %qE for identifiers in diagnostics. * doc/invoke.texi (-finstrument-functions-exclude-function-list): Document that functions are named in UTF-8. * expr.c (expand_expr_real_1): Translate function names to locale character set in diagnostics. * gimplify.c (omp_notice_variable, omp_is_private, gimplify_scan_omp_clauses): Use %qE for identifiers in diagnostics. * langhooks.c (lhd_print_error_function): Translate function names to locale character set. * langhooks.h (decl_printable_name): Document that return value is in internal character set. * stmt.c: Include pretty-print.h (tree_conflicts_with_clobbers_p): Use %qE for identifiers in diagnostics. (resolve_operand_name_1): Translate named operand name to locale character set. * stor-layout.c (finalize_record_size): Use %qE for identifiers in diagnostics. * toplev.c (announce_function): Translate function names to locale character set. (warn_deprecated_use): Use %qE for identifiers in diagnostics. (default_tree_printer): Use pp_identifier or translate identifiers to locale character set. Mark "<anonymous>" for translation. * tree-mudflap.c (mx_register_decls, mudflap_finish_file): Use %qE for identifiers in diagnostics. * tree.c (handle_dll_attribute): Use %qE for identifiers in diagnostics. * varasm.c (output_constructor): Use %qE for identifiers in diagnostics. testsuite: * gcc.dg/ucnid-11.c, gcc.dg/ucnid-12.c, gcc.dg/ucnid-13.c: New tests. From-SVN: r147111
2009-05-05 01:44:36 +02:00
error ("wrong number of arguments specified for %qE attribute",
name);
continue;
}
gcc_assert (is_attribute_p (spec->name, name));
if (spec->decl_required && !DECL_P (*anode))
{
if (flags & ((int) ATTR_FLAG_DECL_NEXT
| (int) ATTR_FLAG_FUNCTION_NEXT
| (int) ATTR_FLAG_ARRAY_NEXT))
{
/* Pass on this attribute to be tried again. */
returned_attrs = tree_cons (name, args, returned_attrs);
continue;
}
else
{
attribs.c (decl_attributes): Use %qE for identifiers in diagnostics. * attribs.c (decl_attributes): Use %qE for identifiers in diagnostics. * cgraphunit.c (verify_cgraph_node): Translate function names to locale character set in diagnostics. * coverage.c (get_coverage_counts): Use %qE for identifiers in diagnostics. * doc/invoke.texi (-finstrument-functions-exclude-function-list): Document that functions are named in UTF-8. * expr.c (expand_expr_real_1): Translate function names to locale character set in diagnostics. * gimplify.c (omp_notice_variable, omp_is_private, gimplify_scan_omp_clauses): Use %qE for identifiers in diagnostics. * langhooks.c (lhd_print_error_function): Translate function names to locale character set. * langhooks.h (decl_printable_name): Document that return value is in internal character set. * stmt.c: Include pretty-print.h (tree_conflicts_with_clobbers_p): Use %qE for identifiers in diagnostics. (resolve_operand_name_1): Translate named operand name to locale character set. * stor-layout.c (finalize_record_size): Use %qE for identifiers in diagnostics. * toplev.c (announce_function): Translate function names to locale character set. (warn_deprecated_use): Use %qE for identifiers in diagnostics. (default_tree_printer): Use pp_identifier or translate identifiers to locale character set. Mark "<anonymous>" for translation. * tree-mudflap.c (mx_register_decls, mudflap_finish_file): Use %qE for identifiers in diagnostics. * tree.c (handle_dll_attribute): Use %qE for identifiers in diagnostics. * varasm.c (output_constructor): Use %qE for identifiers in diagnostics. testsuite: * gcc.dg/ucnid-11.c, gcc.dg/ucnid-12.c, gcc.dg/ucnid-13.c: New tests. From-SVN: r147111
2009-05-05 01:44:36 +02:00
warning (OPT_Wattributes, "%qE attribute does not apply to types",
name);
continue;
}
}
/* If we require a type, but were passed a decl, set up to make a
new type and update the one in the decl. ATTR_FLAG_TYPE_IN_PLACE
would have applied if we'd been passed a type, but we cannot modify
the decl's type in place here. */
if (spec->type_required && DECL_P (*anode))
{
anode = &TREE_TYPE (*anode);
/* Allow ATTR_FLAG_TYPE_IN_PLACE for the type's naming decl. */
if (!(TREE_CODE (*anode) == TYPE_DECL
&& *anode == TYPE_NAME (TYPE_MAIN_VARIANT
(TREE_TYPE (*anode)))))
flags &= ~(int) ATTR_FLAG_TYPE_IN_PLACE;
}
if (spec->function_type_required && TREE_CODE (*anode) != FUNCTION_TYPE
&& TREE_CODE (*anode) != METHOD_TYPE)
{
if (TREE_CODE (*anode) == POINTER_TYPE
&& (TREE_CODE (TREE_TYPE (*anode)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (*anode)) == METHOD_TYPE))
{
/* OK, this is a bit convoluted. We can't just make a copy
of the pointer type and modify its TREE_TYPE, because if
we change the attributes of the target type the pointer
type needs to have a different TYPE_MAIN_VARIANT. So we
pull out the target type now, frob it as appropriate, and
rebuild the pointer type later.
2006-05-19 00:16:23 +02:00
This would all be simpler if attributes were part of the
declarator, grumble grumble. */
fn_ptr_tmp = TREE_TYPE (*anode);
fn_ptr_quals = TYPE_QUALS (*anode);
anode = &fn_ptr_tmp;
flags &= ~(int) ATTR_FLAG_TYPE_IN_PLACE;
}
else if (flags & (int) ATTR_FLAG_FUNCTION_NEXT)
{
/* Pass on this attribute to be tried again. */
returned_attrs = tree_cons (name, args, returned_attrs);
continue;
}
if (TREE_CODE (*anode) != FUNCTION_TYPE
&& TREE_CODE (*anode) != METHOD_TYPE)
{
common.opt (-Wattributes): New. * common.opt (-Wattributes): New. Default true. * doc/invoke.texi (-Wno-attributes): Document. * attribs.c (decl_attributes): Move warning control from if() to warning(OPT_*). * c-common.c (handle_packed_attribute): Likewise. (handle_nocommon_attribute): Likewise. (handle_common_attribute): Likewise. (handle_noreturn_attribute): Likewise. (handle_noinline_attribute): Likewise. (handle_always_inline_attribute): Likewise. (handle_used_attribute): Likewise. (handle_unused_attribute): Likewise. (handle_const_attribute): Likewise. (handle_transparent_union_attribute): Likewise. (handle_constructor_attribute): Likewise. (handle_destructor_attribute): Likewise. (handle_mode_attribute): Likewise. (handle_alias_attribute): Likewise. (handle_visibility_attribute): Likewise. (handle_tls_model_attribute): Likewise. (handle_malloc_attribute): Likewise. (handle_returns_twice_attribute): Likewise. (handle_pure_attribute): Likewise. (handle_deprecated_attribute): Likewise. (handle_vector_size_attribute): Likewise. (handle_nothrow_attribute): Likewise. (handle_cleanup_attribute): Likewise. (handle_warn_unused_result_attribute): Likewise. (handle_sentinel_attribute): Likewise. * c-decl.c (diagnose_mismatched_decls): Likewise. (start_decl): Likewise. (grokdeclarator): Likewise. (start_function): Likewise. * c-format.c (check_function_format): Likewise. * stor-layout.c (place_field): Likewise. (finalize_record_size): Likewise. * tree.c (handle_dll_attribute)): Likewise. * varasm.c (default_assemble_visibility): Likewise. * config/darwin.c (darwin_handle_weak_import_attribute): Likewise. (darwin_assemble_visibility): Likewise. * config/arc/arc.c (arc_handle_interrupt_attribute): Likewise. * config/arm/arm.c (arm_handle_fndecl_attribute): Likewise. (arm_handle_isr_attribute): Likewise. * config/avr/avr.c (avr_handle_progmem_attribute): Likewise. (avr_handle_fndecl_attribute): Likewise. * config/bfin/bfin.c (handle_int_attribute): Likewise. * config/c4x/c4x.c (c4x_handle_fntype_attribute): Likewise. * config/h8300/h8300.c (h8300_handle_fndecl_attribute): Likewise. (h8300_handle_eightbit_data_attribute): Likewise. (h8300_handle_tiny_data_attribute): Likewise. * config/i386/i386.c (ix86_handle_cdecl_attribute): Likewise. (ix86_handle_regparm_attribute): Likewise. (ix86_handle_struct_attribute): Likewise. * config/i386/winnt.c (ix86_handle_shared_attribute): Likewise. (i386_pe_encode_section_info): Likewise. * config/ia64/ia64.c (ia64_handle_model_attribute): Likewise. * config/ip2k/ip2k.c (ip2k_handle_progmem_attribute): Likewise. (ip2k_handle_fndecl_attribute): Likewise. * config/m32r/m32r.c (m32r_handle_model_attribute): Likewise. * config/m68hc11/m68hc11 (m68hc11_handle_page0_attribute): Likewise. (m68hc11_handle_fntype_attribute): Likewise. (m68hc11_encode_section_info): Likewise. * config/m68k/m68k.c (m68k_handle_fndecl_attribute): Likewise. * config/mcore/mcore.c (mcore_handle_naked_attribute): Likewise. * config/ns32k/ns32k.c (ns32k_handle_fntype_attribute): Likewise. * config/rs6000/rs6000.c (rs6000_handle_longcall_attribute): Likewise. * config/sh/sh.c (sh_handle_interrupt_handler_attribute): Likewise. (sh_handle_sp_switch_attribute): Likewise. (sh_handle_trap_exit_attribute): Likewise. * config/sh/symbian.c (sh_symbian_dllimport_p): Likewise. (sh_symbian_handle_dll_attribute): Likewise. * config/stormy16/stormy16.c (xstormy16_handle_interrupt_attribute): Likewise. (xstormy16_handle_below100_attribute): Likewise. * config/v850/v850.c (v850_handle_interrupt_attribute): Likewise. [testsuite] * gcc.dg/Wattributes-1.c: New. * gcc.dg/Wattributes-2.c: New. * gcc.dg/Wattributes-3.c: New. [cp] * decl.c (duplicate_decls): Move warning control from if() to warning(OPT_*). * name-lookup.c (parse_using_directive): Likewise. * parser.c (cp_parser_elaborated_type_specifier): Likewise. (cp_parser_init_declarator): Likewise. * tree.c (handle_com_interface_attribute): Likewise. [java] * class.c (set_constant_value): Move warning control from if() to warning(OPT_*). From-SVN: r100136
2005-05-25 06:18:19 +02:00
warning (OPT_Wattributes,
attribs.c (decl_attributes): Use %qE for identifiers in diagnostics. * attribs.c (decl_attributes): Use %qE for identifiers in diagnostics. * cgraphunit.c (verify_cgraph_node): Translate function names to locale character set in diagnostics. * coverage.c (get_coverage_counts): Use %qE for identifiers in diagnostics. * doc/invoke.texi (-finstrument-functions-exclude-function-list): Document that functions are named in UTF-8. * expr.c (expand_expr_real_1): Translate function names to locale character set in diagnostics. * gimplify.c (omp_notice_variable, omp_is_private, gimplify_scan_omp_clauses): Use %qE for identifiers in diagnostics. * langhooks.c (lhd_print_error_function): Translate function names to locale character set. * langhooks.h (decl_printable_name): Document that return value is in internal character set. * stmt.c: Include pretty-print.h (tree_conflicts_with_clobbers_p): Use %qE for identifiers in diagnostics. (resolve_operand_name_1): Translate named operand name to locale character set. * stor-layout.c (finalize_record_size): Use %qE for identifiers in diagnostics. * toplev.c (announce_function): Translate function names to locale character set. (warn_deprecated_use): Use %qE for identifiers in diagnostics. (default_tree_printer): Use pp_identifier or translate identifiers to locale character set. Mark "<anonymous>" for translation. * tree-mudflap.c (mx_register_decls, mudflap_finish_file): Use %qE for identifiers in diagnostics. * tree.c (handle_dll_attribute): Use %qE for identifiers in diagnostics. * varasm.c (output_constructor): Use %qE for identifiers in diagnostics. testsuite: * gcc.dg/ucnid-11.c, gcc.dg/ucnid-12.c, gcc.dg/ucnid-13.c: New tests. From-SVN: r147111
2009-05-05 01:44:36 +02:00
"%qE attribute only applies to function types",
name);
continue;
}
}
re PR c++/26905 (default-visibility class symbol improperly resolved as hidden-visibility) PR c++/26905 PR c++/26612 PR c++/27000 PR c++/26984 PR c++/19134 * tree.c (build_decl_stat): Don't hande #pragma visibility here. * c-common.c (c_determine_visibility): Handle it here. * c-decl.c (finish_decl): Call c_determine_visibility for functions, too. * flags.h (enum symbol_visibility): Sort from most to least visibility. * tree.h: Likewise. * varasm.c (default_assemble_visibility): Likewise. * c-common.c (handle_visibility_attribute): Complain about trying to give visibility to an already defined class, or trying to change declared visibility. Always attach the attribute. * cp/decl2.c (determine_visibility): Overhaul. (determine_visibility_from_class): Likewise. (min_vis_r, type_visibility, constrain_visibility): New fns. (constrain_visibility_for_template): Likewise. (constrain_class_visibility): Likewise. * cp/decl.c (cp_finish_decl): Call determine_visibility for function decls, too. * cp/name-lookup.c (pushtag): Call determine_visibility. * cp/decl.c (duplicate_decls): Don't copy visibility from template to specialization. * cp/pt.c (check_explicit_specialization): Likewise. (lookup_template_class, tsubst_decl): Call determine_visibility. * cp/class.c (finish_struct_1): Call constrain_class_visibility. PR c++/26905 PR c++/21675 PR c++/17470 * cp/parser.c (cp_parser_explicit_instantiation): Pass the attributes to grokdeclarator. (cp_parser_type_specifier): Allow 'enum __attribute ((...)) E'. (cp_parser_enum_specifier): Likewise. (cp_parser_elaborated_type_specifier): Apply attributes if this declares only the class. (cp_parser_class_specifier): Apply leading attributes immediately. * cp/semantics.c (begin_class_definition): Add attributes parameter, apply them to the type. * attribs.c (decl_attributes): Ignore type-in-place attributes once the type has been defined. PR c++/21581 PR c++/25915 * cp/tree.c (decl_anon_ns_mem_p): New function. * cp/cp-tree.h: Declare it. * cp/decl2.c (determine_visibility): Make anonymous namespace members static. (min_vis_r, constrain_visibility): Likewise. * cp/rtti.c (create_pseudo_type_info): Set TREE_PUBLIC on pseudo-types. * cp/decl.c (cxx_init_decl_processing): Set TREE_PUBLIC on global_namespace. * cp/name-lookup.c (push_namespace_with_attribs): Don't set TREE_PUBLIC on anonymous namespaces. From-SVN: r115086
2006-06-30 03:15:56 +02:00
if (TYPE_P (*anode)
&& (flags & (int) ATTR_FLAG_TYPE_IN_PLACE)
&& TYPE_SIZE (*anode) != NULL_TREE)
{
warning (OPT_Wattributes, "type attributes ignored after type is already defined");
continue;
}
if (spec->handler != NULL)
returned_attrs = chainon ((*spec->handler) (anode, name, args,
flags, &no_add_attrs),
returned_attrs);
/* Layout the decl in case anything changed. */
if (spec->type_required && DECL_P (*node)
&& (TREE_CODE (*node) == VAR_DECL
|| TREE_CODE (*node) == PARM_DECL
|| TREE_CODE (*node) == RESULT_DECL))
relayout_decl (*node);
if (!no_add_attrs)
{
tree old_attrs;
tree a;
if (DECL_P (*anode))
old_attrs = DECL_ATTRIBUTES (*anode);
else
old_attrs = TYPE_ATTRIBUTES (*anode);
for (a = lookup_attribute (spec->name, old_attrs);
a != NULL_TREE;
a = lookup_attribute (spec->name, TREE_CHAIN (a)))
{
if (simple_cst_equal (TREE_VALUE (a), args) == 1)
break;
}
if (a == NULL_TREE)
{
/* This attribute isn't already in the list. */
if (DECL_P (*anode))
DECL_ATTRIBUTES (*anode) = tree_cons (name, args, old_attrs);
else if (flags & (int) ATTR_FLAG_TYPE_IN_PLACE)
{
TYPE_ATTRIBUTES (*anode) = tree_cons (name, args, old_attrs);
/* If this is the main variant, also push the attributes
out to the other variants. */
if (*anode == TYPE_MAIN_VARIANT (*anode))
{
tree variant;
for (variant = *anode; variant;
variant = TYPE_NEXT_VARIANT (variant))
{
if (TYPE_ATTRIBUTES (variant) == old_attrs)
TYPE_ATTRIBUTES (variant)
= TYPE_ATTRIBUTES (*anode);
else if (!lookup_attribute
(spec->name, TYPE_ATTRIBUTES (variant)))
TYPE_ATTRIBUTES (variant) = tree_cons
(name, args, TYPE_ATTRIBUTES (variant));
}
}
}
else
*anode = build_type_attribute_variant (*anode,
tree_cons (name, args,
old_attrs));
}
}
if (fn_ptr_tmp)
{
/* Rebuild the function pointer type and put it in the
appropriate place. */
fn_ptr_tmp = build_pointer_type (fn_ptr_tmp);
if (fn_ptr_quals)
fn_ptr_tmp = build_qualified_type (fn_ptr_tmp, fn_ptr_quals);
if (DECL_P (*node))
TREE_TYPE (*node) = fn_ptr_tmp;
else
{
gcc_assert (TREE_CODE (*node) == POINTER_TYPE);
*node = fn_ptr_tmp;
}
}
}
return returned_attrs;
}