aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-attribs.cc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-01-14 16:56:44 +0100
committerMartin Liska <mliska@suse.cz>2022-01-17 22:12:04 +0100
commit5c69acb32329d49e58c26fa41ae74229a52b9106 (patch)
treeddb05f9d73afb6f998457d2ac4b720e3b3b60483 /gcc/c-family/c-attribs.cc
parent490e23032baaece71f2ec09fa1805064b150fbc2 (diff)
downloadgcc-5c69acb32329d49e58c26fa41ae74229a52b9106.zip
gcc-5c69acb32329d49e58c26fa41ae74229a52b9106.tar.gz
gcc-5c69acb32329d49e58c26fa41ae74229a52b9106.tar.bz2
Rename .c files to .cc files.
gcc/ada/ChangeLog: * adadecode.c: Moved to... * adadecode.cc: ...here. * affinity.c: Moved to... * affinity.cc: ...here. * argv-lynxos178-raven-cert.c: Moved to... * argv-lynxos178-raven-cert.cc: ...here. * argv.c: Moved to... * argv.cc: ...here. * aux-io.c: Moved to... * aux-io.cc: ...here. * cio.c: Moved to... * cio.cc: ...here. * cstreams.c: Moved to... * cstreams.cc: ...here. * env.c: Moved to... * env.cc: ...here. * exit.c: Moved to... * exit.cc: ...here. * expect.c: Moved to... * expect.cc: ...here. * final.c: Moved to... * final.cc: ...here. * gcc-interface/cuintp.c: Moved to... * gcc-interface/cuintp.cc: ...here. * gcc-interface/decl.c: Moved to... * gcc-interface/decl.cc: ...here. * gcc-interface/misc.c: Moved to... * gcc-interface/misc.cc: ...here. * gcc-interface/targtyps.c: Moved to... * gcc-interface/targtyps.cc: ...here. * gcc-interface/trans.c: Moved to... * gcc-interface/trans.cc: ...here. * gcc-interface/utils.c: Moved to... * gcc-interface/utils.cc: ...here. * gcc-interface/utils2.c: Moved to... * gcc-interface/utils2.cc: ...here. * init.c: Moved to... * init.cc: ...here. * initialize.c: Moved to... * initialize.cc: ...here. * libgnarl/thread.c: Moved to... * libgnarl/thread.cc: ...here. * link.c: Moved to... * link.cc: ...here. * locales.c: Moved to... * locales.cc: ...here. * mkdir.c: Moved to... * mkdir.cc: ...here. * raise.c: Moved to... * raise.cc: ...here. * rtfinal.c: Moved to... * rtfinal.cc: ...here. * rtinit.c: Moved to... * rtinit.cc: ...here. * seh_init.c: Moved to... * seh_init.cc: ...here. * sigtramp-armdroid.c: Moved to... * sigtramp-armdroid.cc: ...here. * sigtramp-ios.c: Moved to... * sigtramp-ios.cc: ...here. * sigtramp-qnx.c: Moved to... * sigtramp-qnx.cc: ...here. * sigtramp-vxworks.c: Moved to... * sigtramp-vxworks.cc: ...here. * socket.c: Moved to... * socket.cc: ...here. * tracebak.c: Moved to... * tracebak.cc: ...here. * version.c: Moved to... * version.cc: ...here. * vx_stack_info.c: Moved to... * vx_stack_info.cc: ...here. gcc/ChangeLog: * adjust-alignment.c: Moved to... * adjust-alignment.cc: ...here. * alias.c: Moved to... * alias.cc: ...here. * alloc-pool.c: Moved to... * alloc-pool.cc: ...here. * asan.c: Moved to... * asan.cc: ...here. * attribs.c: Moved to... * attribs.cc: ...here. * auto-inc-dec.c: Moved to... * auto-inc-dec.cc: ...here. * auto-profile.c: Moved to... * auto-profile.cc: ...here. * bb-reorder.c: Moved to... * bb-reorder.cc: ...here. * bitmap.c: Moved to... * bitmap.cc: ...here. * btfout.c: Moved to... * btfout.cc: ...here. * builtins.c: Moved to... * builtins.cc: ...here. * caller-save.c: Moved to... * caller-save.cc: ...here. * calls.c: Moved to... * calls.cc: ...here. * ccmp.c: Moved to... * ccmp.cc: ...here. * cfg.c: Moved to... * cfg.cc: ...here. * cfganal.c: Moved to... * cfganal.cc: ...here. * cfgbuild.c: Moved to... * cfgbuild.cc: ...here. * cfgcleanup.c: Moved to... * cfgcleanup.cc: ...here. * cfgexpand.c: Moved to... * cfgexpand.cc: ...here. * cfghooks.c: Moved to... * cfghooks.cc: ...here. * cfgloop.c: Moved to... * cfgloop.cc: ...here. * cfgloopanal.c: Moved to... * cfgloopanal.cc: ...here. * cfgloopmanip.c: Moved to... * cfgloopmanip.cc: ...here. * cfgrtl.c: Moved to... * cfgrtl.cc: ...here. * cgraph.c: Moved to... * cgraph.cc: ...here. * cgraphbuild.c: Moved to... * cgraphbuild.cc: ...here. * cgraphclones.c: Moved to... * cgraphclones.cc: ...here. * cgraphunit.c: Moved to... * cgraphunit.cc: ...here. * collect-utils.c: Moved to... * collect-utils.cc: ...here. * collect2-aix.c: Moved to... * collect2-aix.cc: ...here. * collect2.c: Moved to... * collect2.cc: ...here. * combine-stack-adj.c: Moved to... * combine-stack-adj.cc: ...here. * combine.c: Moved to... * combine.cc: ...here. * common/common-targhooks.c: Moved to... * common/common-targhooks.cc: ...here. * common/config/aarch64/aarch64-common.c: Moved to... * common/config/aarch64/aarch64-common.cc: ...here. * common/config/alpha/alpha-common.c: Moved to... * common/config/alpha/alpha-common.cc: ...here. * common/config/arc/arc-common.c: Moved to... * common/config/arc/arc-common.cc: ...here. * common/config/arm/arm-common.c: Moved to... * common/config/arm/arm-common.cc: ...here. * common/config/avr/avr-common.c: Moved to... * common/config/avr/avr-common.cc: ...here. * common/config/bfin/bfin-common.c: Moved to... * common/config/bfin/bfin-common.cc: ...here. * common/config/bpf/bpf-common.c: Moved to... * common/config/bpf/bpf-common.cc: ...here. * common/config/c6x/c6x-common.c: Moved to... * common/config/c6x/c6x-common.cc: ...here. * common/config/cr16/cr16-common.c: Moved to... * common/config/cr16/cr16-common.cc: ...here. * common/config/cris/cris-common.c: Moved to... * common/config/cris/cris-common.cc: ...here. * common/config/csky/csky-common.c: Moved to... * common/config/csky/csky-common.cc: ...here. * common/config/default-common.c: Moved to... * common/config/default-common.cc: ...here. * common/config/epiphany/epiphany-common.c: Moved to... * common/config/epiphany/epiphany-common.cc: ...here. * common/config/fr30/fr30-common.c: Moved to... * common/config/fr30/fr30-common.cc: ...here. * common/config/frv/frv-common.c: Moved to... * common/config/frv/frv-common.cc: ...here. * common/config/gcn/gcn-common.c: Moved to... * common/config/gcn/gcn-common.cc: ...here. * common/config/h8300/h8300-common.c: Moved to... * common/config/h8300/h8300-common.cc: ...here. * common/config/i386/i386-common.c: Moved to... * common/config/i386/i386-common.cc: ...here. * common/config/ia64/ia64-common.c: Moved to... * common/config/ia64/ia64-common.cc: ...here. * common/config/iq2000/iq2000-common.c: Moved to... * common/config/iq2000/iq2000-common.cc: ...here. * common/config/lm32/lm32-common.c: Moved to... * common/config/lm32/lm32-common.cc: ...here. * common/config/m32r/m32r-common.c: Moved to... * common/config/m32r/m32r-common.cc: ...here. * common/config/m68k/m68k-common.c: Moved to... * common/config/m68k/m68k-common.cc: ...here. * common/config/mcore/mcore-common.c: Moved to... * common/config/mcore/mcore-common.cc: ...here. * common/config/microblaze/microblaze-common.c: Moved to... * common/config/microblaze/microblaze-common.cc: ...here. * common/config/mips/mips-common.c: Moved to... * common/config/mips/mips-common.cc: ...here. * common/config/mmix/mmix-common.c: Moved to... * common/config/mmix/mmix-common.cc: ...here. * common/config/mn10300/mn10300-common.c: Moved to... * common/config/mn10300/mn10300-common.cc: ...here. * common/config/msp430/msp430-common.c: Moved to... * common/config/msp430/msp430-common.cc: ...here. * common/config/nds32/nds32-common.c: Moved to... * common/config/nds32/nds32-common.cc: ...here. * common/config/nios2/nios2-common.c: Moved to... * common/config/nios2/nios2-common.cc: ...here. * common/config/nvptx/nvptx-common.c: Moved to... * common/config/nvptx/nvptx-common.cc: ...here. * common/config/or1k/or1k-common.c: Moved to... * common/config/or1k/or1k-common.cc: ...here. * common/config/pa/pa-common.c: Moved to... * common/config/pa/pa-common.cc: ...here. * common/config/pdp11/pdp11-common.c: Moved to... * common/config/pdp11/pdp11-common.cc: ...here. * common/config/pru/pru-common.c: Moved to... * common/config/pru/pru-common.cc: ...here. * common/config/riscv/riscv-common.c: Moved to... * common/config/riscv/riscv-common.cc: ...here. * common/config/rs6000/rs6000-common.c: Moved to... * common/config/rs6000/rs6000-common.cc: ...here. * common/config/rx/rx-common.c: Moved to... * common/config/rx/rx-common.cc: ...here. * common/config/s390/s390-common.c: Moved to... * common/config/s390/s390-common.cc: ...here. * common/config/sh/sh-common.c: Moved to... * common/config/sh/sh-common.cc: ...here. * common/config/sparc/sparc-common.c: Moved to... * common/config/sparc/sparc-common.cc: ...here. * common/config/tilegx/tilegx-common.c: Moved to... * common/config/tilegx/tilegx-common.cc: ...here. * common/config/tilepro/tilepro-common.c: Moved to... * common/config/tilepro/tilepro-common.cc: ...here. * common/config/v850/v850-common.c: Moved to... * common/config/v850/v850-common.cc: ...here. * common/config/vax/vax-common.c: Moved to... * common/config/vax/vax-common.cc: ...here. * common/config/visium/visium-common.c: Moved to... * common/config/visium/visium-common.cc: ...here. * common/config/xstormy16/xstormy16-common.c: Moved to... * common/config/xstormy16/xstormy16-common.cc: ...here. * common/config/xtensa/xtensa-common.c: Moved to... * common/config/xtensa/xtensa-common.cc: ...here. * compare-elim.c: Moved to... * compare-elim.cc: ...here. * config/aarch64/aarch64-bti-insert.c: Moved to... * config/aarch64/aarch64-bti-insert.cc: ...here. * config/aarch64/aarch64-builtins.c: Moved to... * config/aarch64/aarch64-builtins.cc: ...here. * config/aarch64/aarch64-c.c: Moved to... * config/aarch64/aarch64-c.cc: ...here. * config/aarch64/aarch64-d.c: Moved to... * config/aarch64/aarch64-d.cc: ...here. * config/aarch64/aarch64.c: Moved to... * config/aarch64/aarch64.cc: ...here. * config/aarch64/cortex-a57-fma-steering.c: Moved to... * config/aarch64/cortex-a57-fma-steering.cc: ...here. * config/aarch64/driver-aarch64.c: Moved to... * config/aarch64/driver-aarch64.cc: ...here. * config/aarch64/falkor-tag-collision-avoidance.c: Moved to... * config/aarch64/falkor-tag-collision-avoidance.cc: ...here. * config/aarch64/host-aarch64-darwin.c: Moved to... * config/aarch64/host-aarch64-darwin.cc: ...here. * config/alpha/alpha.c: Moved to... * config/alpha/alpha.cc: ...here. * config/alpha/driver-alpha.c: Moved to... * config/alpha/driver-alpha.cc: ...here. * config/arc/arc-c.c: Moved to... * config/arc/arc-c.cc: ...here. * config/arc/arc.c: Moved to... * config/arc/arc.cc: ...here. * config/arc/driver-arc.c: Moved to... * config/arc/driver-arc.cc: ...here. * config/arm/aarch-common.c: Moved to... * config/arm/aarch-common.cc: ...here. * config/arm/arm-builtins.c: Moved to... * config/arm/arm-builtins.cc: ...here. * config/arm/arm-c.c: Moved to... * config/arm/arm-c.cc: ...here. * config/arm/arm-d.c: Moved to... * config/arm/arm-d.cc: ...here. * config/arm/arm.c: Moved to... * config/arm/arm.cc: ...here. * config/arm/driver-arm.c: Moved to... * config/arm/driver-arm.cc: ...here. * config/avr/avr-c.c: Moved to... * config/avr/avr-c.cc: ...here. * config/avr/avr-devices.c: Moved to... * config/avr/avr-devices.cc: ...here. * config/avr/avr-log.c: Moved to... * config/avr/avr-log.cc: ...here. * config/avr/avr.c: Moved to... * config/avr/avr.cc: ...here. * config/avr/driver-avr.c: Moved to... * config/avr/driver-avr.cc: ...here. * config/avr/gen-avr-mmcu-specs.c: Moved to... * config/avr/gen-avr-mmcu-specs.cc: ...here. * config/avr/gen-avr-mmcu-texi.c: Moved to... * config/avr/gen-avr-mmcu-texi.cc: ...here. * config/bfin/bfin.c: Moved to... * config/bfin/bfin.cc: ...here. * config/bpf/bpf.c: Moved to... * config/bpf/bpf.cc: ...here. * config/bpf/coreout.c: Moved to... * config/bpf/coreout.cc: ...here. * config/c6x/c6x.c: Moved to... * config/c6x/c6x.cc: ...here. * config/cr16/cr16.c: Moved to... * config/cr16/cr16.cc: ...here. * config/cris/cris.c: Moved to... * config/cris/cris.cc: ...here. * config/csky/csky.c: Moved to... * config/csky/csky.cc: ...here. * config/darwin-c.c: Moved to... * config/darwin-c.cc: ...here. * config/darwin-d.c: Moved to... * config/darwin-d.cc: ...here. * config/darwin-driver.c: Moved to... * config/darwin-driver.cc: ...here. * config/darwin-f.c: Moved to... * config/darwin-f.cc: ...here. * config/darwin.c: Moved to... * config/darwin.cc: ...here. * config/default-c.c: Moved to... * config/default-c.cc: ...here. * config/default-d.c: Moved to... * config/default-d.cc: ...here. * config/dragonfly-d.c: Moved to... * config/dragonfly-d.cc: ...here. * config/epiphany/epiphany.c: Moved to... * config/epiphany/epiphany.cc: ...here. * config/epiphany/mode-switch-use.c: Moved to... * config/epiphany/mode-switch-use.cc: ...here. * config/epiphany/resolve-sw-modes.c: Moved to... * config/epiphany/resolve-sw-modes.cc: ...here. * config/fr30/fr30.c: Moved to... * config/fr30/fr30.cc: ...here. * config/freebsd-d.c: Moved to... * config/freebsd-d.cc: ...here. * config/frv/frv.c: Moved to... * config/frv/frv.cc: ...here. * config/ft32/ft32.c: Moved to... * config/ft32/ft32.cc: ...here. * config/gcn/driver-gcn.c: Moved to... * config/gcn/driver-gcn.cc: ...here. * config/gcn/gcn-run.c: Moved to... * config/gcn/gcn-run.cc: ...here. * config/gcn/gcn-tree.c: Moved to... * config/gcn/gcn-tree.cc: ...here. * config/gcn/gcn.c: Moved to... * config/gcn/gcn.cc: ...here. * config/gcn/mkoffload.c: Moved to... * config/gcn/mkoffload.cc: ...here. * config/glibc-c.c: Moved to... * config/glibc-c.cc: ...here. * config/glibc-d.c: Moved to... * config/glibc-d.cc: ...here. * config/h8300/h8300.c: Moved to... * config/h8300/h8300.cc: ...here. * config/host-darwin.c: Moved to... * config/host-darwin.cc: ...here. * config/host-hpux.c: Moved to... * config/host-hpux.cc: ...here. * config/host-linux.c: Moved to... * config/host-linux.cc: ...here. * config/host-netbsd.c: Moved to... * config/host-netbsd.cc: ...here. * config/host-openbsd.c: Moved to... * config/host-openbsd.cc: ...here. * config/host-solaris.c: Moved to... * config/host-solaris.cc: ...here. * config/i386/djgpp.c: Moved to... * config/i386/djgpp.cc: ...here. * config/i386/driver-i386.c: Moved to... * config/i386/driver-i386.cc: ...here. * config/i386/driver-mingw32.c: Moved to... * config/i386/driver-mingw32.cc: ...here. * config/i386/gnu-property.c: Moved to... * config/i386/gnu-property.cc: ...here. * config/i386/host-cygwin.c: Moved to... * config/i386/host-cygwin.cc: ...here. * config/i386/host-i386-darwin.c: Moved to... * config/i386/host-i386-darwin.cc: ...here. * config/i386/host-mingw32.c: Moved to... * config/i386/host-mingw32.cc: ...here. * config/i386/i386-builtins.c: Moved to... * config/i386/i386-builtins.cc: ...here. * config/i386/i386-c.c: Moved to... * config/i386/i386-c.cc: ...here. * config/i386/i386-d.c: Moved to... * config/i386/i386-d.cc: ...here. * config/i386/i386-expand.c: Moved to... * config/i386/i386-expand.cc: ...here. * config/i386/i386-features.c: Moved to... * config/i386/i386-features.cc: ...here. * config/i386/i386-options.c: Moved to... * config/i386/i386-options.cc: ...here. * config/i386/i386.c: Moved to... * config/i386/i386.cc: ...here. * config/i386/intelmic-mkoffload.c: Moved to... * config/i386/intelmic-mkoffload.cc: ...here. * config/i386/msformat-c.c: Moved to... * config/i386/msformat-c.cc: ...here. * config/i386/winnt-cxx.c: Moved to... * config/i386/winnt-cxx.cc: ...here. * config/i386/winnt-d.c: Moved to... * config/i386/winnt-d.cc: ...here. * config/i386/winnt-stubs.c: Moved to... * config/i386/winnt-stubs.cc: ...here. * config/i386/winnt.c: Moved to... * config/i386/winnt.cc: ...here. * config/i386/x86-tune-sched-atom.c: Moved to... * config/i386/x86-tune-sched-atom.cc: ...here. * config/i386/x86-tune-sched-bd.c: Moved to... * config/i386/x86-tune-sched-bd.cc: ...here. * config/i386/x86-tune-sched-core.c: Moved to... * config/i386/x86-tune-sched-core.cc: ...here. * config/i386/x86-tune-sched.c: Moved to... * config/i386/x86-tune-sched.cc: ...here. * config/ia64/ia64-c.c: Moved to... * config/ia64/ia64-c.cc: ...here. * config/ia64/ia64.c: Moved to... * config/ia64/ia64.cc: ...here. * config/iq2000/iq2000.c: Moved to... * config/iq2000/iq2000.cc: ...here. * config/linux.c: Moved to... * config/linux.cc: ...here. * config/lm32/lm32.c: Moved to... * config/lm32/lm32.cc: ...here. * config/m32c/m32c-pragma.c: Moved to... * config/m32c/m32c-pragma.cc: ...here. * config/m32c/m32c.c: Moved to... * config/m32c/m32c.cc: ...here. * config/m32r/m32r.c: Moved to... * config/m32r/m32r.cc: ...here. * config/m68k/m68k.c: Moved to... * config/m68k/m68k.cc: ...here. * config/mcore/mcore.c: Moved to... * config/mcore/mcore.cc: ...here. * config/microblaze/microblaze-c.c: Moved to... * config/microblaze/microblaze-c.cc: ...here. * config/microblaze/microblaze.c: Moved to... * config/microblaze/microblaze.cc: ...here. * config/mips/driver-native.c: Moved to... * config/mips/driver-native.cc: ...here. * config/mips/frame-header-opt.c: Moved to... * config/mips/frame-header-opt.cc: ...here. * config/mips/mips-d.c: Moved to... * config/mips/mips-d.cc: ...here. * config/mips/mips.c: Moved to... * config/mips/mips.cc: ...here. * config/mmix/mmix.c: Moved to... * config/mmix/mmix.cc: ...here. * config/mn10300/mn10300.c: Moved to... * config/mn10300/mn10300.cc: ...here. * config/moxie/moxie.c: Moved to... * config/moxie/moxie.cc: ...here. * config/msp430/driver-msp430.c: Moved to... * config/msp430/driver-msp430.cc: ...here. * config/msp430/msp430-c.c: Moved to... * config/msp430/msp430-c.cc: ...here. * config/msp430/msp430-devices.c: Moved to... * config/msp430/msp430-devices.cc: ...here. * config/msp430/msp430.c: Moved to... * config/msp430/msp430.cc: ...here. * config/nds32/nds32-cost.c: Moved to... * config/nds32/nds32-cost.cc: ...here. * config/nds32/nds32-fp-as-gp.c: Moved to... * config/nds32/nds32-fp-as-gp.cc: ...here. * config/nds32/nds32-intrinsic.c: Moved to... * config/nds32/nds32-intrinsic.cc: ...here. * config/nds32/nds32-isr.c: Moved to... * config/nds32/nds32-isr.cc: ...here. * config/nds32/nds32-md-auxiliary.c: Moved to... * config/nds32/nds32-md-auxiliary.cc: ...here. * config/nds32/nds32-memory-manipulation.c: Moved to... * config/nds32/nds32-memory-manipulation.cc: ...here. * config/nds32/nds32-pipelines-auxiliary.c: Moved to... * config/nds32/nds32-pipelines-auxiliary.cc: ...here. * config/nds32/nds32-predicates.c: Moved to... * config/nds32/nds32-predicates.cc: ...here. * config/nds32/nds32-relax-opt.c: Moved to... * config/nds32/nds32-relax-opt.cc: ...here. * config/nds32/nds32-utils.c: Moved to... * config/nds32/nds32-utils.cc: ...here. * config/nds32/nds32.c: Moved to... * config/nds32/nds32.cc: ...here. * config/netbsd-d.c: Moved to... * config/netbsd-d.cc: ...here. * config/netbsd.c: Moved to... * config/netbsd.cc: ...here. * config/nios2/nios2.c: Moved to... * config/nios2/nios2.cc: ...here. * config/nvptx/mkoffload.c: Moved to... * config/nvptx/mkoffload.cc: ...here. * config/nvptx/nvptx-c.c: Moved to... * config/nvptx/nvptx-c.cc: ...here. * config/nvptx/nvptx.c: Moved to... * config/nvptx/nvptx.cc: ...here. * config/openbsd-d.c: Moved to... * config/openbsd-d.cc: ...here. * config/or1k/or1k.c: Moved to... * config/or1k/or1k.cc: ...here. * config/pa/pa-d.c: Moved to... * config/pa/pa-d.cc: ...here. * config/pa/pa.c: Moved to... * config/pa/pa.cc: ...here. * config/pdp11/pdp11.c: Moved to... * config/pdp11/pdp11.cc: ...here. * config/pru/pru-passes.c: Moved to... * config/pru/pru-passes.cc: ...here. * config/pru/pru-pragma.c: Moved to... * config/pru/pru-pragma.cc: ...here. * config/pru/pru.c: Moved to... * config/pru/pru.cc: ...here. * config/riscv/riscv-builtins.c: Moved to... * config/riscv/riscv-builtins.cc: ...here. * config/riscv/riscv-c.c: Moved to... * config/riscv/riscv-c.cc: ...here. * config/riscv/riscv-d.c: Moved to... * config/riscv/riscv-d.cc: ...here. * config/riscv/riscv-shorten-memrefs.c: Moved to... * config/riscv/riscv-shorten-memrefs.cc: ...here. * config/riscv/riscv-sr.c: Moved to... * config/riscv/riscv-sr.cc: ...here. * config/riscv/riscv.c: Moved to... * config/riscv/riscv.cc: ...here. * config/rl78/rl78-c.c: Moved to... * config/rl78/rl78-c.cc: ...here. * config/rl78/rl78.c: Moved to... * config/rl78/rl78.cc: ...here. * config/rs6000/driver-rs6000.c: Moved to... * config/rs6000/driver-rs6000.cc: ...here. * config/rs6000/host-darwin.c: Moved to... * config/rs6000/host-darwin.cc: ...here. * config/rs6000/host-ppc64-darwin.c: Moved to... * config/rs6000/host-ppc64-darwin.cc: ...here. * config/rs6000/rbtree.c: Moved to... * config/rs6000/rbtree.cc: ...here. * config/rs6000/rs6000-c.c: Moved to... * config/rs6000/rs6000-c.cc: ...here. * config/rs6000/rs6000-call.c: Moved to... * config/rs6000/rs6000-call.cc: ...here. * config/rs6000/rs6000-d.c: Moved to... * config/rs6000/rs6000-d.cc: ...here. * config/rs6000/rs6000-gen-builtins.c: Moved to... * config/rs6000/rs6000-gen-builtins.cc: ...here. * config/rs6000/rs6000-linux.c: Moved to... * config/rs6000/rs6000-linux.cc: ...here. * config/rs6000/rs6000-logue.c: Moved to... * config/rs6000/rs6000-logue.cc: ...here. * config/rs6000/rs6000-p8swap.c: Moved to... * config/rs6000/rs6000-p8swap.cc: ...here. * config/rs6000/rs6000-pcrel-opt.c: Moved to... * config/rs6000/rs6000-pcrel-opt.cc: ...here. * config/rs6000/rs6000-string.c: Moved to... * config/rs6000/rs6000-string.cc: ...here. * config/rs6000/rs6000.c: Moved to... * config/rs6000/rs6000.cc: ...here. * config/rx/rx.c: Moved to... * config/rx/rx.cc: ...here. * config/s390/driver-native.c: Moved to... * config/s390/driver-native.cc: ...here. * config/s390/s390-c.c: Moved to... * config/s390/s390-c.cc: ...here. * config/s390/s390-d.c: Moved to... * config/s390/s390-d.cc: ...here. * config/s390/s390.c: Moved to... * config/s390/s390.cc: ...here. * config/sh/divtab-sh4-300.c: Moved to... * config/sh/divtab-sh4-300.cc: ...here. * config/sh/divtab-sh4.c: Moved to... * config/sh/divtab-sh4.cc: ...here. * config/sh/divtab.c: Moved to... * config/sh/divtab.cc: ...here. * config/sh/sh-c.c: Moved to... * config/sh/sh-c.cc: ...here. * config/sh/sh.c: Moved to... * config/sh/sh.cc: ...here. * config/sol2-c.c: Moved to... * config/sol2-c.cc: ...here. * config/sol2-cxx.c: Moved to... * config/sol2-cxx.cc: ...here. * config/sol2-d.c: Moved to... * config/sol2-d.cc: ...here. * config/sol2-stubs.c: Moved to... * config/sol2-stubs.cc: ...here. * config/sol2.c: Moved to... * config/sol2.cc: ...here. * config/sparc/driver-sparc.c: Moved to... * config/sparc/driver-sparc.cc: ...here. * config/sparc/sparc-c.c: Moved to... * config/sparc/sparc-c.cc: ...here. * config/sparc/sparc-d.c: Moved to... * config/sparc/sparc-d.cc: ...here. * config/sparc/sparc.c: Moved to... * config/sparc/sparc.cc: ...here. * config/stormy16/stormy16.c: Moved to... * config/stormy16/stormy16.cc: ...here. * config/tilegx/mul-tables.c: Moved to... * config/tilegx/mul-tables.cc: ...here. * config/tilegx/tilegx-c.c: Moved to... * config/tilegx/tilegx-c.cc: ...here. * config/tilegx/tilegx.c: Moved to... * config/tilegx/tilegx.cc: ...here. * config/tilepro/mul-tables.c: Moved to... * config/tilepro/mul-tables.cc: ...here. * config/tilepro/tilepro-c.c: Moved to... * config/tilepro/tilepro-c.cc: ...here. * config/tilepro/tilepro.c: Moved to... * config/tilepro/tilepro.cc: ...here. * config/v850/v850-c.c: Moved to... * config/v850/v850-c.cc: ...here. * config/v850/v850.c: Moved to... * config/v850/v850.cc: ...here. * config/vax/vax.c: Moved to... * config/vax/vax.cc: ...here. * config/visium/visium.c: Moved to... * config/visium/visium.cc: ...here. * config/vms/vms-c.c: Moved to... * config/vms/vms-c.cc: ...here. * config/vms/vms-f.c: Moved to... * config/vms/vms-f.cc: ...here. * config/vms/vms.c: Moved to... * config/vms/vms.cc: ...here. * config/vxworks-c.c: Moved to... * config/vxworks-c.cc: ...here. * config/vxworks.c: Moved to... * config/vxworks.cc: ...here. * config/winnt-c.c: Moved to... * config/winnt-c.cc: ...here. * config/xtensa/xtensa.c: Moved to... * config/xtensa/xtensa.cc: ...here. * context.c: Moved to... * context.cc: ...here. * convert.c: Moved to... * convert.cc: ...here. * coverage.c: Moved to... * coverage.cc: ...here. * cppbuiltin.c: Moved to... * cppbuiltin.cc: ...here. * cppdefault.c: Moved to... * cppdefault.cc: ...here. * cprop.c: Moved to... * cprop.cc: ...here. * cse.c: Moved to... * cse.cc: ...here. * cselib.c: Moved to... * cselib.cc: ...here. * ctfc.c: Moved to... * ctfc.cc: ...here. * ctfout.c: Moved to... * ctfout.cc: ...here. * data-streamer-in.c: Moved to... * data-streamer-in.cc: ...here. * data-streamer-out.c: Moved to... * data-streamer-out.cc: ...here. * data-streamer.c: Moved to... * data-streamer.cc: ...here. * dbgcnt.c: Moved to... * dbgcnt.cc: ...here. * dbxout.c: Moved to... * dbxout.cc: ...here. * dce.c: Moved to... * dce.cc: ...here. * ddg.c: Moved to... * ddg.cc: ...here. * debug.c: Moved to... * debug.cc: ...here. * df-core.c: Moved to... * df-core.cc: ...here. * df-problems.c: Moved to... * df-problems.cc: ...here. * df-scan.c: Moved to... * df-scan.cc: ...here. * dfp.c: Moved to... * dfp.cc: ...here. * diagnostic-color.c: Moved to... * diagnostic-color.cc: ...here. * diagnostic-show-locus.c: Moved to... * diagnostic-show-locus.cc: ...here. * diagnostic-spec.c: Moved to... * diagnostic-spec.cc: ...here. * diagnostic.c: Moved to... * diagnostic.cc: ...here. * dojump.c: Moved to... * dojump.cc: ...here. * dominance.c: Moved to... * dominance.cc: ...here. * domwalk.c: Moved to... * domwalk.cc: ...here. * double-int.c: Moved to... * double-int.cc: ...here. * dse.c: Moved to... * dse.cc: ...here. * dumpfile.c: Moved to... * dumpfile.cc: ...here. * dwarf2asm.c: Moved to... * dwarf2asm.cc: ...here. * dwarf2cfi.c: Moved to... * dwarf2cfi.cc: ...here. * dwarf2ctf.c: Moved to... * dwarf2ctf.cc: ...here. * dwarf2out.c: Moved to... * dwarf2out.cc: ...here. * early-remat.c: Moved to... * early-remat.cc: ...here. * edit-context.c: Moved to... * edit-context.cc: ...here. * emit-rtl.c: Moved to... * emit-rtl.cc: ...here. * errors.c: Moved to... * errors.cc: ...here. * et-forest.c: Moved to... * et-forest.cc: ...here. * except.c: Moved to... * except.cc: ...here. * explow.c: Moved to... * explow.cc: ...here. * expmed.c: Moved to... * expmed.cc: ...here. * expr.c: Moved to... * expr.cc: ...here. * fibonacci_heap.c: Moved to... * fibonacci_heap.cc: ...here. * file-find.c: Moved to... * file-find.cc: ...here. * file-prefix-map.c: Moved to... * file-prefix-map.cc: ...here. * final.c: Moved to... * final.cc: ...here. * fixed-value.c: Moved to... * fixed-value.cc: ...here. * fold-const-call.c: Moved to... * fold-const-call.cc: ...here. * fold-const.c: Moved to... * fold-const.cc: ...here. * fp-test.c: Moved to... * fp-test.cc: ...here. * function-tests.c: Moved to... * function-tests.cc: ...here. * function.c: Moved to... * function.cc: ...here. * fwprop.c: Moved to... * fwprop.cc: ...here. * gcc-ar.c: Moved to... * gcc-ar.cc: ...here. * gcc-main.c: Moved to... * gcc-main.cc: ...here. * gcc-rich-location.c: Moved to... * gcc-rich-location.cc: ...here. * gcc.c: Moved to... * gcc.cc: ...here. * gcov-dump.c: Moved to... * gcov-dump.cc: ...here. * gcov-io.c: Moved to... * gcov-io.cc: ...here. * gcov-tool.c: Moved to... * gcov-tool.cc: ...here. * gcov.c: Moved to... * gcov.cc: ...here. * gcse-common.c: Moved to... * gcse-common.cc: ...here. * gcse.c: Moved to... * gcse.cc: ...here. * genattr-common.c: Moved to... * genattr-common.cc: ...here. * genattr.c: Moved to... * genattr.cc: ...here. * genattrtab.c: Moved to... * genattrtab.cc: ...here. * genautomata.c: Moved to... * genautomata.cc: ...here. * gencfn-macros.c: Moved to... * gencfn-macros.cc: ...here. * gencheck.c: Moved to... * gencheck.cc: ...here. * genchecksum.c: Moved to... * genchecksum.cc: ...here. * gencodes.c: Moved to... * gencodes.cc: ...here. * genconditions.c: Moved to... * genconditions.cc: ...here. * genconfig.c: Moved to... * genconfig.cc: ...here. * genconstants.c: Moved to... * genconstants.cc: ...here. * genemit.c: Moved to... * genemit.cc: ...here. * genenums.c: Moved to... * genenums.cc: ...here. * generic-match-head.c: Moved to... * generic-match-head.cc: ...here. * genextract.c: Moved to... * genextract.cc: ...here. * genflags.c: Moved to... * genflags.cc: ...here. * gengenrtl.c: Moved to... * gengenrtl.cc: ...here. * gengtype-parse.c: Moved to... * gengtype-parse.cc: ...here. * gengtype-state.c: Moved to... * gengtype-state.cc: ...here. * gengtype.c: Moved to... * gengtype.cc: ...here. * genhooks.c: Moved to... * genhooks.cc: ...here. * genmatch.c: Moved to... * genmatch.cc: ...here. * genmddeps.c: Moved to... * genmddeps.cc: ...here. * genmddump.c: Moved to... * genmddump.cc: ...here. * genmodes.c: Moved to... * genmodes.cc: ...here. * genopinit.c: Moved to... * genopinit.cc: ...here. * genoutput.c: Moved to... * genoutput.cc: ...here. * genpeep.c: Moved to... * genpeep.cc: ...here. * genpreds.c: Moved to... * genpreds.cc: ...here. * genrecog.c: Moved to... * genrecog.cc: ...here. * gensupport.c: Moved to... * gensupport.cc: ...here. * gentarget-def.c: Moved to... * gentarget-def.cc: ...here. * genversion.c: Moved to... * genversion.cc: ...here. * ggc-common.c: Moved to... * ggc-common.cc: ...here. * ggc-none.c: Moved to... * ggc-none.cc: ...here. * ggc-page.c: Moved to... * ggc-page.cc: ...here. * ggc-tests.c: Moved to... * ggc-tests.cc: ...here. * gimple-builder.c: Moved to... * gimple-builder.cc: ...here. * gimple-expr.c: Moved to... * gimple-expr.cc: ...here. * gimple-fold.c: Moved to... * gimple-fold.cc: ...here. * gimple-iterator.c: Moved to... * gimple-iterator.cc: ...here. * gimple-laddress.c: Moved to... * gimple-laddress.cc: ...here. * gimple-loop-jam.c: Moved to... * gimple-loop-jam.cc: ...here. * gimple-low.c: Moved to... * gimple-low.cc: ...here. * gimple-match-head.c: Moved to... * gimple-match-head.cc: ...here. * gimple-pretty-print.c: Moved to... * gimple-pretty-print.cc: ...here. * gimple-ssa-backprop.c: Moved to... * gimple-ssa-backprop.cc: ...here. * gimple-ssa-evrp-analyze.c: Moved to... * gimple-ssa-evrp-analyze.cc: ...here. * gimple-ssa-evrp.c: Moved to... * gimple-ssa-evrp.cc: ...here. * gimple-ssa-isolate-paths.c: Moved to... * gimple-ssa-isolate-paths.cc: ...here. * gimple-ssa-nonnull-compare.c: Moved to... * gimple-ssa-nonnull-compare.cc: ...here. * gimple-ssa-split-paths.c: Moved to... * gimple-ssa-split-paths.cc: ...here. * gimple-ssa-sprintf.c: Moved to... * gimple-ssa-sprintf.cc: ...here. * gimple-ssa-store-merging.c: Moved to... * gimple-ssa-store-merging.cc: ...here. * gimple-ssa-strength-reduction.c: Moved to... * gimple-ssa-strength-reduction.cc: ...here. * gimple-ssa-warn-alloca.c: Moved to... * gimple-ssa-warn-alloca.cc: ...here. * gimple-ssa-warn-restrict.c: Moved to... * gimple-ssa-warn-restrict.cc: ...here. * gimple-streamer-in.c: Moved to... * gimple-streamer-in.cc: ...here. * gimple-streamer-out.c: Moved to... * gimple-streamer-out.cc: ...here. * gimple-walk.c: Moved to... * gimple-walk.cc: ...here. * gimple-warn-recursion.c: Moved to... * gimple-warn-recursion.cc: ...here. * gimple.c: Moved to... * gimple.cc: ...here. * gimplify-me.c: Moved to... * gimplify-me.cc: ...here. * gimplify.c: Moved to... * gimplify.cc: ...here. * godump.c: Moved to... * godump.cc: ...here. * graph.c: Moved to... * graph.cc: ...here. * graphds.c: Moved to... * graphds.cc: ...here. * graphite-dependences.c: Moved to... * graphite-dependences.cc: ...here. * graphite-isl-ast-to-gimple.c: Moved to... * graphite-isl-ast-to-gimple.cc: ...here. * graphite-optimize-isl.c: Moved to... * graphite-optimize-isl.cc: ...here. * graphite-poly.c: Moved to... * graphite-poly.cc: ...here. * graphite-scop-detection.c: Moved to... * graphite-scop-detection.cc: ...here. * graphite-sese-to-poly.c: Moved to... * graphite-sese-to-poly.cc: ...here. * graphite.c: Moved to... * graphite.cc: ...here. * haifa-sched.c: Moved to... * haifa-sched.cc: ...here. * hash-map-tests.c: Moved to... * hash-map-tests.cc: ...here. * hash-set-tests.c: Moved to... * hash-set-tests.cc: ...here. * hash-table.c: Moved to... * hash-table.cc: ...here. * hooks.c: Moved to... * hooks.cc: ...here. * host-default.c: Moved to... * host-default.cc: ...here. * hw-doloop.c: Moved to... * hw-doloop.cc: ...here. * hwint.c: Moved to... * hwint.cc: ...here. * ifcvt.c: Moved to... * ifcvt.cc: ...here. * inchash.c: Moved to... * inchash.cc: ...here. * incpath.c: Moved to... * incpath.cc: ...here. * init-regs.c: Moved to... * init-regs.cc: ...here. * input.c: Moved to... * input.cc: ...here. * internal-fn.c: Moved to... * internal-fn.cc: ...here. * intl.c: Moved to... * intl.cc: ...here. * ipa-comdats.c: Moved to... * ipa-comdats.cc: ...here. * ipa-cp.c: Moved to... * ipa-cp.cc: ...here. * ipa-devirt.c: Moved to... * ipa-devirt.cc: ...here. * ipa-fnsummary.c: Moved to... * ipa-fnsummary.cc: ...here. * ipa-icf-gimple.c: Moved to... * ipa-icf-gimple.cc: ...here. * ipa-icf.c: Moved to... * ipa-icf.cc: ...here. * ipa-inline-analysis.c: Moved to... * ipa-inline-analysis.cc: ...here. * ipa-inline-transform.c: Moved to... * ipa-inline-transform.cc: ...here. * ipa-inline.c: Moved to... * ipa-inline.cc: ...here. * ipa-modref-tree.c: Moved to... * ipa-modref-tree.cc: ...here. * ipa-modref.c: Moved to... * ipa-modref.cc: ...here. * ipa-param-manipulation.c: Moved to... * ipa-param-manipulation.cc: ...here. * ipa-polymorphic-call.c: Moved to... * ipa-polymorphic-call.cc: ...here. * ipa-predicate.c: Moved to... * ipa-predicate.cc: ...here. * ipa-profile.c: Moved to... * ipa-profile.cc: ...here. * ipa-prop.c: Moved to... * ipa-prop.cc: ...here. * ipa-pure-const.c: Moved to... * ipa-pure-const.cc: ...here. * ipa-ref.c: Moved to... * ipa-ref.cc: ...here. * ipa-reference.c: Moved to... * ipa-reference.cc: ...here. * ipa-split.c: Moved to... * ipa-split.cc: ...here. * ipa-sra.c: Moved to... * ipa-sra.cc: ...here. * ipa-utils.c: Moved to... * ipa-utils.cc: ...here. * ipa-visibility.c: Moved to... * ipa-visibility.cc: ...here. * ipa.c: Moved to... * ipa.cc: ...here. * ira-build.c: Moved to... * ira-build.cc: ...here. * ira-color.c: Moved to... * ira-color.cc: ...here. * ira-conflicts.c: Moved to... * ira-conflicts.cc: ...here. * ira-costs.c: Moved to... * ira-costs.cc: ...here. * ira-emit.c: Moved to... * ira-emit.cc: ...here. * ira-lives.c: Moved to... * ira-lives.cc: ...here. * ira.c: Moved to... * ira.cc: ...here. * jump.c: Moved to... * jump.cc: ...here. * langhooks.c: Moved to... * langhooks.cc: ...here. * lcm.c: Moved to... * lcm.cc: ...here. * lists.c: Moved to... * lists.cc: ...here. * loop-doloop.c: Moved to... * loop-doloop.cc: ...here. * loop-init.c: Moved to... * loop-init.cc: ...here. * loop-invariant.c: Moved to... * loop-invariant.cc: ...here. * loop-iv.c: Moved to... * loop-iv.cc: ...here. * loop-unroll.c: Moved to... * loop-unroll.cc: ...here. * lower-subreg.c: Moved to... * lower-subreg.cc: ...here. * lra-assigns.c: Moved to... * lra-assigns.cc: ...here. * lra-coalesce.c: Moved to... * lra-coalesce.cc: ...here. * lra-constraints.c: Moved to... * lra-constraints.cc: ...here. * lra-eliminations.c: Moved to... * lra-eliminations.cc: ...here. * lra-lives.c: Moved to... * lra-lives.cc: ...here. * lra-remat.c: Moved to... * lra-remat.cc: ...here. * lra-spills.c: Moved to... * lra-spills.cc: ...here. * lra.c: Moved to... * lra.cc: ...here. * lto-cgraph.c: Moved to... * lto-cgraph.cc: ...here. * lto-compress.c: Moved to... * lto-compress.cc: ...here. * lto-opts.c: Moved to... * lto-opts.cc: ...here. * lto-section-in.c: Moved to... * lto-section-in.cc: ...here. * lto-section-out.c: Moved to... * lto-section-out.cc: ...here. * lto-streamer-in.c: Moved to... * lto-streamer-in.cc: ...here. * lto-streamer-out.c: Moved to... * lto-streamer-out.cc: ...here. * lto-streamer.c: Moved to... * lto-streamer.cc: ...here. * lto-wrapper.c: Moved to... * lto-wrapper.cc: ...here. * main.c: Moved to... * main.cc: ...here. * mcf.c: Moved to... * mcf.cc: ...here. * mode-switching.c: Moved to... * mode-switching.cc: ...here. * modulo-sched.c: Moved to... * modulo-sched.cc: ...here. * multiple_target.c: Moved to... * multiple_target.cc: ...here. * omp-expand.c: Moved to... * omp-expand.cc: ...here. * omp-general.c: Moved to... * omp-general.cc: ...here. * omp-low.c: Moved to... * omp-low.cc: ...here. * omp-offload.c: Moved to... * omp-offload.cc: ...here. * omp-simd-clone.c: Moved to... * omp-simd-clone.cc: ...here. * opt-suggestions.c: Moved to... * opt-suggestions.cc: ...here. * optabs-libfuncs.c: Moved to... * optabs-libfuncs.cc: ...here. * optabs-query.c: Moved to... * optabs-query.cc: ...here. * optabs-tree.c: Moved to... * optabs-tree.cc: ...here. * optabs.c: Moved to... * optabs.cc: ...here. * opts-common.c: Moved to... * opts-common.cc: ...here. * opts-global.c: Moved to... * opts-global.cc: ...here. * opts.c: Moved to... * opts.cc: ...here. * passes.c: Moved to... * passes.cc: ...here. * plugin.c: Moved to... * plugin.cc: ...here. * postreload-gcse.c: Moved to... * postreload-gcse.cc: ...here. * postreload.c: Moved to... * postreload.cc: ...here. * predict.c: Moved to... * predict.cc: ...here. * prefix.c: Moved to... * prefix.cc: ...here. * pretty-print.c: Moved to... * pretty-print.cc: ...here. * print-rtl-function.c: Moved to... * print-rtl-function.cc: ...here. * print-rtl.c: Moved to... * print-rtl.cc: ...here. * print-tree.c: Moved to... * print-tree.cc: ...here. * profile-count.c: Moved to... * profile-count.cc: ...here. * profile.c: Moved to... * profile.cc: ...here. * read-md.c: Moved to... * read-md.cc: ...here. * read-rtl-function.c: Moved to... * read-rtl-function.cc: ...here. * read-rtl.c: Moved to... * read-rtl.cc: ...here. * real.c: Moved to... * real.cc: ...here. * realmpfr.c: Moved to... * realmpfr.cc: ...here. * recog.c: Moved to... * recog.cc: ...here. * ree.c: Moved to... * ree.cc: ...here. * reg-stack.c: Moved to... * reg-stack.cc: ...here. * regcprop.c: Moved to... * regcprop.cc: ...here. * reginfo.c: Moved to... * reginfo.cc: ...here. * regrename.c: Moved to... * regrename.cc: ...here. * regstat.c: Moved to... * regstat.cc: ...here. * reload.c: Moved to... * reload.cc: ...here. * reload1.c: Moved to... * reload1.cc: ...here. * reorg.c: Moved to... * reorg.cc: ...here. * resource.c: Moved to... * resource.cc: ...here. * rtl-error.c: Moved to... * rtl-error.cc: ...here. * rtl-tests.c: Moved to... * rtl-tests.cc: ...here. * rtl.c: Moved to... * rtl.cc: ...here. * rtlanal.c: Moved to... * rtlanal.cc: ...here. * rtlhash.c: Moved to... * rtlhash.cc: ...here. * rtlhooks.c: Moved to... * rtlhooks.cc: ...here. * rtx-vector-builder.c: Moved to... * rtx-vector-builder.cc: ...here. * run-rtl-passes.c: Moved to... * run-rtl-passes.cc: ...here. * sancov.c: Moved to... * sancov.cc: ...here. * sanopt.c: Moved to... * sanopt.cc: ...here. * sbitmap.c: Moved to... * sbitmap.cc: ...here. * sched-deps.c: Moved to... * sched-deps.cc: ...here. * sched-ebb.c: Moved to... * sched-ebb.cc: ...here. * sched-rgn.c: Moved to... * sched-rgn.cc: ...here. * sel-sched-dump.c: Moved to... * sel-sched-dump.cc: ...here. * sel-sched-ir.c: Moved to... * sel-sched-ir.cc: ...here. * sel-sched.c: Moved to... * sel-sched.cc: ...here. * selftest-diagnostic.c: Moved to... * selftest-diagnostic.cc: ...here. * selftest-rtl.c: Moved to... * selftest-rtl.cc: ...here. * selftest-run-tests.c: Moved to... * selftest-run-tests.cc: ...here. * selftest.c: Moved to... * selftest.cc: ...here. * sese.c: Moved to... * sese.cc: ...here. * shrink-wrap.c: Moved to... * shrink-wrap.cc: ...here. * simplify-rtx.c: Moved to... * simplify-rtx.cc: ...here. * sparseset.c: Moved to... * sparseset.cc: ...here. * spellcheck-tree.c: Moved to... * spellcheck-tree.cc: ...here. * spellcheck.c: Moved to... * spellcheck.cc: ...here. * sreal.c: Moved to... * sreal.cc: ...here. * stack-ptr-mod.c: Moved to... * stack-ptr-mod.cc: ...here. * statistics.c: Moved to... * statistics.cc: ...here. * stmt.c: Moved to... * stmt.cc: ...here. * stor-layout.c: Moved to... * stor-layout.cc: ...here. * store-motion.c: Moved to... * store-motion.cc: ...here. * streamer-hooks.c: Moved to... * streamer-hooks.cc: ...here. * stringpool.c: Moved to... * stringpool.cc: ...here. * substring-locations.c: Moved to... * substring-locations.cc: ...here. * symtab.c: Moved to... * symtab.cc: ...here. * target-globals.c: Moved to... * target-globals.cc: ...here. * targhooks.c: Moved to... * targhooks.cc: ...here. * timevar.c: Moved to... * timevar.cc: ...here. * toplev.c: Moved to... * toplev.cc: ...here. * tracer.c: Moved to... * tracer.cc: ...here. * trans-mem.c: Moved to... * trans-mem.cc: ...here. * tree-affine.c: Moved to... * tree-affine.cc: ...here. * tree-call-cdce.c: Moved to... * tree-call-cdce.cc: ...here. * tree-cfg.c: Moved to... * tree-cfg.cc: ...here. * tree-cfgcleanup.c: Moved to... * tree-cfgcleanup.cc: ...here. * tree-chrec.c: Moved to... * tree-chrec.cc: ...here. * tree-complex.c: Moved to... * tree-complex.cc: ...here. * tree-data-ref.c: Moved to... * tree-data-ref.cc: ...here. * tree-dfa.c: Moved to... * tree-dfa.cc: ...here. * tree-diagnostic.c: Moved to... * tree-diagnostic.cc: ...here. * tree-dump.c: Moved to... * tree-dump.cc: ...here. * tree-eh.c: Moved to... * tree-eh.cc: ...here. * tree-emutls.c: Moved to... * tree-emutls.cc: ...here. * tree-if-conv.c: Moved to... * tree-if-conv.cc: ...here. * tree-inline.c: Moved to... * tree-inline.cc: ...here. * tree-into-ssa.c: Moved to... * tree-into-ssa.cc: ...here. * tree-iterator.c: Moved to... * tree-iterator.cc: ...here. * tree-loop-distribution.c: Moved to... * tree-loop-distribution.cc: ...here. * tree-nested.c: Moved to... * tree-nested.cc: ...here. * tree-nrv.c: Moved to... * tree-nrv.cc: ...here. * tree-object-size.c: Moved to... * tree-object-size.cc: ...here. * tree-outof-ssa.c: Moved to... * tree-outof-ssa.cc: ...here. * tree-parloops.c: Moved to... * tree-parloops.cc: ...here. * tree-phinodes.c: Moved to... * tree-phinodes.cc: ...here. * tree-predcom.c: Moved to... * tree-predcom.cc: ...here. * tree-pretty-print.c: Moved to... * tree-pretty-print.cc: ...here. * tree-profile.c: Moved to... * tree-profile.cc: ...here. * tree-scalar-evolution.c: Moved to... * tree-scalar-evolution.cc: ...here. * tree-sra.c: Moved to... * tree-sra.cc: ...here. * tree-ssa-address.c: Moved to... * tree-ssa-address.cc: ...here. * tree-ssa-alias.c: Moved to... * tree-ssa-alias.cc: ...here. * tree-ssa-ccp.c: Moved to... * tree-ssa-ccp.cc: ...here. * tree-ssa-coalesce.c: Moved to... * tree-ssa-coalesce.cc: ...here. * tree-ssa-copy.c: Moved to... * tree-ssa-copy.cc: ...here. * tree-ssa-dce.c: Moved to... * tree-ssa-dce.cc: ...here. * tree-ssa-dom.c: Moved to... * tree-ssa-dom.cc: ...here. * tree-ssa-dse.c: Moved to... * tree-ssa-dse.cc: ...here. * tree-ssa-forwprop.c: Moved to... * tree-ssa-forwprop.cc: ...here. * tree-ssa-ifcombine.c: Moved to... * tree-ssa-ifcombine.cc: ...here. * tree-ssa-live.c: Moved to... * tree-ssa-live.cc: ...here. * tree-ssa-loop-ch.c: Moved to... * tree-ssa-loop-ch.cc: ...here. * tree-ssa-loop-im.c: Moved to... * tree-ssa-loop-im.cc: ...here. * tree-ssa-loop-ivcanon.c: Moved to... * tree-ssa-loop-ivcanon.cc: ...here. * tree-ssa-loop-ivopts.c: Moved to... * tree-ssa-loop-ivopts.cc: ...here. * tree-ssa-loop-manip.c: Moved to... * tree-ssa-loop-manip.cc: ...here. * tree-ssa-loop-niter.c: Moved to... * tree-ssa-loop-niter.cc: ...here. * tree-ssa-loop-prefetch.c: Moved to... * tree-ssa-loop-prefetch.cc: ...here. * tree-ssa-loop-split.c: Moved to... * tree-ssa-loop-split.cc: ...here. * tree-ssa-loop-unswitch.c: Moved to... * tree-ssa-loop-unswitch.cc: ...here. * tree-ssa-loop.c: Moved to... * tree-ssa-loop.cc: ...here. * tree-ssa-math-opts.c: Moved to... * tree-ssa-math-opts.cc: ...here. * tree-ssa-operands.c: Moved to... * tree-ssa-operands.cc: ...here. * tree-ssa-phiopt.c: Moved to... * tree-ssa-phiopt.cc: ...here. * tree-ssa-phiprop.c: Moved to... * tree-ssa-phiprop.cc: ...here. * tree-ssa-pre.c: Moved to... * tree-ssa-pre.cc: ...here. * tree-ssa-propagate.c: Moved to... * tree-ssa-propagate.cc: ...here. * tree-ssa-reassoc.c: Moved to... * tree-ssa-reassoc.cc: ...here. * tree-ssa-sccvn.c: Moved to... * tree-ssa-sccvn.cc: ...here. * tree-ssa-scopedtables.c: Moved to... * tree-ssa-scopedtables.cc: ...here. * tree-ssa-sink.c: Moved to... * tree-ssa-sink.cc: ...here. * tree-ssa-strlen.c: Moved to... * tree-ssa-strlen.cc: ...here. * tree-ssa-structalias.c: Moved to... * tree-ssa-structalias.cc: ...here. * tree-ssa-tail-merge.c: Moved to... * tree-ssa-tail-merge.cc: ...here. * tree-ssa-ter.c: Moved to... * tree-ssa-ter.cc: ...here. * tree-ssa-threadbackward.c: Moved to... * tree-ssa-threadbackward.cc: ...here. * tree-ssa-threadedge.c: Moved to... * tree-ssa-threadedge.cc: ...here. * tree-ssa-threadupdate.c: Moved to... * tree-ssa-threadupdate.cc: ...here. * tree-ssa-uncprop.c: Moved to... * tree-ssa-uncprop.cc: ...here. * tree-ssa-uninit.c: Moved to... * tree-ssa-uninit.cc: ...here. * tree-ssa.c: Moved to... * tree-ssa.cc: ...here. * tree-ssanames.c: Moved to... * tree-ssanames.cc: ...here. * tree-stdarg.c: Moved to... * tree-stdarg.cc: ...here. * tree-streamer-in.c: Moved to... * tree-streamer-in.cc: ...here. * tree-streamer-out.c: Moved to... * tree-streamer-out.cc: ...here. * tree-streamer.c: Moved to... * tree-streamer.cc: ...here. * tree-switch-conversion.c: Moved to... * tree-switch-conversion.cc: ...here. * tree-tailcall.c: Moved to... * tree-tailcall.cc: ...here. * tree-vect-data-refs.c: Moved to... * tree-vect-data-refs.cc: ...here. * tree-vect-generic.c: Moved to... * tree-vect-generic.cc: ...here. * tree-vect-loop-manip.c: Moved to... * tree-vect-loop-manip.cc: ...here. * tree-vect-loop.c: Moved to... * tree-vect-loop.cc: ...here. * tree-vect-patterns.c: Moved to... * tree-vect-patterns.cc: ...here. * tree-vect-slp-patterns.c: Moved to... * tree-vect-slp-patterns.cc: ...here. * tree-vect-slp.c: Moved to... * tree-vect-slp.cc: ...here. * tree-vect-stmts.c: Moved to... * tree-vect-stmts.cc: ...here. * tree-vector-builder.c: Moved to... * tree-vector-builder.cc: ...here. * tree-vectorizer.c: Moved to... * tree-vectorizer.cc: ...here. * tree-vrp.c: Moved to... * tree-vrp.cc: ...here. * tree.c: Moved to... * tree.cc: ...here. * tsan.c: Moved to... * tsan.cc: ...here. * typed-splay-tree.c: Moved to... * typed-splay-tree.cc: ...here. * ubsan.c: Moved to... * ubsan.cc: ...here. * valtrack.c: Moved to... * valtrack.cc: ...here. * value-prof.c: Moved to... * value-prof.cc: ...here. * var-tracking.c: Moved to... * var-tracking.cc: ...here. * varasm.c: Moved to... * varasm.cc: ...here. * varpool.c: Moved to... * varpool.cc: ...here. * vec-perm-indices.c: Moved to... * vec-perm-indices.cc: ...here. * vec.c: Moved to... * vec.cc: ...here. * vmsdbgout.c: Moved to... * vmsdbgout.cc: ...here. * vr-values.c: Moved to... * vr-values.cc: ...here. * vtable-verify.c: Moved to... * vtable-verify.cc: ...here. * web.c: Moved to... * web.cc: ...here. * xcoffout.c: Moved to... * xcoffout.cc: ...here. gcc/c-family/ChangeLog: * c-ada-spec.c: Moved to... * c-ada-spec.cc: ...here. * c-attribs.c: Moved to... * c-attribs.cc: ...here. * c-common.c: Moved to... * c-common.cc: ...here. * c-cppbuiltin.c: Moved to... * c-cppbuiltin.cc: ...here. * c-dump.c: Moved to... * c-dump.cc: ...here. * c-format.c: Moved to... * c-format.cc: ...here. * c-gimplify.c: Moved to... * c-gimplify.cc: ...here. * c-indentation.c: Moved to... * c-indentation.cc: ...here. * c-lex.c: Moved to... * c-lex.cc: ...here. * c-omp.c: Moved to... * c-omp.cc: ...here. * c-opts.c: Moved to... * c-opts.cc: ...here. * c-pch.c: Moved to... * c-pch.cc: ...here. * c-ppoutput.c: Moved to... * c-ppoutput.cc: ...here. * c-pragma.c: Moved to... * c-pragma.cc: ...here. * c-pretty-print.c: Moved to... * c-pretty-print.cc: ...here. * c-semantics.c: Moved to... * c-semantics.cc: ...here. * c-ubsan.c: Moved to... * c-ubsan.cc: ...here. * c-warn.c: Moved to... * c-warn.cc: ...here. * cppspec.c: Moved to... * cppspec.cc: ...here. * stub-objc.c: Moved to... * stub-objc.cc: ...here. gcc/c/ChangeLog: * c-aux-info.c: Moved to... * c-aux-info.cc: ...here. * c-convert.c: Moved to... * c-convert.cc: ...here. * c-decl.c: Moved to... * c-decl.cc: ...here. * c-errors.c: Moved to... * c-errors.cc: ...here. * c-fold.c: Moved to... * c-fold.cc: ...here. * c-lang.c: Moved to... * c-lang.cc: ...here. * c-objc-common.c: Moved to... * c-objc-common.cc: ...here. * c-parser.c: Moved to... * c-parser.cc: ...here. * c-typeck.c: Moved to... * c-typeck.cc: ...here. * gccspec.c: Moved to... * gccspec.cc: ...here. * gimple-parser.c: Moved to... * gimple-parser.cc: ...here. gcc/cp/ChangeLog: * call.c: Moved to... * call.cc: ...here. * class.c: Moved to... * class.cc: ...here. * constexpr.c: Moved to... * constexpr.cc: ...here. * cp-gimplify.c: Moved to... * cp-gimplify.cc: ...here. * cp-lang.c: Moved to... * cp-lang.cc: ...here. * cp-objcp-common.c: Moved to... * cp-objcp-common.cc: ...here. * cp-ubsan.c: Moved to... * cp-ubsan.cc: ...here. * cvt.c: Moved to... * cvt.cc: ...here. * cxx-pretty-print.c: Moved to... * cxx-pretty-print.cc: ...here. * decl.c: Moved to... * decl.cc: ...here. * decl2.c: Moved to... * decl2.cc: ...here. * dump.c: Moved to... * dump.cc: ...here. * error.c: Moved to... * error.cc: ...here. * except.c: Moved to... * except.cc: ...here. * expr.c: Moved to... * expr.cc: ...here. * friend.c: Moved to... * friend.cc: ...here. * g++spec.c: Moved to... * g++spec.cc: ...here. * init.c: Moved to... * init.cc: ...here. * lambda.c: Moved to... * lambda.cc: ...here. * lex.c: Moved to... * lex.cc: ...here. * mangle.c: Moved to... * mangle.cc: ...here. * method.c: Moved to... * method.cc: ...here. * name-lookup.c: Moved to... * name-lookup.cc: ...here. * optimize.c: Moved to... * optimize.cc: ...here. * parser.c: Moved to... * parser.cc: ...here. * pt.c: Moved to... * pt.cc: ...here. * ptree.c: Moved to... * ptree.cc: ...here. * rtti.c: Moved to... * rtti.cc: ...here. * search.c: Moved to... * search.cc: ...here. * semantics.c: Moved to... * semantics.cc: ...here. * tree.c: Moved to... * tree.cc: ...here. * typeck.c: Moved to... * typeck.cc: ...here. * typeck2.c: Moved to... * typeck2.cc: ...here. * vtable-class-hierarchy.c: Moved to... * vtable-class-hierarchy.cc: ...here. gcc/fortran/ChangeLog: * arith.c: Moved to... * arith.cc: ...here. * array.c: Moved to... * array.cc: ...here. * bbt.c: Moved to... * bbt.cc: ...here. * check.c: Moved to... * check.cc: ...here. * class.c: Moved to... * class.cc: ...here. * constructor.c: Moved to... * constructor.cc: ...here. * convert.c: Moved to... * convert.cc: ...here. * cpp.c: Moved to... * cpp.cc: ...here. * data.c: Moved to... * data.cc: ...here. * decl.c: Moved to... * decl.cc: ...here. * dependency.c: Moved to... * dependency.cc: ...here. * dump-parse-tree.c: Moved to... * dump-parse-tree.cc: ...here. * error.c: Moved to... * error.cc: ...here. * expr.c: Moved to... * expr.cc: ...here. * f95-lang.c: Moved to... * f95-lang.cc: ...here. * frontend-passes.c: Moved to... * frontend-passes.cc: ...here. * gfortranspec.c: Moved to... * gfortranspec.cc: ...here. * interface.c: Moved to... * interface.cc: ...here. * intrinsic.c: Moved to... * intrinsic.cc: ...here. * io.c: Moved to... * io.cc: ...here. * iresolve.c: Moved to... * iresolve.cc: ...here. * match.c: Moved to... * match.cc: ...here. * matchexp.c: Moved to... * matchexp.cc: ...here. * misc.c: Moved to... * misc.cc: ...here. * module.c: Moved to... * module.cc: ...here. * openmp.c: Moved to... * openmp.cc: ...here. * options.c: Moved to... * options.cc: ...here. * parse.c: Moved to... * parse.cc: ...here. * primary.c: Moved to... * primary.cc: ...here. * resolve.c: Moved to... * resolve.cc: ...here. * scanner.c: Moved to... * scanner.cc: ...here. * simplify.c: Moved to... * simplify.cc: ...here. * st.c: Moved to... * st.cc: ...here. * symbol.c: Moved to... * symbol.cc: ...here. * target-memory.c: Moved to... * target-memory.cc: ...here. * trans-array.c: Moved to... * trans-array.cc: ...here. * trans-common.c: Moved to... * trans-common.cc: ...here. * trans-const.c: Moved to... * trans-const.cc: ...here. * trans-decl.c: Moved to... * trans-decl.cc: ...here. * trans-expr.c: Moved to... * trans-expr.cc: ...here. * trans-intrinsic.c: Moved to... * trans-intrinsic.cc: ...here. * trans-io.c: Moved to... * trans-io.cc: ...here. * trans-openmp.c: Moved to... * trans-openmp.cc: ...here. * trans-stmt.c: Moved to... * trans-stmt.cc: ...here. * trans-types.c: Moved to... * trans-types.cc: ...here. * trans.c: Moved to... * trans.cc: ...here. gcc/go/ChangeLog: * go-backend.c: Moved to... * go-backend.cc: ...here. * go-lang.c: Moved to... * go-lang.cc: ...here. * gospec.c: Moved to... * gospec.cc: ...here. gcc/jit/ChangeLog: * dummy-frontend.c: Moved to... * dummy-frontend.cc: ...here. * jit-builtins.c: Moved to... * jit-builtins.cc: ...here. * jit-logging.c: Moved to... * jit-logging.cc: ...here. * jit-playback.c: Moved to... * jit-playback.cc: ...here. * jit-recording.c: Moved to... * jit-recording.cc: ...here. * jit-result.c: Moved to... * jit-result.cc: ...here. * jit-spec.c: Moved to... * jit-spec.cc: ...here. * jit-tempdir.c: Moved to... * jit-tempdir.cc: ...here. * jit-w32.c: Moved to... * jit-w32.cc: ...here. * libgccjit.c: Moved to... * libgccjit.cc: ...here. gcc/lto/ChangeLog: * common.c: Moved to... * common.cc: ...here. * lto-common.c: Moved to... * lto-common.cc: ...here. * lto-dump.c: Moved to... * lto-dump.cc: ...here. * lto-lang.c: Moved to... * lto-lang.cc: ...here. * lto-object.c: Moved to... * lto-object.cc: ...here. * lto-partition.c: Moved to... * lto-partition.cc: ...here. * lto-symtab.c: Moved to... * lto-symtab.cc: ...here. * lto.c: Moved to... * lto.cc: ...here. gcc/objc/ChangeLog: * objc-act.c: Moved to... * objc-act.cc: ...here. * objc-encoding.c: Moved to... * objc-encoding.cc: ...here. * objc-gnu-runtime-abi-01.c: Moved to... * objc-gnu-runtime-abi-01.cc: ...here. * objc-lang.c: Moved to... * objc-lang.cc: ...here. * objc-map.c: Moved to... * objc-map.cc: ...here. * objc-next-runtime-abi-01.c: Moved to... * objc-next-runtime-abi-01.cc: ...here. * objc-next-runtime-abi-02.c: Moved to... * objc-next-runtime-abi-02.cc: ...here. * objc-runtime-shared-support.c: Moved to... * objc-runtime-shared-support.cc: ...here. gcc/objcp/ChangeLog: * objcp-decl.c: Moved to... * objcp-decl.cc: ...here. * objcp-lang.c: Moved to... * objcp-lang.cc: ...here. libcpp/ChangeLog: * charset.c: Moved to... * charset.cc: ...here. * directives.c: Moved to... * directives.cc: ...here. * errors.c: Moved to... * errors.cc: ...here. * expr.c: Moved to... * expr.cc: ...here. * files.c: Moved to... * files.cc: ...here. * identifiers.c: Moved to... * identifiers.cc: ...here. * init.c: Moved to... * init.cc: ...here. * lex.c: Moved to... * lex.cc: ...here. * line-map.c: Moved to... * line-map.cc: ...here. * macro.c: Moved to... * macro.cc: ...here. * makeucnid.c: Moved to... * makeucnid.cc: ...here. * mkdeps.c: Moved to... * mkdeps.cc: ...here. * pch.c: Moved to... * pch.cc: ...here. * symtab.c: Moved to... * symtab.cc: ...here. * traditional.c: Moved to... * traditional.cc: ...here.
Diffstat (limited to 'gcc/c-family/c-attribs.cc')
-rw-r--r--gcc/c-family/c-attribs.cc6142
1 files changed, 6142 insertions, 0 deletions
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
new file mode 100644
index 0000000..4fb5dbd
--- /dev/null
+++ b/gcc/c-family/c-attribs.cc
@@ -0,0 +1,6142 @@
+/* C-family attributes handling.
+ Copyright (C) 1992-2022 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/>. */
+
+#define INCLUDE_STRING
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "target.h"
+#include "function.h"
+#include "tree.h"
+#include "memmodel.h"
+#include "c-common.h"
+#include "gimple-expr.h"
+#include "tm_p.h"
+#include "stringpool.h"
+#include "cgraph.h"
+#include "diagnostic.h"
+#include "intl.h"
+#include "stor-layout.h"
+#include "calls.h"
+#include "attribs.h"
+#include "varasm.h"
+#include "trans-mem.h"
+#include "c-objc.h"
+#include "common/common-target.h"
+#include "langhooks.h"
+#include "tree-inline.h"
+#include "toplev.h"
+#include "tree-iterator.h"
+#include "opts.h"
+#include "gimplify.h"
+#include "tree-pretty-print.h"
+#include "gcc-rich-location.h"
+
+static tree handle_packed_attribute (tree *, tree, tree, int, bool *);
+static tree handle_nocommon_attribute (tree *, tree, tree, int, bool *);
+static tree handle_common_attribute (tree *, tree, tree, int, bool *);
+static tree handle_hot_attribute (tree *, tree, tree, int, bool *);
+static tree handle_cold_attribute (tree *, tree, tree, int, bool *);
+static tree handle_no_sanitize_attribute (tree *, tree, tree, int, bool *);
+static tree handle_no_sanitize_address_attribute (tree *, tree, tree,
+ int, bool *);
+static tree handle_no_sanitize_thread_attribute (tree *, tree, tree,
+ int, bool *);
+static tree handle_no_address_safety_analysis_attribute (tree *, tree, tree,
+ int, bool *);
+static tree handle_no_sanitize_undefined_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_no_sanitize_coverage_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_asan_odr_indicator_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_stack_protect_attribute (tree *, tree, tree, int, bool *);
+static tree handle_no_stack_protector_function_attribute (tree *, tree,
+ tree, int, bool *);
+static tree handle_noinline_attribute (tree *, tree, tree, int, bool *);
+static tree handle_noclone_attribute (tree *, tree, tree, int, bool *);
+static tree handle_nocf_check_attribute (tree *, tree, tree, int, bool *);
+static tree handle_symver_attribute (tree *, tree, tree, int, bool *);
+static tree handle_noicf_attribute (tree *, tree, tree, int, bool *);
+static tree handle_noipa_attribute (tree *, tree, tree, int, bool *);
+static tree handle_leaf_attribute (tree *, tree, tree, int, bool *);
+static tree handle_always_inline_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_gnu_inline_attribute (tree *, tree, tree, int, bool *);
+static tree handle_artificial_attribute (tree *, tree, tree, int, bool *);
+static tree handle_flatten_attribute (tree *, tree, tree, int, bool *);
+static tree handle_error_attribute (tree *, tree, tree, int, bool *);
+static tree handle_used_attribute (tree *, tree, tree, int, bool *);
+static tree handle_uninitialized_attribute (tree *, tree, tree, int, bool *);
+static tree handle_externally_visible_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_no_reorder_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_const_attribute (tree *, tree, tree, int, bool *);
+static tree handle_transparent_union_attribute (tree *, tree, tree,
+ int, bool *);
+static tree handle_scalar_storage_order_attribute (tree *, tree, tree,
+ int, bool *);
+static tree handle_constructor_attribute (tree *, tree, tree, int, bool *);
+static tree handle_destructor_attribute (tree *, tree, tree, int, bool *);
+static tree handle_mode_attribute (tree *, tree, tree, int, bool *);
+static tree handle_section_attribute (tree *, tree, tree, int, bool *);
+static tree handle_special_var_sec_attribute (tree *, tree, tree, int, bool *);
+static tree handle_aligned_attribute (tree *, tree, tree, int, bool *);
+static tree handle_warn_if_not_aligned_attribute (tree *, tree, tree,
+ int, bool *);
+static tree handle_weak_attribute (tree *, tree, tree, int, bool *) ;
+static tree handle_noplt_attribute (tree *, tree, tree, int, bool *) ;
+static tree handle_alias_ifunc_attribute (bool, tree *, tree, tree, bool *);
+static tree handle_ifunc_attribute (tree *, tree, tree, int, bool *);
+static tree handle_alias_attribute (tree *, tree, tree, int, bool *);
+static tree handle_weakref_attribute (tree *, tree, tree, int, bool *) ;
+static tree handle_visibility_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_tls_model_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_no_instrument_function_attribute (tree *, tree,
+ tree, int, bool *);
+static tree handle_no_profile_instrument_function_attribute (tree *, tree,
+ tree, int, bool *);
+static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
+static tree handle_dealloc_attribute (tree *, tree, tree, int, bool *);
+static tree handle_tainted_args_attribute (tree *, tree, tree, int, bool *);
+static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *);
+static tree handle_no_limit_stack_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_pure_attribute (tree *, tree, tree, int, bool *);
+static tree handle_tm_attribute (tree *, tree, tree, int, bool *);
+static tree handle_tm_wrap_attribute (tree *, tree, tree, int, bool *);
+static tree handle_novops_attribute (tree *, tree, tree, int, bool *);
+static tree handle_unavailable_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_vector_size_attribute (tree *, tree, tree, int,
+ bool *) ATTRIBUTE_NONNULL(3);
+static tree handle_nonnull_attribute (tree *, tree, tree, int, bool *);
+static tree handle_nonstring_attribute (tree *, tree, tree, int, bool *);
+static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
+static tree handle_cleanup_attribute (tree *, tree, tree, int, bool *);
+static tree handle_warn_unused_result_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_access_attribute (tree *, tree, tree, int, bool *);
+
+static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
+static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *);
+static tree handle_alloc_size_attribute (tree *, tree, tree, int, bool *);
+static tree handle_alloc_align_attribute (tree *, tree, tree, int, bool *);
+static tree handle_assume_aligned_attribute (tree *, tree, tree, int, bool *);
+static tree handle_target_attribute (tree *, tree, tree, int, bool *);
+static tree handle_target_clones_attribute (tree *, tree, tree, int, bool *);
+static tree handle_optimize_attribute (tree *, tree, tree, int, bool *);
+static tree ignore_attribute (tree *, tree, tree, int, bool *);
+static tree handle_no_split_stack_attribute (tree *, tree, tree, int, bool *);
+static tree handle_zero_call_used_regs_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_argspec_attribute (tree *, tree, tree, int, bool *);
+static tree handle_fnspec_attribute (tree *, tree, tree, int, bool *);
+static tree handle_warn_unused_attribute (tree *, tree, tree, int, bool *);
+static tree handle_returns_nonnull_attribute (tree *, tree, tree, int, bool *);
+static tree handle_omp_declare_simd_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_omp_declare_variant_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_simd_attribute (tree *, tree, tree, int, bool *);
+static tree handle_omp_declare_target_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_non_overlapping_attribute (tree *, tree, tree, int, bool *);
+static tree handle_designated_init_attribute (tree *, tree, tree, int, bool *);
+static tree handle_patchable_function_entry_attribute (tree *, tree, tree,
+ int, bool *);
+static tree handle_copy_attribute (tree *, tree, tree, int, bool *);
+static tree handle_nsobject_attribute (tree *, tree, tree, int, bool *);
+static tree handle_objc_root_class_attribute (tree *, tree, tree, int, bool *);
+static tree handle_objc_nullability_attribute (tree *, tree, tree, int, bool *);
+static tree handle_signed_bool_precision_attribute (tree *, tree, tree, int,
+ bool *);
+static tree handle_retain_attribute (tree *, tree, tree, int, bool *);
+
+/* Helper to define attribute exclusions. */
+#define ATTR_EXCL(name, function, type, variable) \
+ { name, function, type, variable }
+
+/* Define attributes that are mutually exclusive with one another. */
+static const struct attribute_spec::exclusions attr_aligned_exclusions[] =
+{
+ /* Attribute name exclusion applies to:
+ function, type, variable */
+ ATTR_EXCL ("aligned", true, false, false),
+ ATTR_EXCL ("packed", true, false, false),
+ ATTR_EXCL (NULL, false, false, false)
+};
+
+extern const struct attribute_spec::exclusions attr_cold_hot_exclusions[] =
+{
+ ATTR_EXCL ("cold", true, true, true),
+ ATTR_EXCL ("hot", true, true, true),
+ ATTR_EXCL (NULL, false, false, false)
+};
+
+static const struct attribute_spec::exclusions attr_common_exclusions[] =
+{
+ ATTR_EXCL ("common", true, true, true),
+ ATTR_EXCL ("nocommon", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions attr_inline_exclusions[] =
+{
+ ATTR_EXCL ("noinline", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions attr_noinline_exclusions[] =
+{
+ ATTR_EXCL ("always_inline", true, true, true),
+ ATTR_EXCL ("gnu_inline", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+extern const struct attribute_spec::exclusions attr_noreturn_exclusions[] =
+{
+ ATTR_EXCL ("alloc_align", true, true, true),
+ ATTR_EXCL ("alloc_size", true, true, true),
+ ATTR_EXCL ("const", true, true, true),
+ ATTR_EXCL ("malloc", true, true, true),
+ ATTR_EXCL ("pure", true, true, true),
+ ATTR_EXCL ("returns_twice", true, true, true),
+ ATTR_EXCL ("warn_unused_result", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions
+attr_warn_unused_result_exclusions[] =
+{
+ ATTR_EXCL ("noreturn", true, true, true),
+ ATTR_EXCL ("warn_unused_result", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions attr_returns_twice_exclusions[] =
+{
+ ATTR_EXCL ("noreturn", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+/* Exclusions that apply to attribute alloc_align, alloc_size, and malloc. */
+static const struct attribute_spec::exclusions attr_alloc_exclusions[] =
+{
+ ATTR_EXCL ("const", true, true, true),
+ ATTR_EXCL ("noreturn", true, true, true),
+ ATTR_EXCL ("pure", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions attr_const_pure_exclusions[] =
+{
+ ATTR_EXCL ("const", true, true, true),
+ ATTR_EXCL ("alloc_align", true, true, true),
+ ATTR_EXCL ("alloc_size", true, true, true),
+ ATTR_EXCL ("malloc", true, true, true),
+ ATTR_EXCL ("noreturn", true, true, true),
+ ATTR_EXCL ("pure", true, true, true),
+ ATTR_EXCL (NULL, false, false, false)
+};
+
+/* Exclusions that apply to attributes that put declarations in specific
+ sections. */
+static const struct attribute_spec::exclusions attr_section_exclusions[] =
+{
+ ATTR_EXCL ("noinit", true, true, true),
+ ATTR_EXCL ("persistent", true, true, true),
+ ATTR_EXCL ("section", true, true, true),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+static const struct attribute_spec::exclusions attr_stack_protect_exclusions[] =
+{
+ ATTR_EXCL ("stack_protect", true, false, false),
+ ATTR_EXCL ("no_stack_protector", true, false, false),
+ ATTR_EXCL (NULL, false, false, false),
+};
+
+
+/* Table of machine-independent attributes common to all C-like languages.
+
+ Current list of processed common attributes: nonnull. */
+const struct attribute_spec c_common_attribute_table[] =
+{
+ /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
+ affects_type_identity, handler, exclude } */
+ { "signed_bool_precision", 1, 1, false, true, false, true,
+ handle_signed_bool_precision_attribute, NULL },
+ { "packed", 0, 0, false, false, false, false,
+ handle_packed_attribute,
+ attr_aligned_exclusions },
+ { "nocommon", 0, 0, true, false, false, false,
+ handle_nocommon_attribute,
+ attr_common_exclusions },
+ { "common", 0, 0, true, false, false, false,
+ handle_common_attribute,
+ attr_common_exclusions },
+ /* FIXME: logically, noreturn attributes should be listed as
+ "false, true, true" and apply to function types. But implementing this
+ would require all the places in the compiler that use TREE_THIS_VOLATILE
+ on a decl to identify non-returning functions to be located and fixed
+ to check the function type instead. */
+ { "noreturn", 0, 0, true, false, false, false,
+ handle_noreturn_attribute,
+ attr_noreturn_exclusions },
+ { "volatile", 0, 0, true, false, false, false,
+ handle_noreturn_attribute, NULL },
+ { "stack_protect", 0, 0, true, false, false, false,
+ handle_stack_protect_attribute,
+ attr_stack_protect_exclusions },
+ { "no_stack_protector", 0, 0, true, false, false, false,
+ handle_no_stack_protector_function_attribute,
+ attr_stack_protect_exclusions },
+ { "noinline", 0, 0, true, false, false, false,
+ handle_noinline_attribute,
+ attr_noinline_exclusions },
+ { "noclone", 0, 0, true, false, false, false,
+ handle_noclone_attribute, NULL },
+ { "no_icf", 0, 0, true, false, false, false,
+ handle_noicf_attribute, NULL },
+ { "noipa", 0, 0, true, false, false, false,
+ handle_noipa_attribute, NULL },
+ { "leaf", 0, 0, true, false, false, false,
+ handle_leaf_attribute, NULL },
+ { "always_inline", 0, 0, true, false, false, false,
+ handle_always_inline_attribute,
+ attr_inline_exclusions },
+ { "gnu_inline", 0, 0, true, false, false, false,
+ handle_gnu_inline_attribute,
+ attr_inline_exclusions },
+ { "artificial", 0, 0, true, false, false, false,
+ handle_artificial_attribute, NULL },
+ { "flatten", 0, 0, true, false, false, false,
+ handle_flatten_attribute, NULL },
+ { "used", 0, 0, true, false, false, false,
+ handle_used_attribute, NULL },
+ { "unused", 0, 0, false, false, false, false,
+ handle_unused_attribute, NULL },
+ { "uninitialized", 0, 0, true, false, false, false,
+ handle_uninitialized_attribute, NULL },
+ { "retain", 0, 0, true, false, false, false,
+ handle_retain_attribute, NULL },
+ { "externally_visible", 0, 0, true, false, false, false,
+ handle_externally_visible_attribute, NULL },
+ { "no_reorder", 0, 0, true, false, false, false,
+ handle_no_reorder_attribute, NULL },
+ /* The same comments as for noreturn attributes apply to const ones. */
+ { "const", 0, 0, true, false, false, false,
+ handle_const_attribute,
+ attr_const_pure_exclusions },
+ { "scalar_storage_order", 1, 1, false, false, false, false,
+ handle_scalar_storage_order_attribute, NULL },
+ { "transparent_union", 0, 0, false, false, false, false,
+ handle_transparent_union_attribute, NULL },
+ { "constructor", 0, 1, true, false, false, false,
+ handle_constructor_attribute, NULL },
+ { "destructor", 0, 1, true, false, false, false,
+ handle_destructor_attribute, NULL },
+ { "mode", 1, 1, false, true, false, false,
+ handle_mode_attribute, NULL },
+ { "section", 1, 1, true, false, false, false,
+ handle_section_attribute, attr_section_exclusions },
+ { "aligned", 0, 1, false, false, false, false,
+ handle_aligned_attribute,
+ attr_aligned_exclusions },
+ { "warn_if_not_aligned", 0, 1, false, false, false, false,
+ handle_warn_if_not_aligned_attribute, NULL },
+ { "weak", 0, 0, true, false, false, false,
+ handle_weak_attribute, NULL },
+ { "noplt", 0, 0, true, false, false, false,
+ handle_noplt_attribute, NULL },
+ { "ifunc", 1, 1, true, false, false, false,
+ handle_ifunc_attribute, NULL },
+ { "alias", 1, 1, true, false, false, false,
+ handle_alias_attribute, NULL },
+ { "weakref", 0, 1, true, false, false, false,
+ handle_weakref_attribute, NULL },
+ { "no_instrument_function", 0, 0, true, false, false, false,
+ handle_no_instrument_function_attribute,
+ NULL },
+ { "no_profile_instrument_function", 0, 0, true, false, false, false,
+ handle_no_profile_instrument_function_attribute,
+ NULL },
+ { "malloc", 0, 2, true, false, false, false,
+ handle_malloc_attribute, attr_alloc_exclusions },
+ { "returns_twice", 0, 0, true, false, false, false,
+ handle_returns_twice_attribute,
+ attr_returns_twice_exclusions },
+ { "no_stack_limit", 0, 0, true, false, false, false,
+ handle_no_limit_stack_attribute, NULL },
+ { "pure", 0, 0, true, false, false, false,
+ handle_pure_attribute,
+ attr_const_pure_exclusions },
+ { "transaction_callable", 0, 0, false, true, false, false,
+ handle_tm_attribute, NULL },
+ { "transaction_unsafe", 0, 0, false, true, false, true,
+ handle_tm_attribute, NULL },
+ { "transaction_safe", 0, 0, false, true, false, true,
+ handle_tm_attribute, NULL },
+ { "transaction_safe_dynamic", 0, 0, true, false, false, false,
+ handle_tm_attribute, NULL },
+ { "transaction_may_cancel_outer", 0, 0, false, true, false, false,
+ handle_tm_attribute, NULL },
+ /* ??? These two attributes didn't make the transition from the
+ Intel language document to the multi-vendor language document. */
+ { "transaction_pure", 0, 0, false, true, false, false,
+ handle_tm_attribute, NULL },
+ { "transaction_wrap", 1, 1, true, false, false, false,
+ handle_tm_wrap_attribute, NULL },
+ /* For internal use (marking of builtins) only. The name contains space
+ to prevent its usage in source code. */
+ { "no vops", 0, 0, true, false, false, false,
+ handle_novops_attribute, NULL },
+ { "deprecated", 0, 1, false, false, false, false,
+ handle_deprecated_attribute, NULL },
+ { "unavailable", 0, 1, false, false, false, false,
+ handle_unavailable_attribute, NULL },
+ { "vector_size", 1, 1, false, true, false, true,
+ handle_vector_size_attribute, NULL },
+ { "visibility", 1, 1, false, false, false, false,
+ handle_visibility_attribute, NULL },
+ { "tls_model", 1, 1, true, false, false, false,
+ handle_tls_model_attribute, NULL },
+ { "nonnull", 0, -1, false, true, true, false,
+ handle_nonnull_attribute, NULL },
+ { "nonstring", 0, 0, true, false, false, false,
+ handle_nonstring_attribute, NULL },
+ { "nothrow", 0, 0, true, false, false, false,
+ handle_nothrow_attribute, NULL },
+ { "may_alias", 0, 0, false, true, false, false, NULL, NULL },
+ { "cleanup", 1, 1, true, false, false, false,
+ handle_cleanup_attribute, NULL },
+ { "warn_unused_result", 0, 0, false, true, true, false,
+ handle_warn_unused_result_attribute,
+ attr_warn_unused_result_exclusions },
+ { "sentinel", 0, 1, false, true, true, false,
+ handle_sentinel_attribute, NULL },
+ /* For internal use (marking of builtins) only. The name contains space
+ to prevent its usage in source code. */
+ { "type generic", 0, 0, false, true, true, false,
+ handle_type_generic_attribute, NULL },
+ { "alloc_size", 1, 2, false, true, true, false,
+ handle_alloc_size_attribute,
+ attr_alloc_exclusions },
+ { "cold", 0, 0, true, false, false, false,
+ handle_cold_attribute,
+ attr_cold_hot_exclusions },
+ { "hot", 0, 0, true, false, false, false,
+ handle_hot_attribute,
+ attr_cold_hot_exclusions },
+ { "no_address_safety_analysis",
+ 0, 0, true, false, false, false,
+ handle_no_address_safety_analysis_attribute,
+ NULL },
+ { "no_sanitize", 1, -1, true, false, false, false,
+ handle_no_sanitize_attribute, NULL },
+ { "no_sanitize_address", 0, 0, true, false, false, false,
+ handle_no_sanitize_address_attribute, NULL },
+ { "no_sanitize_thread", 0, 0, true, false, false, false,
+ handle_no_sanitize_thread_attribute, NULL },
+ { "no_sanitize_undefined", 0, 0, true, false, false, false,
+ handle_no_sanitize_undefined_attribute, NULL },
+ { "no_sanitize_coverage", 0, 0, true, false, false, false,
+ handle_no_sanitize_coverage_attribute, NULL },
+ { "asan odr indicator", 0, 0, true, false, false, false,
+ handle_asan_odr_indicator_attribute, NULL },
+ { "warning", 1, 1, true, false, false, false,
+ handle_error_attribute, NULL },
+ { "error", 1, 1, true, false, false, false,
+ handle_error_attribute, NULL },
+ { "target", 1, -1, true, false, false, false,
+ handle_target_attribute, NULL },
+ { "target_clones", 1, -1, true, false, false, false,
+ handle_target_clones_attribute, NULL },
+ { "optimize", 1, -1, true, false, false, false,
+ handle_optimize_attribute, NULL },
+ /* For internal use only. The leading '*' both prevents its usage in
+ source code and signals that it may be overridden by machine tables. */
+ { "*tm regparm", 0, 0, false, true, true, false,
+ ignore_attribute, NULL },
+ { "no_split_stack", 0, 0, true, false, false, false,
+ handle_no_split_stack_attribute, NULL },
+ { "zero_call_used_regs", 1, 1, true, false, false, false,
+ handle_zero_call_used_regs_attribute, NULL },
+ /* For internal use only (marking of function arguments).
+ The name contains a space to prevent its usage in source code. */
+ { "arg spec", 1, -1, true, false, false, false,
+ handle_argspec_attribute, NULL },
+ /* For internal use (marking of builtins and runtime functions) only.
+ The name contains space to prevent its usage in source code. */
+ { "fn spec", 1, 1, false, true, true, false,
+ handle_fnspec_attribute, NULL },
+ { "warn_unused", 0, 0, false, false, false, false,
+ handle_warn_unused_attribute, NULL },
+ { "returns_nonnull", 0, 0, false, true, true, false,
+ handle_returns_nonnull_attribute, NULL },
+ { "omp declare simd", 0, -1, true, false, false, false,
+ handle_omp_declare_simd_attribute, NULL },
+ { "omp declare variant base", 0, -1, true, false, false, false,
+ handle_omp_declare_variant_attribute, NULL },
+ { "omp declare variant variant", 0, -1, true, false, false, false,
+ handle_omp_declare_variant_attribute, NULL },
+ { "simd", 0, 1, true, false, false, false,
+ handle_simd_attribute, NULL },
+ { "omp declare target", 0, -1, true, false, false, false,
+ handle_omp_declare_target_attribute, NULL },
+ { "omp declare target link", 0, 0, true, false, false, false,
+ handle_omp_declare_target_attribute, NULL },
+ { "omp declare target implicit", 0, 0, true, false, false, false,
+ handle_omp_declare_target_attribute, NULL },
+ { "omp declare target host", 0, 0, true, false, false, false,
+ handle_omp_declare_target_attribute, NULL },
+ { "omp declare target nohost", 0, 0, true, false, false, false,
+ handle_omp_declare_target_attribute, NULL },
+ { "omp declare target block", 0, 0, true, false, false, false,
+ handle_omp_declare_target_attribute, NULL },
+ { "non overlapping", 0, 0, true, false, false, false,
+ handle_non_overlapping_attribute, NULL },
+ { "alloc_align", 1, 1, false, true, true, false,
+ handle_alloc_align_attribute,
+ attr_alloc_exclusions },
+ { "assume_aligned", 1, 2, false, true, true, false,
+ handle_assume_aligned_attribute, NULL },
+ { "designated_init", 0, 0, false, true, false, false,
+ handle_designated_init_attribute, NULL },
+ { "fallthrough", 0, 0, false, false, false, false,
+ handle_fallthrough_attribute, NULL },
+ { "patchable_function_entry", 1, 2, true, false, false, false,
+ handle_patchable_function_entry_attribute,
+ NULL },
+ { "nocf_check", 0, 0, false, true, true, true,
+ handle_nocf_check_attribute, NULL },
+ { "symver", 1, -1, true, false, false, false,
+ handle_symver_attribute, NULL},
+ { "copy", 1, 1, false, false, false, false,
+ handle_copy_attribute, NULL },
+ { "noinit", 0, 0, true, false, false, false,
+ handle_special_var_sec_attribute, attr_section_exclusions },
+ { "persistent", 0, 0, true, false, false, false,
+ handle_special_var_sec_attribute, attr_section_exclusions },
+ { "access", 1, 3, false, true, true, false,
+ handle_access_attribute, NULL },
+ /* Attributes used by Objective-C. */
+ { "NSObject", 0, 0, true, false, false, false,
+ handle_nsobject_attribute, NULL },
+ { "objc_root_class", 0, 0, true, false, false, false,
+ handle_objc_root_class_attribute, NULL },
+ { "objc_nullability", 1, 1, true, false, false, false,
+ handle_objc_nullability_attribute, NULL },
+ { "*dealloc", 1, 2, true, false, false, false,
+ handle_dealloc_attribute, NULL },
+ { "tainted_args", 0, 0, true, false, false, false,
+ handle_tainted_args_attribute, NULL },
+ { NULL, 0, 0, false, false, false, false, NULL, NULL }
+};
+
+/* Give the specifications for the format attributes, used by C and all
+ descendants.
+
+ Current list of processed format attributes: format, format_arg. */
+const struct attribute_spec c_common_format_attribute_table[] =
+{
+ /* { name, min_len, max_len, decl_req, type_req, fn_type_req,
+ affects_type_identity, handler, exclude } */
+ { "format", 3, 3, false, true, true, false,
+ handle_format_attribute, NULL },
+ { "format_arg", 1, 1, false, true, true, false,
+ handle_format_arg_attribute, NULL },
+ { NULL, 0, 0, false, false, false, false, NULL, NULL }
+};
+
+/* Returns TRUE iff the attribute indicated by ATTR_ID takes a plain
+ identifier as an argument, so the front end shouldn't look it up. */
+
+bool
+attribute_takes_identifier_p (const_tree attr_id)
+{
+ const struct attribute_spec *spec = lookup_attribute_spec (attr_id);
+ if (spec == NULL)
+ /* Unknown attribute that we'll end up ignoring, return true so we
+ don't complain about an identifier argument. */
+ return true;
+ else if (!strcmp ("mode", spec->name)
+ || !strcmp ("format", spec->name)
+ || !strcmp ("cleanup", spec->name)
+ || !strcmp ("access", spec->name))
+ return true;
+ else
+ return targetm.attribute_takes_identifier_p (attr_id);
+}
+
+/* Verify that argument value POS at position ARGNO to attribute NAME
+ applied to function TYPE refers to a function parameter at position
+ POS and the expected type CODE. Treat CODE == INTEGER_TYPE as
+ matching all C integral types except bool. If successful, return
+ POS after default conversions, if any. Otherwise, issue appropriate
+ warnings and return null. A non-zero 1-based ARGNO should be passed
+ in by callers only for attributes with more than one argument. */
+
+tree
+positional_argument (const_tree fntype, const_tree atname, tree pos,
+ tree_code code, int argno /* = 0 */,
+ int flags /* = posargflags () */)
+{
+ if (pos && TREE_CODE (pos) != IDENTIFIER_NODE
+ && TREE_CODE (pos) != FUNCTION_DECL)
+ pos = default_conversion (pos);
+
+ tree postype = TREE_TYPE (pos);
+ if (pos == error_mark_node || !postype)
+ {
+ /* Only mention the positional argument number when it's non-zero. */
+ if (argno < 1)
+ warning (OPT_Wattributes,
+ "%qE attribute argument is invalid", atname);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument %i is invalid", atname, argno);
+
+ return NULL_TREE;
+ }
+
+ if (!INTEGRAL_TYPE_P (postype))
+ {
+ /* Handle this case specially to avoid mentioning the value
+ of pointer constants in diagnostics. Only mention
+ the positional argument number when it's non-zero. */
+ if (argno < 1)
+ warning (OPT_Wattributes,
+ "%qE attribute argument has type %qT",
+ atname, postype);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument %i has type %qT",
+ atname, argno, postype);
+
+ return NULL_TREE;
+ }
+
+ if (TREE_CODE (pos) != INTEGER_CST)
+ {
+ /* Only mention the argument number when it's non-zero. */
+ if (argno < 1)
+ warning (OPT_Wattributes,
+ "%qE attribute argument value %qE is not an integer "
+ "constant",
+ atname, pos);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument %i value %qE is not an integer "
+ "constant",
+ atname, argno, pos);
+
+ return NULL_TREE;
+ }
+
+ /* Argument positions are 1-based. */
+ if (integer_zerop (pos))
+ {
+ if (flags & POSARG_ZERO)
+ /* Zero is explicitly allowed. */
+ return pos;
+
+ if (argno < 1)
+ warning (OPT_Wattributes,
+ "%qE attribute argument value %qE does not refer to "
+ "a function parameter",
+ atname, pos);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument %i value %qE does not refer to "
+ "a function parameter",
+ atname, argno, pos);
+
+ return NULL_TREE;
+ }
+
+ if (!prototype_p (fntype))
+ return pos;
+
+ /* Verify that the argument position does not exceed the number
+ of formal arguments to the function. When POSARG_ELLIPSIS
+ is set, ARGNO may be beyond the last argument of a vararg
+ function. */
+ unsigned nargs = type_num_arguments (fntype);
+ if (!nargs
+ || !tree_fits_uhwi_p (pos)
+ || ((flags & POSARG_ELLIPSIS) == 0
+ && !IN_RANGE (tree_to_uhwi (pos), 1, nargs)))
+ {
+
+ if (argno < 1)
+ warning (OPT_Wattributes,
+ "%qE attribute argument value %qE exceeds the number "
+ "of function parameters %u",
+ atname, pos, nargs);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument %i value %qE exceeds the number "
+ "of function parameters %u",
+ atname, argno, pos, nargs);
+ return NULL_TREE;
+ }
+
+ /* Verify that the type of the referenced formal argument matches
+ the expected type. */
+ unsigned HOST_WIDE_INT ipos = tree_to_uhwi (pos);
+
+ /* Zero was handled above. */
+ gcc_assert (ipos != 0);
+
+ if (tree argtype = type_argument_type (fntype, ipos))
+ {
+ if (argtype == error_mark_node)
+ return NULL_TREE;
+
+ if (flags & POSARG_ELLIPSIS)
+ {
+ if (argno < 1)
+ error ("%qE attribute argument value %qE does not refer to "
+ "a variable argument list",
+ atname, pos);
+ else
+ error ("%qE attribute argument %i value %qE does not refer to "
+ "a variable argument list",
+ atname, argno, pos);
+ return NULL_TREE;
+ }
+
+ /* Where the expected code is STRING_CST accept any pointer
+ expected by attribute format (this includes possibly qualified
+ char pointers and, for targets like Darwin, also pointers to
+ struct CFString). */
+ bool type_match;
+ if (code == STRING_CST)
+ type_match = valid_format_string_type_p (argtype);
+ else if (code == INTEGER_TYPE)
+ /* For integers, accept enums, wide characters and other types
+ that match INTEGRAL_TYPE_P except for bool. */
+ type_match = (INTEGRAL_TYPE_P (argtype)
+ && TREE_CODE (argtype) != BOOLEAN_TYPE);
+ else
+ type_match = TREE_CODE (argtype) == code;
+
+ if (!type_match)
+ {
+ if (code == STRING_CST)
+ {
+ /* Reject invalid format strings with an error. */
+ if (argno < 1)
+ error ("%qE attribute argument value %qE refers to "
+ "parameter type %qT",
+ atname, pos, argtype);
+ else
+ error ("%qE attribute argument %i value %qE refers to "
+ "parameter type %qT",
+ atname, argno, pos, argtype);
+
+ return NULL_TREE;
+ }
+
+ if (argno < 1)
+ warning (OPT_Wattributes,
+ "%qE attribute argument value %qE refers to "
+ "parameter type %qT",
+ atname, pos, argtype);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument %i value %qE refers to "
+ "parameter type %qT",
+ atname, argno, pos, argtype);
+ return NULL_TREE;
+ }
+ }
+ else if (!(flags & POSARG_ELLIPSIS))
+ {
+ if (argno < 1)
+ warning (OPT_Wattributes,
+ "%qE attribute argument value %qE refers to "
+ "a variadic function parameter of unknown type",
+ atname, pos);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument %i value %qE refers to "
+ "a variadic function parameter of unknown type",
+ atname, argno, pos);
+ return NULL_TREE;
+ }
+
+ return pos;
+}
+
+/* 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. */
+
+static tree
+decl_or_type_attrs (tree node)
+{
+ if (DECL_P (node))
+ {
+ if (tree attrs = DECL_ATTRIBUTES (node))
+ return attrs;
+
+ tree type = TREE_TYPE (node);
+ return TYPE_ATTRIBUTES (type);
+ }
+
+ if (TYPE_P (node))
+ return TYPE_ATTRIBUTES (node);
+
+ return NULL_TREE;
+}
+
+/* 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. */
+
+static bool
+validate_attr_args (tree node[2], tree name, tree newargs[2])
+{
+ /* First validate the arguments against those already applied to
+ the same declaration (or type). */
+ tree self[2] = { node[0], node[0] };
+ if (node[0] != node[1] && !validate_attr_args (self, name, newargs))
+ return false;
+
+ if (!node[1])
+ return true;
+
+ /* Extract the same attribute from the previous declaration or type. */
+ tree prevattr = decl_or_type_attrs (node[1]);
+ const char* const namestr = IDENTIFIER_POINTER (name);
+ prevattr = lookup_attribute (namestr, prevattr);
+ if (!prevattr)
+ return true;
+
+ /* Extract one or both attribute arguments. */
+ tree prevargs[2];
+ prevargs[0] = TREE_VALUE (TREE_VALUE (prevattr));
+ prevargs[1] = TREE_CHAIN (TREE_VALUE (prevattr));
+ if (prevargs[1])
+ prevargs[1] = TREE_VALUE (prevargs[1]);
+
+ /* Both arguments must be equal or, for the second pair, neither must
+ be provided to succeed. */
+ bool arg1eq, arg2eq;
+ if (TREE_CODE (newargs[0]) == INTEGER_CST)
+ {
+ arg1eq = tree_int_cst_equal (newargs[0], prevargs[0]);
+ if (newargs[1] && prevargs[1])
+ arg2eq = tree_int_cst_equal (newargs[1], prevargs[1]);
+ else
+ arg2eq = newargs[1] == prevargs[1];
+ }
+ else if (TREE_CODE (newargs[0]) == STRING_CST)
+ {
+ const char *s0 = TREE_STRING_POINTER (newargs[0]);
+ const char *s1 = TREE_STRING_POINTER (prevargs[0]);
+ arg1eq = strcmp (s0, s1) == 0;
+ if (newargs[1] && prevargs[1])
+ {
+ s0 = TREE_STRING_POINTER (newargs[1]);
+ s1 = TREE_STRING_POINTER (prevargs[1]);
+ arg2eq = strcmp (s0, s1) == 0;
+ }
+ else
+ arg2eq = newargs[1] == prevargs[1];
+ }
+ else
+ gcc_unreachable ();
+
+ if (arg1eq && arg2eq)
+ return true;
+
+ /* If the two locations are different print a note pointing to
+ the previous one. */
+ const location_t curloc = input_location;
+ const location_t prevloc =
+ DECL_P (node[1]) ? DECL_SOURCE_LOCATION (node[1]) : curloc;
+
+ /* Format the attribute specification for convenience. */
+ char newspec[80], prevspec[80];
+ if (newargs[1])
+ snprintf (newspec, sizeof newspec, "%s (%s, %s)", namestr,
+ print_generic_expr_to_str (newargs[0]),
+ print_generic_expr_to_str (newargs[1]));
+ else
+ snprintf (newspec, sizeof newspec, "%s (%s)", namestr,
+ print_generic_expr_to_str (newargs[0]));
+
+ if (prevargs[1])
+ snprintf (prevspec, sizeof prevspec, "%s (%s, %s)", namestr,
+ print_generic_expr_to_str (prevargs[0]),
+ print_generic_expr_to_str (prevargs[1]));
+ else
+ snprintf (prevspec, sizeof prevspec, "%s (%s)", namestr,
+ print_generic_expr_to_str (prevargs[0]));
+
+ if (warning_at (curloc, OPT_Wattributes,
+ "ignoring attribute %qs because it conflicts "
+ "with previous %qs",
+ newspec, prevspec)
+ && curloc != prevloc)
+ inform (prevloc, "previous declaration here");
+
+ return false;
+}
+
+/* Convenience wrapper for validate_attr_args to validate a single
+ attribute argument. Used by handlers for attributes that take
+ just a single argument. */
+
+static bool
+validate_attr_arg (tree node[2], tree name, tree newarg)
+{
+ tree argarray[2] = { newarg, NULL_TREE };
+ return validate_attr_args (node, name, argarray);
+}
+
+/* Attribute handlers common to C front ends. */
+
+/* Handle a "signed_bool_precision" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_signed_bool_precision_attribute (tree *node, tree name, tree args,
+ int, bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+ if (!flag_gimple)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ return NULL_TREE;
+ }
+
+ if (!TYPE_P (*node) || TREE_CODE (*node) != BOOLEAN_TYPE)
+ {
+ warning (OPT_Wattributes, "%qE attribute only supported on "
+ "boolean types", name);
+ return NULL_TREE;
+ }
+
+ unsigned HOST_WIDE_INT prec = HOST_WIDE_INT_M1U;
+ if (tree_fits_uhwi_p (TREE_VALUE (args)))
+ prec = tree_to_uhwi (TREE_VALUE (args));
+ if (prec > MAX_FIXED_MODE_SIZE)
+ {
+ warning (OPT_Wattributes, "%qE attribute with unsupported boolean "
+ "precision", name);
+ return NULL_TREE;
+ }
+
+ tree new_type = build_nonstandard_boolean_type (prec);
+ *node = lang_hooks.types.reconstruct_complex_type (*node, new_type);
+
+ return NULL_TREE;
+}
+
+/* Handle a "packed" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_packed_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int flags, bool *no_add_attrs)
+{
+ if (TYPE_P (*node))
+ {
+ if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute ignored for type %qT", name, *node);
+ *no_add_attrs = true;
+ }
+ else
+ TYPE_PACKED (*node) = 1;
+ }
+ else if (TREE_CODE (*node) == FIELD_DECL)
+ {
+ if (TYPE_ALIGN (TREE_TYPE (*node)) <= BITS_PER_UNIT
+ /* Still pack bitfields. */
+ && ! DECL_C_BIT_FIELD (*node))
+ warning (OPT_Wattributes,
+ "%qE attribute ignored for field of type %qT",
+ name, TREE_TYPE (*node));
+ else
+ DECL_PACKED (*node) = 1;
+ }
+ /* We can't set DECL_PACKED for a VAR_DECL, because the bit is
+ used for DECL_REGISTER. It wouldn't mean anything anyway.
+ We can't set DECL_PACKED on the type of a TYPE_DECL, because
+ that changes what the typedef is typing. */
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "nocommon" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_nocommon_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (VAR_P (*node))
+ DECL_COMMON (*node) = 0;
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "common" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_common_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (VAR_P (*node))
+ DECL_COMMON (*node) = 1;
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "noreturn" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+tree
+handle_noreturn_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree type = TREE_TYPE (*node);
+
+ /* See FIXME comment in c_common_attribute_table. */
+ if (TREE_CODE (*node) == FUNCTION_DECL
+ || objc_method_decl (TREE_CODE (*node)))
+ TREE_THIS_VOLATILE (*node) = 1;
+ else if (TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
+ TREE_TYPE (*node)
+ = (build_qualified_type
+ (build_pointer_type
+ (build_type_variant (TREE_TYPE (type),
+ TYPE_READONLY (TREE_TYPE (type)), 1)),
+ TYPE_QUALS (type)));
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "hot" and attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_hot_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL
+ || TREE_CODE (*node) == LABEL_DECL)
+ {
+ /* Attribute hot processing is done later with lookup_attribute. */
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "cold" and attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_cold_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL
+ || TREE_CODE (*node) == LABEL_DECL)
+ {
+ /* Attribute cold processing is done later with lookup_attribute. */
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Add FLAGS for a function NODE to no_sanitize_flags in DECL_ATTRIBUTES. */
+
+void
+add_no_sanitize_value (tree node, unsigned int flags)
+{
+ tree attr = lookup_attribute ("no_sanitize", DECL_ATTRIBUTES (node));
+ if (attr)
+ {
+ unsigned int old_value = tree_to_uhwi (TREE_VALUE (attr));
+ flags |= old_value;
+
+ if (flags == old_value)
+ return;
+
+ TREE_VALUE (attr) = build_int_cst (unsigned_type_node, flags);
+ }
+ else
+ DECL_ATTRIBUTES (node)
+ = tree_cons (get_identifier ("no_sanitize"),
+ build_int_cst (unsigned_type_node, flags),
+ DECL_ATTRIBUTES (node));
+}
+
+/* Handle a "no_sanitize" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_sanitize_attribute (tree *node, tree name, tree args, int,
+ bool *no_add_attrs)
+{
+ unsigned int flags = 0;
+ *no_add_attrs = true;
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ return NULL_TREE;
+ }
+
+ for (; args; args = TREE_CHAIN (args))
+ {
+ tree id = TREE_VALUE (args);
+ if (TREE_CODE (id) != STRING_CST)
+ {
+ error ("%qE argument not a string", name);
+ return NULL_TREE;
+ }
+
+ char *string = ASTRDUP (TREE_STRING_POINTER (id));
+ flags |= parse_no_sanitize_attribute (string);
+ }
+
+ add_no_sanitize_value (*node, flags);
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_sanitize_address" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_sanitize_address_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ else
+ add_no_sanitize_value (*node, SANITIZE_ADDRESS);
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_sanitize_thread" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_sanitize_thread_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ else
+ add_no_sanitize_value (*node, SANITIZE_THREAD);
+
+ return NULL_TREE;
+}
+
+
+/* Handle a "no_address_safety_analysis" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_address_safety_analysis_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ else
+ add_no_sanitize_value (*node, SANITIZE_ADDRESS);
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_sanitize_undefined" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_sanitize_undefined_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ else
+ add_no_sanitize_value (*node,
+ SANITIZE_UNDEFINED | SANITIZE_UNDEFINED_NONDEFAULT);
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_sanitize_coverage" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_sanitize_coverage_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle an "asan odr indicator" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_asan_odr_indicator_attribute (tree *, tree, tree, int, bool *)
+{
+ return NULL_TREE;
+}
+
+/* Handle a "stack_protect" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_stack_protect_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_stack_protector" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_stack_protector_function_attribute (tree *node, tree name, tree,
+ int, bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "noipa" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_noipa_attribute (tree *node, tree name, tree, int, bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "noinline" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_noinline_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ {
+ if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+ "with attribute %qs", name, "always_inline");
+ *no_add_attrs = true;
+ }
+ else
+ DECL_UNINLINABLE (*node) = 1;
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "noclone" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_noclone_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "nocf_check" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_nocf_check_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_TYPE
+ && TREE_CODE (*node) != METHOD_TYPE)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+ else if (!(flag_cf_protection & CF_BRANCH))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored. Use "
+ "%<-fcf-protection%> option to enable it",
+ name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_icf" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_noicf_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+
+/* Handle a "always_inline" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_always_inline_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ {
+ if (lookup_attribute ("noinline", DECL_ATTRIBUTES (*node)))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+ "with %qs attribute", name, "noinline");
+ *no_add_attrs = true;
+ }
+ else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node)))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+ "with %qs attribute", name, "target_clones");
+ *no_add_attrs = true;
+ }
+ else
+ /* Set the attribute and mark it for disregarding inline
+ limits. */
+ DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "gnu_inline" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_gnu_inline_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (*node))
+ {
+ /* Do nothing else, just set the attribute. We'll get at
+ it later with lookup_attribute. */
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "leaf" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_leaf_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+ if (!TREE_PUBLIC (*node))
+ {
+ warning (OPT_Wattributes, "%qE attribute has no effect on unit local "
+ "functions", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle an "artificial" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_artificial_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (*node))
+ {
+ /* Do nothing else, just set the attribute. We'll get at
+ it later with lookup_attribute. */
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "flatten" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_flatten_attribute (tree *node, tree name,
+ tree args ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED, bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ /* Do nothing else, just set the attribute. We'll get at
+ it later with lookup_attribute. */
+ ;
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "warning" or "error" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_error_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL
+ && TREE_CODE (TREE_VALUE (args)) == STRING_CST)
+ /* Do nothing else, just set the attribute. We'll get at
+ it later with lookup_attribute. */
+ ;
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "used" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_used_attribute (tree *pnode, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree node = *pnode;
+
+ if (TREE_CODE (node) == FUNCTION_DECL
+ || (VAR_P (node) && TREE_STATIC (node))
+ || (TREE_CODE (node) == TYPE_DECL))
+ {
+ TREE_USED (node) = 1;
+ DECL_PRESERVE_P (node) = 1;
+ if (VAR_P (node))
+ DECL_READ_P (node) = 1;
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "unused" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+tree
+handle_unused_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int flags, bool *no_add_attrs)
+{
+ if (DECL_P (*node))
+ {
+ tree decl = *node;
+
+ if (TREE_CODE (decl) == PARM_DECL
+ || VAR_OR_FUNCTION_DECL_P (decl)
+ || TREE_CODE (decl) == LABEL_DECL
+ || TREE_CODE (decl) == CONST_DECL
+ || TREE_CODE (decl) == FIELD_DECL
+ || TREE_CODE (decl) == TYPE_DECL)
+ {
+ TREE_USED (decl) = 1;
+ if (VAR_P (decl) || TREE_CODE (decl) == PARM_DECL)
+ DECL_READ_P (decl) = 1;
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+ }
+ else
+ {
+ if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ *node = build_variant_type_copy (*node);
+ TREE_USED (*node) = 1;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "retain" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_retain_attribute (tree *pnode, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree node = *pnode;
+
+ if (SUPPORTS_SHF_GNU_RETAIN
+ && (TREE_CODE (node) == FUNCTION_DECL
+ || (VAR_P (node) && TREE_STATIC (node))))
+ ;
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle an "uninitialized" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_uninitialized_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree decl = *node;
+ if (!VAR_P (decl))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored because %qD "
+ "is not a variable", name, decl);
+ *no_add_attrs = true;
+ }
+ else if (TREE_STATIC (decl) || DECL_EXTERNAL (decl))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored because %qD "
+ "is not a local variable", name, decl);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "externally_visible" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_externally_visible_attribute (tree *pnode, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ tree node = *pnode;
+
+ if (VAR_OR_FUNCTION_DECL_P (node))
+ {
+ if ((!TREE_STATIC (node) && TREE_CODE (node) != FUNCTION_DECL
+ && !DECL_EXTERNAL (node)) || !TREE_PUBLIC (node))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute have effect only on public objects", name);
+ *no_add_attrs = true;
+ }
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle the "no_reorder" attribute. Arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_reorder_attribute (tree *pnode,
+ tree name,
+ tree,
+ int,
+ bool *no_add_attrs)
+{
+ tree node = *pnode;
+
+ if (!VAR_OR_FUNCTION_DECL_P (node)
+ && !(TREE_STATIC (node) || DECL_EXTERNAL (node)))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute only affects top level objects",
+ name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "const" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_const_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int flags, bool *no_add_attrs)
+{
+ tree type = TREE_TYPE (*node);
+
+ /* See FIXME comment on noreturn in c_common_attribute_table. */
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ TREE_READONLY (*node) = 1;
+ else if (TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
+ TREE_TYPE (*node)
+ = (build_qualified_type
+ (build_pointer_type
+ (build_type_variant (TREE_TYPE (type), 1,
+ TREE_THIS_VOLATILE (TREE_TYPE (type)))),
+ TYPE_QUALS (type)));
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ /* void __builtin_unreachable(void) is const. Accept other such
+ built-ins but warn on user-defined functions that return void. */
+ if (!(flags & ATTR_FLAG_BUILT_IN)
+ && TREE_CODE (*node) == FUNCTION_DECL
+ && VOID_TYPE_P (TREE_TYPE (type)))
+ warning (OPT_Wattributes, "%qE attribute on function "
+ "returning %<void%>", name);
+
+ return NULL_TREE;
+}
+
+/* Handle a "scalar_storage_order" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_scalar_storage_order_attribute (tree *node, tree name, tree args,
+ int flags, bool *no_add_attrs)
+{
+ tree id = TREE_VALUE (args);
+ tree type;
+
+ if (TREE_CODE (*node) == TYPE_DECL
+ && ! (flags & ATTR_FLAG_CXX11))
+ node = &TREE_TYPE (*node);
+ type = *node;
+
+ if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN)
+ {
+ error ("%qE attribute is not supported because endianness is not uniform",
+ name);
+ return NULL_TREE;
+ }
+
+ if (RECORD_OR_UNION_TYPE_P (type) && !c_dialect_cxx ())
+ {
+ bool reverse = false;
+
+ if (TREE_CODE (id) == STRING_CST
+ && strcmp (TREE_STRING_POINTER (id), "big-endian") == 0)
+ reverse = !BYTES_BIG_ENDIAN;
+ else if (TREE_CODE (id) == STRING_CST
+ && strcmp (TREE_STRING_POINTER (id), "little-endian") == 0)
+ reverse = BYTES_BIG_ENDIAN;
+ else
+ {
+ error ("attribute %qE argument must be one of %qs or %qs",
+ name, "big-endian", "little-endian");
+ return NULL_TREE;
+ }
+
+ if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ {
+ if (reverse)
+ /* A type variant isn't good enough, since we don't want a cast
+ to such a type to be removed as a no-op. */
+ *node = type = build_duplicate_type (type);
+ }
+
+ TYPE_REVERSE_STORAGE_ORDER (type) = reverse;
+ return NULL_TREE;
+ }
+
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+}
+
+/* Handle a "transparent_union" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_transparent_union_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args), int flags,
+ bool *no_add_attrs)
+{
+ tree type;
+
+ *no_add_attrs = true;
+
+ if (TREE_CODE (*node) == TYPE_DECL
+ && ! (flags & ATTR_FLAG_CXX11))
+ node = &TREE_TYPE (*node);
+ type = *node;
+
+ if (TREE_CODE (type) == UNION_TYPE)
+ {
+ /* Make sure that the first field will work for a transparent union.
+ If the type isn't complete yet, leave the check to the code in
+ finish_struct. */
+ if (TYPE_SIZE (type))
+ {
+ tree first = first_field (type);
+ if (first == NULL_TREE
+ || DECL_ARTIFICIAL (first)
+ || TYPE_MODE (type) != DECL_MODE (first))
+ goto ignored;
+ }
+
+ if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ {
+ /* If the type isn't complete yet, setting the flag
+ on a variant wouldn't ever be checked. */
+ if (!TYPE_SIZE (type))
+ goto ignored;
+
+ /* build_duplicate_type doesn't work for C++. */
+ if (c_dialect_cxx ())
+ goto ignored;
+
+ /* A type variant isn't good enough, since we don't want a cast
+ to such a type to be removed as a no-op. */
+ *node = type = build_duplicate_type (type);
+ }
+
+ for (tree t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
+ TYPE_TRANSPARENT_AGGR (t) = 1;
+ return NULL_TREE;
+ }
+
+ ignored:
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ return NULL_TREE;
+}
+
+/* Subroutine of handle_{con,de}structor_attribute. Evaluate ARGS to
+ get the requested priority for a constructor or destructor,
+ possibly issuing diagnostics for invalid or reserved
+ priorities. */
+
+static priority_type
+get_priority (tree args, bool is_destructor)
+{
+ HOST_WIDE_INT pri;
+ tree arg;
+
+ if (!args)
+ return DEFAULT_INIT_PRIORITY;
+
+ if (!SUPPORTS_INIT_PRIORITY)
+ {
+ if (is_destructor)
+ error ("destructor priorities are not supported");
+ else
+ error ("constructor priorities are not supported");
+ return DEFAULT_INIT_PRIORITY;
+ }
+
+ arg = TREE_VALUE (args);
+ if (TREE_CODE (arg) == IDENTIFIER_NODE)
+ goto invalid;
+ if (arg == error_mark_node)
+ return DEFAULT_INIT_PRIORITY;
+ arg = default_conversion (arg);
+ if (!tree_fits_shwi_p (arg)
+ || !INTEGRAL_TYPE_P (TREE_TYPE (arg)))
+ goto invalid;
+
+ pri = tree_to_shwi (arg);
+ if (pri < 0 || pri > MAX_INIT_PRIORITY)
+ goto invalid;
+
+ if (pri <= MAX_RESERVED_INIT_PRIORITY)
+ {
+ if (is_destructor)
+ warning (OPT_Wprio_ctor_dtor,
+ "destructor priorities from 0 to %d are reserved "
+ "for the implementation",
+ MAX_RESERVED_INIT_PRIORITY);
+ else
+ warning (OPT_Wprio_ctor_dtor,
+ "constructor priorities from 0 to %d are reserved "
+ "for the implementation",
+ MAX_RESERVED_INIT_PRIORITY);
+ }
+ return pri;
+
+ invalid:
+ if (is_destructor)
+ error ("destructor priorities must be integers from 0 to %d inclusive",
+ MAX_INIT_PRIORITY);
+ else
+ error ("constructor priorities must be integers from 0 to %d inclusive",
+ MAX_INIT_PRIORITY);
+ return DEFAULT_INIT_PRIORITY;
+}
+
+/* Handle a "constructor" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_constructor_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ tree decl = *node;
+ tree type = TREE_TYPE (decl);
+
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && TREE_CODE (type) == FUNCTION_TYPE
+ && decl_function_context (decl) == 0)
+ {
+ priority_type priority;
+ DECL_STATIC_CONSTRUCTOR (decl) = 1;
+ priority = get_priority (args, /*is_destructor=*/false);
+ SET_DECL_INIT_PRIORITY (decl, priority);
+ TREE_USED (decl) = 1;
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "destructor" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_destructor_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ tree decl = *node;
+ tree type = TREE_TYPE (decl);
+
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && TREE_CODE (type) == FUNCTION_TYPE
+ && decl_function_context (decl) == 0)
+ {
+ priority_type priority;
+ DECL_STATIC_DESTRUCTOR (decl) = 1;
+ priority = get_priority (args, /*is_destructor=*/true);
+ SET_DECL_FINI_PRIORITY (decl, priority);
+ TREE_USED (decl) = 1;
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Nonzero if the mode is a valid vector mode for this architecture.
+ This returns nonzero even if there is no hardware support for the
+ vector mode, but we can emulate with narrower modes. */
+
+static bool
+vector_mode_valid_p (machine_mode mode)
+{
+ enum mode_class mclass = GET_MODE_CLASS (mode);
+
+ /* Doh! What's going on? */
+ if (mclass != MODE_VECTOR_INT
+ && mclass != MODE_VECTOR_FLOAT
+ && mclass != MODE_VECTOR_FRACT
+ && mclass != MODE_VECTOR_UFRACT
+ && mclass != MODE_VECTOR_ACCUM
+ && mclass != MODE_VECTOR_UACCUM)
+ return false;
+
+ /* Hardware support. Woo hoo! */
+ if (targetm.vector_mode_supported_p (mode))
+ return true;
+
+ /* We should probably return 1 if requesting V4DI and we have no DI,
+ but we have V2DI, but this is probably very unlikely. */
+
+ /* If we have support for the inner mode, we can safely emulate it.
+ We may not have V2DI, but me can emulate with a pair of DIs. */
+ return targetm.scalar_mode_supported_p (GET_MODE_INNER (mode));
+}
+
+
+/* Handle a "mode" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_mode_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree type = *node;
+ tree ident = TREE_VALUE (args);
+
+ *no_add_attrs = true;
+
+ if (TREE_CODE (ident) != IDENTIFIER_NODE)
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ else
+ {
+ int j;
+ const char *p = IDENTIFIER_POINTER (ident);
+ int len = strlen (p);
+ machine_mode mode = VOIDmode;
+ tree typefm;
+ bool valid_mode;
+
+ if (len > 4 && p[0] == '_' && p[1] == '_'
+ && p[len - 1] == '_' && p[len - 2] == '_')
+ {
+ char *newp = (char *) alloca (len - 1);
+
+ strcpy (newp, &p[2]);
+ newp[len - 4] = '\0';
+ p = newp;
+ }
+
+ /* Change this type to have a type with the specified mode.
+ First check for the special modes. */
+ if (!strcmp (p, "byte"))
+ mode = byte_mode;
+ else if (!strcmp (p, "word"))
+ mode = word_mode;
+ else if (!strcmp (p, "pointer"))
+ mode = ptr_mode;
+ else if (!strcmp (p, "libgcc_cmp_return"))
+ mode = targetm.libgcc_cmp_return_mode ();
+ else if (!strcmp (p, "libgcc_shift_count"))
+ mode = targetm.libgcc_shift_count_mode ();
+ else if (!strcmp (p, "unwind_word"))
+ mode = targetm.unwind_word_mode ();
+ else
+ for (j = 0; j < NUM_MACHINE_MODES; j++)
+ if (!strcmp (p, GET_MODE_NAME (j)))
+ {
+ mode = (machine_mode) j;
+ break;
+ }
+
+ if (mode == VOIDmode)
+ {
+ error ("unknown machine mode %qE", ident);
+ return NULL_TREE;
+ }
+
+ /* Allow the target a chance to translate MODE into something supported.
+ See PR86324. */
+ mode = targetm.translate_mode_attribute (mode);
+
+ valid_mode = false;
+ switch (GET_MODE_CLASS (mode))
+ {
+ case MODE_INT:
+ case MODE_PARTIAL_INT:
+ case MODE_FLOAT:
+ case MODE_DECIMAL_FLOAT:
+ case MODE_FRACT:
+ case MODE_UFRACT:
+ case MODE_ACCUM:
+ case MODE_UACCUM:
+ valid_mode
+ = targetm.scalar_mode_supported_p (as_a <scalar_mode> (mode));
+ break;
+
+ case MODE_COMPLEX_INT:
+ case MODE_COMPLEX_FLOAT:
+ valid_mode = targetm.scalar_mode_supported_p (GET_MODE_INNER (mode));
+ break;
+
+ case MODE_VECTOR_INT:
+ case MODE_VECTOR_FLOAT:
+ case MODE_VECTOR_FRACT:
+ case MODE_VECTOR_UFRACT:
+ case MODE_VECTOR_ACCUM:
+ case MODE_VECTOR_UACCUM:
+ warning (OPT_Wattributes, "specifying vector types with "
+ "%<__attribute__ ((mode))%> is deprecated");
+ inform (input_location,
+ "use %<__attribute__ ((vector_size))%> instead");
+ valid_mode = vector_mode_valid_p (mode);
+ break;
+
+ default:
+ break;
+ }
+ if (!valid_mode)
+ {
+ error ("unable to emulate %qs", p);
+ return NULL_TREE;
+ }
+
+ if (POINTER_TYPE_P (type))
+ {
+ scalar_int_mode addr_mode;
+ addr_space_t as = TYPE_ADDR_SPACE (TREE_TYPE (type));
+ tree (*fn)(tree, machine_mode, bool);
+
+ if (!is_a <scalar_int_mode> (mode, &addr_mode)
+ || !targetm.addr_space.valid_pointer_mode (addr_mode, as))
+ {
+ error ("invalid pointer mode %qs", p);
+ return NULL_TREE;
+ }
+
+ if (TREE_CODE (type) == POINTER_TYPE)
+ fn = build_pointer_type_for_mode;
+ else
+ fn = build_reference_type_for_mode;
+ typefm = fn (TREE_TYPE (type), addr_mode, false);
+ }
+ else
+ {
+ /* For fixed-point modes, we need to test if the signness of type
+ and the machine mode are consistent. */
+ if (ALL_FIXED_POINT_MODE_P (mode)
+ && TYPE_UNSIGNED (type) != UNSIGNED_FIXED_POINT_MODE_P (mode))
+ {
+ error ("signedness of type and machine mode %qs don%'t match", p);
+ return NULL_TREE;
+ }
+ /* For fixed-point modes, we need to pass saturating info. */
+ typefm = lang_hooks.types.type_for_mode (mode,
+ ALL_FIXED_POINT_MODE_P (mode) ? TYPE_SATURATING (type)
+ : TYPE_UNSIGNED (type));
+ }
+
+ if (typefm == NULL_TREE)
+ {
+ error ("no data type for mode %qs", p);
+ return NULL_TREE;
+ }
+ else if (TREE_CODE (type) == ENUMERAL_TYPE)
+ {
+ /* For enumeral types, copy the precision from the integer
+ type returned above. If not an INTEGER_TYPE, we can't use
+ this mode for this type. */
+ if (TREE_CODE (typefm) != INTEGER_TYPE)
+ {
+ error ("cannot use mode %qs for enumerated types", p);
+ return NULL_TREE;
+ }
+
+ if (flags & ATTR_FLAG_TYPE_IN_PLACE)
+ {
+ TYPE_PRECISION (type) = TYPE_PRECISION (typefm);
+ typefm = type;
+ }
+ else
+ {
+ /* We cannot build a type variant, as there's code that assumes
+ that TYPE_MAIN_VARIANT has the same mode. This includes the
+ debug generators. Instead, create a subrange type. This
+ results in all of the enumeral values being emitted only once
+ in the original, and the subtype gets them by reference. */
+ if (TYPE_UNSIGNED (type))
+ typefm = make_unsigned_type (TYPE_PRECISION (typefm));
+ else
+ typefm = make_signed_type (TYPE_PRECISION (typefm));
+ TREE_TYPE (typefm) = type;
+ }
+ *no_add_attrs = false;
+ }
+ else if (VECTOR_MODE_P (mode)
+ ? TREE_CODE (type) != TREE_CODE (TREE_TYPE (typefm))
+ : TREE_CODE (type) != TREE_CODE (typefm))
+ {
+ error ("mode %qs applied to inappropriate type", p);
+ return NULL_TREE;
+ }
+
+ *node = build_qualified_type (typefm, TYPE_QUALS (type));
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "section" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_section_attribute (tree *node, tree name, tree args,
+ int flags, bool *no_add_attrs)
+{
+ tree decl = *node;
+ tree res = NULL_TREE;
+ tree argval = TREE_VALUE (args);
+ const char* new_section_name;
+
+ if (!targetm_common.have_named_sections)
+ {
+ error_at (DECL_SOURCE_LOCATION (*node),
+ "section attributes are not supported for this target");
+ goto fail;
+ }
+
+ if (!VAR_OR_FUNCTION_DECL_P (decl))
+ {
+ error ("section attribute not allowed for %q+D", *node);
+ goto fail;
+ }
+
+ if (TREE_CODE (argval) != STRING_CST)
+ {
+ error ("section attribute argument not a string constant");
+ goto fail;
+ }
+
+ if (VAR_P (decl)
+ && current_function_decl != NULL_TREE
+ && !TREE_STATIC (decl))
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "section attribute cannot be specified for local variables");
+ goto fail;
+ }
+
+ new_section_name = TREE_STRING_POINTER (argval);
+
+ /* The decl may have already been given a section attribute
+ from a previous declaration. Ensure they match. */
+ if (const char* const old_section_name = DECL_SECTION_NAME (decl))
+ if (strcmp (old_section_name, new_section_name) != 0)
+ {
+ error ("section of %q+D conflicts with previous declaration",
+ *node);
+ goto fail;
+ }
+
+ if (VAR_P (decl)
+ && !targetm.have_tls && targetm.emutls.tmpl_section
+ && DECL_THREAD_LOCAL_P (decl))
+ {
+ error ("section of %q+D cannot be overridden", *node);
+ goto fail;
+ }
+
+ if (!validate_attr_arg (node, name, argval))
+ goto fail;
+
+ res = targetm.handle_generic_attribute (node, name, args, flags,
+ no_add_attrs);
+
+ /* If the back end confirms the attribute can be added then continue onto
+ final processing. */
+ if (!(*no_add_attrs))
+ {
+ set_decl_section_name (decl, new_section_name);
+ return res;
+ }
+
+fail:
+ *no_add_attrs = true;
+ return res;
+}
+
+/* Common codes shared by handle_warn_if_not_aligned_attribute and
+ handle_aligned_attribute. */
+
+static tree
+common_handle_aligned_attribute (tree *node, tree name, tree args, int flags,
+ bool *no_add_attrs,
+ bool warn_if_not_aligned_p)
+{
+ tree decl = NULL_TREE;
+ tree *type = NULL;
+ bool is_type = false;
+ tree align_expr;
+
+ /* The last (already pushed) declaration with all validated attributes
+ merged in or the current about-to-be-pushed one if one hasn't been
+ yet. */
+ tree last_decl = node[1] ? node[1] : *node;
+
+ if (args)
+ {
+ align_expr = TREE_VALUE (args);
+ if (align_expr && TREE_CODE (align_expr) != IDENTIFIER_NODE
+ && TREE_CODE (align_expr) != FUNCTION_DECL)
+ align_expr = default_conversion (align_expr);
+ }
+ else
+ align_expr = size_int (ATTRIBUTE_ALIGNED_VALUE / BITS_PER_UNIT);
+
+ if (DECL_P (*node))
+ {
+ decl = *node;
+ type = &TREE_TYPE (decl);
+ is_type = TREE_CODE (*node) == TYPE_DECL;
+ }
+ else if (TYPE_P (*node))
+ type = node, is_type = true;
+
+ /* True to consider invalid alignments greater than MAX_OFILE_ALIGNMENT. */
+ bool objfile = (TREE_CODE (*node) == FUNCTION_DECL
+ || (VAR_P (*node) && TREE_STATIC (*node)));
+ /* Log2 of specified alignment. */
+ int pow2align = check_user_alignment (align_expr, objfile,
+ /* warn_zero = */ true);
+ if (pow2align == -1)
+ {
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* The alignment in bits corresponding to the specified alignment. */
+ unsigned bitalign = (1U << pow2align) * BITS_PER_UNIT;
+
+ /* The alignment of the current declaration and that of the last
+ pushed declaration, determined on demand below. */
+ unsigned curalign = 0;
+ unsigned lastalign = 0;
+
+ /* True when SET_DECL_ALIGN() should be called for the decl when
+ *NO_ADD_ATTRS is false. */
+ bool set_align = true;
+ if (is_type)
+ {
+ if ((flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ /* OK, modify the type in place. */;
+ /* If we have a TYPE_DECL, then copy the type, so that we
+ don't accidentally modify a builtin type. See pushdecl. */
+ else if (decl && TREE_TYPE (decl) != error_mark_node
+ && DECL_ORIGINAL_TYPE (decl) == NULL_TREE)
+ {
+ tree tt = TREE_TYPE (decl);
+ *type = build_variant_type_copy (*type);
+ DECL_ORIGINAL_TYPE (decl) = tt;
+ TYPE_NAME (*type) = decl;
+ TREE_USED (*type) = TREE_USED (decl);
+ TREE_TYPE (decl) = *type;
+ }
+ else
+ *type = build_variant_type_copy (*type);
+
+ if (warn_if_not_aligned_p)
+ {
+ SET_TYPE_WARN_IF_NOT_ALIGN (*type, bitalign);
+ warn_if_not_aligned_p = false;
+ }
+ else
+ {
+ SET_TYPE_ALIGN (*type, bitalign);
+ TYPE_USER_ALIGN (*type) = 1;
+ }
+ }
+ else if (! VAR_OR_FUNCTION_DECL_P (decl)
+ && TREE_CODE (decl) != FIELD_DECL)
+ {
+ error ("alignment may not be specified for %q+D", decl);
+ *no_add_attrs = true;
+ }
+ else if (TREE_CODE (decl) == FUNCTION_DECL
+ && (((curalign = DECL_ALIGN (decl)) > bitalign)
+ | ((lastalign = DECL_ALIGN (last_decl)) > bitalign)))
+ {
+ /* Either a prior attribute on the same declaration or one
+ on a prior declaration of the same function specifies
+ stricter alignment than this attribute. */
+ bool note = (lastalign > curalign
+ || (lastalign == curalign
+ && (DECL_USER_ALIGN (last_decl)
+ > DECL_USER_ALIGN (decl))));
+ if (note)
+ curalign = lastalign;
+
+ curalign /= BITS_PER_UNIT;
+ unsigned newalign = bitalign / BITS_PER_UNIT;
+
+ auto_diagnostic_group d;
+ if ((DECL_USER_ALIGN (decl)
+ || DECL_USER_ALIGN (last_decl)))
+ {
+ if (warning (OPT_Wattributes,
+ "ignoring attribute %<%E (%u)%> because it conflicts "
+ "with attribute %<%E (%u)%>",
+ name, newalign, name, curalign)
+ && note)
+ inform (DECL_SOURCE_LOCATION (last_decl),
+ "previous declaration here");
+ /* Only reject attempts to relax/override an alignment
+ explicitly specified previously and accept declarations
+ that appear to relax the implicit function alignment for
+ the target. Both increasing and increasing the alignment
+ set by -falign-functions setting is permitted. */
+ *no_add_attrs = true;
+ }
+ else if (!warn_if_not_aligned_p)
+ {
+ /* Do not fail for attribute warn_if_not_aligned. Otherwise,
+ silently avoid applying the alignment to the declaration
+ because it's implicitly satisfied by the target. Apply
+ the attribute nevertheless so it can be retrieved by
+ __builtin_has_attribute. */
+ set_align = false;
+ }
+ }
+ else if (DECL_USER_ALIGN (decl)
+ && DECL_ALIGN (decl) > bitalign)
+ /* C++-11 [dcl.align/4]:
+
+ When multiple alignment-specifiers are specified for an
+ entity, the alignment requirement shall be set to the
+ strictest specified alignment.
+
+ This formally comes from the c++11 specification but we are
+ doing it for the GNU attribute syntax as well. */
+ *no_add_attrs = true;
+ else if (warn_if_not_aligned_p
+ && TREE_CODE (decl) == FIELD_DECL
+ && !DECL_C_BIT_FIELD (decl))
+ {
+ SET_DECL_WARN_IF_NOT_ALIGN (decl, bitalign);
+ warn_if_not_aligned_p = false;
+ set_align = false;
+ }
+
+ if (warn_if_not_aligned_p)
+ {
+ error ("%<warn_if_not_aligned%> may not be specified for %q+D",
+ decl);
+ *no_add_attrs = true;
+ }
+ else if (!is_type && !*no_add_attrs && set_align)
+ {
+ SET_DECL_ALIGN (decl, bitalign);
+ DECL_USER_ALIGN (decl) = 1;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "aligned" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_aligned_attribute (tree *node, tree name, tree args,
+ int flags, bool *no_add_attrs)
+{
+ return common_handle_aligned_attribute (node, name, args, flags,
+ no_add_attrs, false);
+}
+
+/* Handle a "warn_if_not_aligned" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_warn_if_not_aligned_attribute (tree *node, tree name,
+ tree args, int flags,
+ bool *no_add_attrs)
+{
+ return common_handle_aligned_attribute (node, name, args, flags,
+ no_add_attrs, true);
+}
+
+/* Handle a "weak" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_weak_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool * ARG_UNUSED (no_add_attrs))
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL
+ && DECL_DECLARED_INLINE_P (*node))
+ {
+ warning (OPT_Wattributes, "inline function %q+D declared weak", *node);
+ *no_add_attrs = true;
+ }
+ else if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (*node)))
+ {
+ error ("indirect function %q+D cannot be declared weak", *node);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ else if (VAR_OR_FUNCTION_DECL_P (*node))
+ declare_weak (*node);
+ else
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+
+ return NULL_TREE;
+}
+
+/* Handle a "noinit" or "persistent" attribute; arguments as in
+ struct attribute_spec.handler.
+ This generic handler is used for "special variable sections" that allow the
+ section name to be set using a dedicated attribute. Additional validation
+ is performed for the specific properties of the section corresponding to the
+ attribute.
+ The ".noinit" section *is not* loaded by the program loader, and is not
+ initialized by the runtime startup code.
+ The ".persistent" section *is* loaded by the program loader, but is not
+ initialized by the runtime startup code. */
+static tree
+handle_special_var_sec_attribute (tree *node, tree name, tree args,
+ int flags, bool *no_add_attrs)
+{
+ tree decl = *node;
+ tree res = NULL_TREE;
+
+ /* First perform generic validation common to "noinit" and "persistent"
+ attributes. */
+ if (!targetm_common.have_named_sections)
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "section attributes are not supported for this target");
+ goto fail;
+ }
+
+ if (!VAR_P (decl))
+ {
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+ "ignoring %qE attribute not set on a variable",
+ name);
+ goto fail;
+ }
+
+ if (VAR_P (decl)
+ && current_function_decl != NULL_TREE
+ && !TREE_STATIC (decl))
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE attribute cannot be specified for local variables",
+ name);
+ goto fail;
+ }
+
+ if (VAR_P (decl)
+ && !targetm.have_tls && targetm.emutls.tmpl_section
+ && DECL_THREAD_LOCAL_P (decl))
+ {
+ error ("section of %q+D cannot be overridden", decl);
+ goto fail;
+ }
+
+ if (!targetm.have_switchable_bss_sections)
+ {
+ error ("%qE attribute is specific to ELF targets", name);
+ goto fail;
+ }
+
+ if (TREE_READONLY (decl))
+ {
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+ "ignoring %qE attribute set on const variable",
+ name);
+ goto fail;
+ }
+
+ /* Now validate noinit/persistent individually. */
+ if (strcmp (IDENTIFIER_POINTER (name), "noinit") == 0)
+ {
+ if (DECL_INITIAL (decl))
+ {
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+ "ignoring %qE attribute set on initialized variable",
+ name);
+ goto fail;
+ }
+ /* If this var is thought to be common, then change this. "noinit"
+ variables must be placed in an explicit ".noinit" section. */
+ DECL_COMMON (decl) = 0;
+ }
+ else if (strcmp (IDENTIFIER_POINTER (name), "persistent") == 0)
+ {
+ if (DECL_COMMON (decl) || DECL_INITIAL (decl) == NULL_TREE)
+ {
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+ "ignoring %qE attribute set on uninitialized variable",
+ name);
+ goto fail;
+ }
+ }
+ else
+ gcc_unreachable ();
+
+ res = targetm.handle_generic_attribute (node, name, args, flags,
+ no_add_attrs);
+
+ /* If the back end confirms the attribute can be added then continue onto
+ final processing. */
+ if (!(*no_add_attrs))
+ return res;
+
+fail:
+ *no_add_attrs = true;
+ return res;
+}
+
+/* Handle a "noplt" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_noplt_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool * ARG_UNUSED (no_add_attrs))
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute is only applicable on functions", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ return NULL_TREE;
+}
+
+/* Handle a "symver" attribute. */
+
+static tree
+handle_symver_attribute (tree *node, tree ARG_UNUSED (name), tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree symver;
+ const char *symver_str;
+
+ if (TREE_CODE (*node) != FUNCTION_DECL && TREE_CODE (*node) != VAR_DECL)
+ {
+ warning (OPT_Wattributes,
+ "%<symver%> attribute only applies to functions and variables");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (!decl_in_symtab_p (*node))
+ {
+ warning (OPT_Wattributes,
+ "%<symver%> attribute is only applicable to symbols");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ for (; args; args = TREE_CHAIN (args))
+ {
+ symver = TREE_VALUE (args);
+ if (TREE_CODE (symver) != STRING_CST)
+ {
+ error ("%<symver%> attribute argument not a string constant");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ symver_str = TREE_STRING_POINTER (symver);
+
+ int ats = 0;
+ for (int n = 0; (int)n < TREE_STRING_LENGTH (symver); n++)
+ if (symver_str[n] == '@')
+ ats++;
+
+ if (ats != 1 && ats != 2)
+ {
+ error ("symver attribute argument must have format %<name@nodename%>");
+ error ("%<symver%> attribute argument %qs must contain one or two "
+ "%<@%>", symver_str);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ }
+
+ return NULL_TREE;
+}
+
+
+/* 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. */
+
+static tree
+handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args,
+ bool *no_add_attrs)
+{
+ tree decl = *node;
+
+ if (TREE_CODE (decl) != FUNCTION_DECL
+ && (!is_alias || !VAR_P (decl)))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+ else if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
+ || (TREE_CODE (decl) != FUNCTION_DECL
+ && TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl))
+ /* A static variable declaration is always a tentative definition,
+ but the alias is a non-tentative definition which overrides. */
+ || (TREE_CODE (decl) != FUNCTION_DECL
+ && ! TREE_PUBLIC (decl) && DECL_INITIAL (decl)))
+ {
+ error ("%q+D defined both normally and as %qE attribute", decl, name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ else if (!is_alias
+ && (lookup_attribute ("weak", DECL_ATTRIBUTES (decl))
+ || lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))))
+ {
+ error ("weak %q+D cannot be defined %qE", decl, name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* Note that the very first time we process a nested declaration,
+ decl_function_context will not be set. Indeed, *would* never
+ be set except for the DECL_INITIAL/DECL_EXTERNAL frobbery that
+ we do below. After such frobbery, pushdecl would set the context.
+ In any case, this is never what we want. */
+ else if (decl_function_context (decl) == 0 && current_function_decl == NULL)
+ {
+ tree id;
+
+ id = TREE_VALUE (args);
+ if (TREE_CODE (id) != STRING_CST)
+ {
+ error ("attribute %qE argument not a string", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ id = get_identifier (TREE_STRING_POINTER (id));
+ /* This counts as a use of the object pointed to. */
+ TREE_USED (id) = 1;
+
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ DECL_INITIAL (decl) = error_mark_node;
+ else
+ TREE_STATIC (decl) = 1;
+
+ if (!is_alias)
+ {
+ /* ifuncs are also aliases, so set that attribute too. */
+ DECL_ATTRIBUTES (decl)
+ = tree_cons (get_identifier ("alias"), args,
+ DECL_ATTRIBUTES (decl));
+ DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("ifunc"),
+ NULL, DECL_ATTRIBUTES (decl));
+ }
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ if (decl_in_symtab_p (*node))
+ {
+ struct symtab_node *n = symtab_node::get (decl);
+ if (n && n->refuse_visibility_changes)
+ error ("%+qD declared %qs after being used",
+ decl, is_alias ? "alias" : "ifunc");
+ }
+
+
+ return NULL_TREE;
+}
+
+/* Handle an "alias" or "ifunc" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_ifunc_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ return handle_alias_ifunc_attribute (false, node, name, args, no_add_attrs);
+}
+
+/* Handle an "alias" or "ifunc" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_alias_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ return handle_alias_ifunc_attribute (true, node, name, args, no_add_attrs);
+}
+
+/* Handle the "copy" attribute NAME by copying the set of attributes
+ from the symbol referenced by ARGS to the declaration of *NODE. */
+
+static tree
+handle_copy_attribute (tree *node, tree name, tree args,
+ int flags, bool *no_add_attrs)
+{
+ /* Do not apply the copy attribute itself. It serves no purpose
+ other than to copy other attributes. */
+ *no_add_attrs = true;
+
+ tree decl = *node;
+
+ tree ref = TREE_VALUE (args);
+ if (ref == error_mark_node)
+ return NULL_TREE;
+
+ if (TREE_CODE (ref) == STRING_CST)
+ {
+ /* Explicitly handle this case since using a string literal
+ as an argument is a likely mistake. */
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE attribute argument cannot be a string",
+ name);
+ return NULL_TREE;
+ }
+
+ if (CONSTANT_CLASS_P (ref)
+ && (INTEGRAL_TYPE_P (TREE_TYPE (ref))
+ || FLOAT_TYPE_P (TREE_TYPE (ref))))
+ {
+ /* Similar to the string case, since some function attributes
+ accept literal numbers as arguments (e.g., alloc_size or
+ nonnull) using one here is a likely mistake. */
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE attribute argument cannot be a constant arithmetic "
+ "expression",
+ name);
+ return NULL_TREE;
+ }
+
+ if (ref == node[1])
+ {
+ /* Another possible mistake (but indirect self-references aren't
+ and diagnosed and shouldn't be). */
+ if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes,
+ "%qE attribute ignored on a redeclaration "
+ "of the referenced symbol",
+ name))
+ inform (DECL_SOURCE_LOCATION (node[1]),
+ "previous declaration here");
+ return NULL_TREE;
+ }
+
+ /* Consider address-of expressions in the attribute argument
+ as requests to copy from the referenced entity. */
+ if (TREE_CODE (ref) == ADDR_EXPR)
+ ref = TREE_OPERAND (ref, 0);
+
+ do
+ {
+ /* Drill down into references to find the referenced decl. */
+ tree_code refcode = TREE_CODE (ref);
+ if (refcode == ARRAY_REF
+ || refcode == INDIRECT_REF)
+ ref = TREE_OPERAND (ref, 0);
+ else if (refcode == COMPONENT_REF)
+ ref = TREE_OPERAND (ref, 1);
+ else
+ break;
+ } while (!DECL_P (ref));
+
+ /* For object pointer expressions, consider those to be requests
+ to copy from their type, such as in:
+ struct __attribute__ (copy ((struct T *)0)) U { ... };
+ which copies type attributes from struct T to the declaration
+ of struct U. */
+ if ((CONSTANT_CLASS_P (ref) || EXPR_P (ref))
+ && POINTER_TYPE_P (TREE_TYPE (ref))
+ && !FUNCTION_POINTER_TYPE_P (TREE_TYPE (ref)))
+ ref = TREE_TYPE (ref);
+
+ tree reftype = TYPE_P (ref) ? ref : TREE_TYPE (ref);
+
+ if (DECL_P (decl))
+ {
+ if ((VAR_P (decl)
+ && (TREE_CODE (ref) == FUNCTION_DECL
+ || (EXPR_P (ref)
+ && POINTER_TYPE_P (reftype)
+ && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (reftype)))))
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && (VAR_P (ref)
+ || (EXPR_P (ref)
+ && !FUNC_OR_METHOD_TYPE_P (reftype)
+ && (!POINTER_TYPE_P (reftype)
+ || !FUNC_OR_METHOD_TYPE_P (TREE_TYPE (reftype)))))))
+ {
+ /* It makes no sense to try to copy function attributes
+ to a variable, or variable attributes to a function. */
+ if (warning (OPT_Wattributes,
+ "%qE attribute ignored on a declaration of "
+ "a different kind than referenced symbol",
+ name)
+ && DECL_P (ref))
+ inform (DECL_SOURCE_LOCATION (ref),
+ "symbol %qD referenced by %qD declared here", ref, decl);
+ return NULL_TREE;
+ }
+
+ tree attrs = NULL_TREE;
+ if (DECL_P (ref))
+ attrs = DECL_ATTRIBUTES (ref);
+ else if (TYPE_P (ref))
+ attrs = TYPE_ATTRIBUTES (ref);
+
+ /* Copy decl attributes from REF to DECL. */
+ for (tree at = attrs; at; at = TREE_CHAIN (at))
+ {
+ /* Avoid copying attributes that affect a symbol linkage,
+ inlining, or visibility since those in all likelihood
+ only apply to the target.
+ FIXME: make it possible to specify which attributes to
+ copy or not to copy in the copy attribute itself. */
+ tree atname = get_attribute_name (at);
+ if (is_attribute_p ("alias", atname)
+ || is_attribute_p ("always_inline", atname)
+ || is_attribute_p ("gnu_inline", atname)
+ || is_attribute_p ("ifunc", atname)
+ || is_attribute_p ("noinline", atname)
+ || is_attribute_p ("visibility", atname)
+ || is_attribute_p ("weak", atname)
+ || is_attribute_p ("weakref", atname)
+ || is_attribute_p ("target_clones", atname))
+ continue;
+
+ /* Attribute leaf only applies to extern functions.
+ Avoid copying it to static ones. */
+ if (!TREE_PUBLIC (decl)
+ && is_attribute_p ("leaf", atname))
+ continue;
+
+ tree atargs = TREE_VALUE (at);
+ /* Create a copy of just the one attribute ar AT, including
+ its argumentsm and add it to DECL. */
+ tree attr = tree_cons (atname, copy_list (atargs), NULL_TREE);
+ decl_attributes (node, attr, flags, EXPR_P (ref) ? NULL_TREE : ref);
+ }
+
+ /* Proceed to copy type attributes below. */
+ }
+ else if (!TYPE_P (decl))
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE attribute must apply to a declaration",
+ name);
+ return NULL_TREE;
+ }
+
+ /* A function declared with attribute nothrow has the attribute
+ attached to it, but a C++ throw() function does not. */
+ if (TREE_NOTHROW (ref))
+ TREE_NOTHROW (decl) = true;
+
+ /* Similarly, a function declared with attribute noreturn has it
+ attached on to it, but a C11 _Noreturn function does not. */
+ if (DECL_P (ref)
+ && TREE_THIS_VOLATILE (ref)
+ && FUNC_OR_METHOD_TYPE_P (reftype))
+ TREE_THIS_VOLATILE (decl) = true;
+
+ if (POINTER_TYPE_P (reftype))
+ reftype = TREE_TYPE (reftype);
+
+ if (!TYPE_P (reftype))
+ return NULL_TREE;
+
+ tree attrs = TYPE_ATTRIBUTES (reftype);
+
+ /* Copy type attributes from REF to DECL. Pass in REF if it's a DECL
+ or a type but not if it's an expression. Set ATTR_FLAG_INTERNAL
+ since the attributes' arguments may be in their internal form. */
+ for (tree at = attrs; at; at = TREE_CHAIN (at))
+ decl_attributes (node, at, flags | ATTR_FLAG_INTERNAL,
+ EXPR_P (ref) ? NULL_TREE : ref);
+
+ return NULL_TREE;
+}
+
+/* Handle a "weakref" attribute; arguments as in struct
+ attribute_spec.handler. */
+
+static tree
+handle_weakref_attribute (tree *node, tree name, tree args,
+ int flags, bool *no_add_attrs)
+{
+ tree attr = NULL_TREE;
+
+ /* We must ignore the attribute when it is associated with
+ local-scoped decls, since attribute alias is ignored and many
+ such symbols do not even have a DECL_WEAK field. */
+ if (decl_function_context (*node)
+ || current_function_decl
+ || !VAR_OR_FUNCTION_DECL_P (*node))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (*node)))
+ {
+ error ("indirect function %q+D cannot be declared %qE",
+ *node, name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* The idea here is that `weakref("name")' mutates into `weakref,
+ alias("name")', and weakref without arguments, in turn,
+ implicitly adds weak. */
+
+ if (args)
+ {
+ attr = tree_cons (get_identifier ("alias"), args, attr);
+ attr = tree_cons (get_identifier ("weakref"), NULL_TREE, attr);
+
+ *no_add_attrs = true;
+
+ decl_attributes (node, attr, flags);
+ }
+ else
+ {
+ if (lookup_attribute ("alias", DECL_ATTRIBUTES (*node)))
+ error_at (DECL_SOURCE_LOCATION (*node),
+ "%qE attribute must appear before %qs attribute",
+ name, "alias");
+
+ /* Can't call declare_weak because it wants this to be TREE_PUBLIC,
+ and that isn't supported; and because it wants to add it to
+ the list of weak decls, which isn't helpful. */
+ DECL_WEAK (*node) = 1;
+ }
+
+ if (decl_in_symtab_p (*node))
+ {
+ struct symtab_node *n = symtab_node::get (*node);
+ if (n && n->refuse_visibility_changes)
+ error ("%+qD declared %qE after being used", *node, name);
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle an "visibility" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_visibility_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags),
+ bool *ARG_UNUSED (no_add_attrs))
+{
+ tree decl = *node;
+ tree id = TREE_VALUE (args);
+ enum symbol_visibility vis;
+
+ if (TYPE_P (*node))
+ {
+ if (TREE_CODE (*node) == ENUMERAL_TYPE)
+ /* OK */;
+ else if (!RECORD_OR_UNION_TYPE_P (*node))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored on non-class types",
+ name);
+ return NULL_TREE;
+ }
+ else if (TYPE_FIELDS (*node))
+ {
+ error ("%qE attribute ignored because %qT is already defined",
+ name, *node);
+ return NULL_TREE;
+ }
+ }
+ else if (decl_function_context (decl) != 0 || !TREE_PUBLIC (decl))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ return NULL_TREE;
+ }
+
+ if (TREE_CODE (id) != STRING_CST)
+ {
+ error ("visibility argument not a string");
+ return NULL_TREE;
+ }
+
+ /* If this is a type, set the visibility on the type decl. */
+ if (TYPE_P (decl))
+ {
+ decl = TYPE_NAME (decl);
+ if (!decl)
+ return NULL_TREE;
+ if (TREE_CODE (decl) == IDENTIFIER_NODE)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored on types",
+ name);
+ return NULL_TREE;
+ }
+ }
+
+ if (strcmp (TREE_STRING_POINTER (id), "default") == 0)
+ vis = VISIBILITY_DEFAULT;
+ else if (strcmp (TREE_STRING_POINTER (id), "internal") == 0)
+ vis = VISIBILITY_INTERNAL;
+ else if (strcmp (TREE_STRING_POINTER (id), "hidden") == 0)
+ vis = VISIBILITY_HIDDEN;
+ else if (strcmp (TREE_STRING_POINTER (id), "protected") == 0)
+ vis = VISIBILITY_PROTECTED;
+ else
+ {
+ error ("attribute %qE argument must be one of %qs, %qs, %qs, or %qs",
+ name, "default", "hidden", "protected", "internal");
+ vis = VISIBILITY_DEFAULT;
+ }
+
+ if (DECL_VISIBILITY_SPECIFIED (decl)
+ && vis != DECL_VISIBILITY (decl))
+ {
+ tree attributes = (TYPE_P (*node)
+ ? TYPE_ATTRIBUTES (*node)
+ : DECL_ATTRIBUTES (decl));
+ if (lookup_attribute ("visibility", attributes))
+ error ("%qD redeclared with different visibility", decl);
+ else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
+ && lookup_attribute ("dllimport", attributes))
+ error ("%qD was declared %qs which implies default visibility",
+ decl, "dllimport");
+ else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
+ && lookup_attribute ("dllexport", attributes))
+ error ("%qD was declared %qs which implies default visibility",
+ decl, "dllexport");
+ }
+
+ DECL_VISIBILITY (decl) = vis;
+ DECL_VISIBILITY_SPECIFIED (decl) = 1;
+
+ /* Go ahead and attach the attribute to the node as well. This is needed
+ so we can determine whether we have VISIBILITY_DEFAULT because the
+ visibility was not specified, or because it was explicitly overridden
+ from the containing scope. */
+
+ return NULL_TREE;
+}
+
+/* Handle an "tls_model" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_tls_model_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags),
+ bool *ARG_UNUSED (no_add_attrs))
+{
+ tree id;
+ tree decl = *node;
+ enum tls_model kind;
+
+ if (!VAR_P (decl))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored because %qD "
+ "is not a variable",
+ name, decl);
+ return NULL_TREE;
+ }
+
+ if (!DECL_THREAD_LOCAL_P (decl))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored because %qD does "
+ "not have thread storage duration", name, decl);
+ return NULL_TREE;
+ }
+
+ kind = DECL_TLS_MODEL (decl);
+ id = TREE_VALUE (args);
+ if (TREE_CODE (id) != STRING_CST)
+ {
+ error ("%qE argument not a string", name);
+ return NULL_TREE;
+ }
+
+ if (!strcmp (TREE_STRING_POINTER (id), "local-exec"))
+ kind = TLS_MODEL_LOCAL_EXEC;
+ else if (!strcmp (TREE_STRING_POINTER (id), "initial-exec"))
+ kind = TLS_MODEL_INITIAL_EXEC;
+ else if (!strcmp (TREE_STRING_POINTER (id), "local-dynamic"))
+ kind = optimize ? TLS_MODEL_LOCAL_DYNAMIC : TLS_MODEL_GLOBAL_DYNAMIC;
+ else if (!strcmp (TREE_STRING_POINTER (id), "global-dynamic"))
+ kind = TLS_MODEL_GLOBAL_DYNAMIC;
+ else
+ error ("%qE argument must be one of %qs, %qs, %qs, or %qs",
+ name,
+ "local-exec", "initial-exec", "local-dynamic", "global-dynamic");
+
+ set_decl_tls_model (decl, kind);
+ return NULL_TREE;
+}
+
+/* Handle a "no_instrument_function" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_instrument_function_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ tree decl = *node;
+
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE attribute applies only to functions", name);
+ *no_add_attrs = true;
+ }
+ else
+ DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (decl) = 1;
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_profile_instrument_function" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_profile_instrument_function_attribute (tree *node, tree name, tree,
+ int, bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* If ALLOC_DECL and DEALLOC_DECL are a pair of user-defined functions,
+ if they are declared inline issue warnings and return null. Otherwise
+ create attribute noinline, install it in ALLOC_DECL, and return it.
+ Otherwise return null. */
+
+static tree
+maybe_add_noinline (tree name, tree alloc_decl, tree dealloc_decl,
+ bool *no_add_attrs)
+{
+ if (fndecl_built_in_p (alloc_decl) || fndecl_built_in_p (dealloc_decl))
+ return NULL_TREE;
+
+ /* When inlining (or optimization) is enabled and the allocator and
+ deallocator are not built-in functions, ignore the attribute on
+ functions declared inline since it could lead to false positives
+ when inlining one or the other call would wind up calling
+ a mismatched allocator or deallocator. */
+ if ((optimize && DECL_DECLARED_INLINE_P (alloc_decl))
+ || lookup_attribute ("always_inline", DECL_ATTRIBUTES (alloc_decl)))
+ {
+ warning (OPT_Wattributes,
+ "%<%E (%E)%> attribute ignored on functions "
+ "declared %qs", name, DECL_NAME (dealloc_decl), "inline");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if ((optimize && DECL_DECLARED_INLINE_P (dealloc_decl))
+ || lookup_attribute ("always_inline", DECL_ATTRIBUTES (dealloc_decl)))
+ {
+ warning (OPT_Wattributes,
+ "%<%E (%E)%> attribute ignored with deallocation "
+ "functions declared %qs",
+ name, DECL_NAME (dealloc_decl), "inline");
+ inform (DECL_SOURCE_LOCATION (dealloc_decl),
+ "deallocation function declared here" );
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* Disable inlining for non-standard deallocators to avoid false
+ positives due to mismatches between the inlined implementation
+ of one and not the other pair of functions. */
+ tree attr = tree_cons (get_identifier ("noinline"), NULL_TREE, NULL_TREE);
+ decl_attributes (&alloc_decl, attr, 0);
+ return attr;
+}
+
+/* Handle the "malloc" attribute. */
+
+static tree
+handle_malloc_attribute (tree *node, tree name, tree args, int flags,
+ bool *no_add_attrs)
+{
+ if (flags & ATTR_FLAG_INTERNAL)
+ /* Recursive call. */
+ return NULL_TREE;
+
+ tree fndecl = *node;
+
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored; valid only "
+ "for functions",
+ name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ tree rettype = TREE_TYPE (TREE_TYPE (*node));
+ if (!POINTER_TYPE_P (rettype))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored on functions "
+ "returning %qT; valid only for pointer return types",
+ name, rettype);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (!args)
+ {
+ /* Only the form of the attribute with no arguments declares
+ a function malloc-like. */
+ DECL_IS_MALLOC (*node) = 1;
+ return NULL_TREE;
+ }
+
+ tree dealloc = TREE_VALUE (args);
+ if (error_operand_p (dealloc))
+ {
+ /* If the argument is in error it will have already been diagnosed.
+ Avoid issuing redundant errors here. */
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ STRIP_NOPS (dealloc);
+ if (TREE_CODE (dealloc) == ADDR_EXPR)
+ {
+ /* In C++ the argument may be wrapped in a cast to disambiguate
+ one of a number of overloads (such as operator delete). To
+ make things interesting, the cast looks different between
+ different C++ versions. Strip it and install the attribute
+ with the disambiguated function. */
+ dealloc = TREE_OPERAND (dealloc, 0);
+
+ *no_add_attrs = true;
+ tree attr = tree_cons (NULL_TREE, dealloc, TREE_CHAIN (args));
+ attr = build_tree_list (name, attr);
+ return decl_attributes (node, attr, 0);
+ }
+
+ if (TREE_CODE (dealloc) != FUNCTION_DECL)
+ {
+ if (TREE_CODE (dealloc) == OVERLOAD)
+ {
+ /* Handle specially the common case of specifying one of a number
+ of overloads, such as operator delete. */
+ error ("%qE attribute argument 1 is ambiguous", name);
+ inform (input_location,
+ "use a cast to the expected type to disambiguate");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ error ("%qE attribute argument 1 does not name a function", name);
+ if (DECL_P (dealloc))
+ inform (DECL_SOURCE_LOCATION (dealloc),
+ "argument references a symbol declared here");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* Mentioning the deallocation function qualifies as its use. */
+ TREE_USED (dealloc) = 1;
+
+ tree fntype = TREE_TYPE (dealloc);
+ tree argpos = TREE_CHAIN (args) ? TREE_VALUE (TREE_CHAIN (args)) : NULL_TREE;
+ if (!argpos)
+ {
+ tree argtypes = TYPE_ARG_TYPES (fntype);
+ if (!argtypes)
+ {
+ /* Reject functions without a prototype. */
+ error ("%qE attribute argument 1 must take a pointer "
+ "type as its first argument", name);
+ inform (DECL_SOURCE_LOCATION (dealloc),
+ "referenced symbol declared here");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ tree argtype = TREE_VALUE (argtypes);
+ if (TREE_CODE (argtype) != POINTER_TYPE)
+ {
+ /* Reject functions that don't take a pointer as their first
+ argument. */
+ error ("%qE attribute argument 1 must take a pointer type "
+ "as its first argument; have %qT", name, argtype);
+ inform (DECL_SOURCE_LOCATION (dealloc),
+ "referenced symbol declared here");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* Disable inlining for non-standard deallocators to avoid false
+ positives (or warn if either function is explicitly inline). */
+ tree at_noinline =
+ maybe_add_noinline (name, fndecl, dealloc, no_add_attrs);
+ if (*no_add_attrs)
+ return NULL_TREE;
+
+ /* Add attribute *dealloc to the deallocator function associating
+ it with this one. Ideally, the attribute would reference
+ the DECL of the deallocator but since that changes for each
+ redeclaration, use DECL_NAME instead. (DECL_ASSEMBLER_NAME
+ need not be set set this point and setting it here is too early. */
+ tree attrs = build_tree_list (NULL_TREE, DECL_NAME (fndecl));
+ attrs = tree_cons (get_identifier ("*dealloc"), attrs, at_noinline);
+ decl_attributes (&dealloc, attrs, 0);
+ return NULL_TREE;
+ }
+
+ /* Validate the positional argument. */
+ argpos = positional_argument (fntype, name, argpos, POINTER_TYPE);
+ if (!argpos)
+ {
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* As above, disable inlining for non-standard deallocators to avoid
+ false positives (or warn). */
+ tree at_noinline =
+ maybe_add_noinline (name, fndecl, dealloc, no_add_attrs);
+ if (*no_add_attrs)
+ return NULL_TREE;
+
+ /* It's valid to declare the same function with multiple instances
+ of attribute malloc, each naming the same or different deallocator
+ functions, and each referencing either the same or a different
+ positional argument. */
+ tree attrs = tree_cons (NULL_TREE, argpos, NULL_TREE);
+ attrs = tree_cons (NULL_TREE, DECL_NAME (fndecl), attrs);
+ attrs = tree_cons (get_identifier ("*dealloc"), attrs, at_noinline);
+ decl_attributes (&dealloc, attrs, 0);
+ return NULL_TREE;
+}
+
+/* Handle the internal "*dealloc" attribute added for functions declared
+ with the one- and two-argument forms of attribute malloc. Add it
+ to *NODE unless it's already there with the same arguments. */
+
+static tree
+handle_dealloc_attribute (tree *node, tree name, tree args, int,
+ bool *no_add_attrs)
+{
+ tree fndecl = *node;
+
+ tree attrs = DECL_ATTRIBUTES (fndecl);
+ if (!attrs)
+ return NULL_TREE;
+
+ tree arg = TREE_VALUE (args);
+ args = TREE_CHAIN (args);
+ tree arg_pos = args ? TREE_VALUE (args) : integer_zero_node;
+
+ gcc_checking_assert ((DECL_P (arg)
+ && fndecl_built_in_p (arg, BUILT_IN_NORMAL))
+ || TREE_CODE (arg) == IDENTIFIER_NODE);
+
+ const char* const namestr = IDENTIFIER_POINTER (name);
+ for (tree at = attrs; (at = lookup_attribute (namestr, at));
+ at = TREE_CHAIN (at))
+ {
+ tree alloc = TREE_VALUE (at);
+ if (!alloc)
+ continue;
+
+ tree pos = TREE_CHAIN (alloc);
+ alloc = TREE_VALUE (alloc);
+ pos = pos ? TREE_VALUE (pos) : integer_zero_node;
+ gcc_checking_assert ((DECL_P (alloc)
+ && fndecl_built_in_p (alloc, BUILT_IN_NORMAL))
+ || TREE_CODE (alloc) == IDENTIFIER_NODE);
+
+ if (alloc == arg && tree_int_cst_equal (pos, arg_pos))
+ {
+ /* The function already has the attribute either without any
+ arguments or with the same arguments as the attribute that's
+ being added. Return without adding another copy. */
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle the "alloc_size (argpos1 [, argpos2])" function type attribute.
+ *NODE is the type of the function the attribute is being applied to. */
+
+static tree
+handle_alloc_size_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree fntype = *node;
+ tree rettype = TREE_TYPE (fntype);
+ if (!POINTER_TYPE_P (rettype))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute ignored on a function returning %qT",
+ name, rettype);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ tree newargs[2] = { NULL_TREE, NULL_TREE };
+ for (int i = 1; args; ++i)
+ {
+ tree pos = TREE_VALUE (args);
+ /* NEXT is null when the attribute includes just one argument.
+ That's used to tell positional_argument to avoid mentioning
+ the argument number in diagnostics (since there's just one
+ mentioning it is unnecessary and coule be confusing). */
+ tree next = TREE_CHAIN (args);
+ if (tree val = positional_argument (fntype, name, pos, INTEGER_TYPE,
+ next || i > 1 ? i : 0))
+ {
+ TREE_VALUE (args) = val;
+ newargs[i - 1] = val;
+ }
+ else
+ {
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ args = next;
+ }
+
+ if (!validate_attr_args (node, name, newargs))
+ *no_add_attrs = true;
+
+ return NULL_TREE;
+}
+
+
+/* Handle an "alloc_align (argpos)" attribute. */
+
+static tree
+handle_alloc_align_attribute (tree *node, tree name, tree args, int,
+ bool *no_add_attrs)
+{
+ tree fntype = *node;
+ tree rettype = TREE_TYPE (fntype);
+ if (!POINTER_TYPE_P (rettype))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute ignored on a function returning %qT",
+ name, rettype);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (tree val = positional_argument (*node, name, TREE_VALUE (args),
+ INTEGER_TYPE))
+ if (validate_attr_arg (node, name, val))
+ return NULL_TREE;
+
+ *no_add_attrs = true;
+ return NULL_TREE;
+}
+
+/* Handle a "assume_aligned" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_assume_aligned_attribute (tree *node, tree name, tree args, int,
+ bool *no_add_attrs)
+{
+ tree decl = *node;
+ tree rettype = TREE_TYPE (decl);
+ if (TREE_CODE (rettype) != POINTER_TYPE)
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute ignored on a function returning %qT",
+ name, rettype);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* The alignment specified by the first argument. */
+ tree align = NULL_TREE;
+
+ for (; args; args = TREE_CHAIN (args))
+ {
+ tree val = TREE_VALUE (args);
+ if (val && TREE_CODE (val) != IDENTIFIER_NODE
+ && TREE_CODE (val) != FUNCTION_DECL)
+ val = default_conversion (val);
+
+ if (!tree_fits_shwi_p (val))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute argument %E is not an integer constant",
+ name, val);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ else if (tree_int_cst_sgn (val) < 0)
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute argument %E is not positive", name, val);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (!align)
+ {
+ /* Validate and save the alignment. */
+ if (!integer_pow2p (val))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute argument %E is not a power of 2",
+ name, val);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ align = val;
+ }
+ else if (tree_int_cst_le (align, val))
+ {
+ /* The misalignment specified by the second argument
+ must be non-negative and less than the alignment. */
+ warning (OPT_Wattributes,
+ "%qE attribute argument %E is not in the range [0, %wu]",
+ name, val, tree_to_uhwi (align) - 1);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ }
+ return NULL_TREE;
+}
+
+/* Handle the internal-only "arg spec" attribute. */
+
+static tree
+handle_argspec_attribute (tree *, tree, tree args, int, bool *)
+{
+ /* Verify the attribute has one or two arguments and their kind. */
+ gcc_assert (args && TREE_CODE (TREE_VALUE (args)) == STRING_CST);
+ for (tree next = TREE_CHAIN (args); next; next = TREE_CHAIN (next))
+ {
+ tree val = TREE_VALUE (next);
+ gcc_assert (DECL_P (val) || EXPR_P (val));
+ }
+ return NULL_TREE;
+}
+
+/* Handle the internal-only "fn spec" attribute. */
+
+static tree
+handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, tree ARG_UNUSED (name),
+ tree args, int ARG_UNUSED (flags),
+ bool *no_add_attrs ATTRIBUTE_UNUSED)
+{
+ gcc_assert (args
+ && TREE_CODE (TREE_VALUE (args)) == STRING_CST
+ && !TREE_CHAIN (args));
+ return NULL_TREE;
+}
+
+/* Handle a "warn_unused" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_warn_unused_attribute (tree *node, tree name,
+ tree args ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED, bool *no_add_attrs)
+{
+ if (TYPE_P (*node))
+ /* Do nothing else, just set the attribute. We'll get at
+ it later with lookup_attribute. */
+ ;
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle an "omp declare simd" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_omp_declare_simd_attribute (tree *, tree, tree, int, bool *)
+{
+ return NULL_TREE;
+}
+
+/* Handle an "omp declare variant {base,variant}" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_omp_declare_variant_attribute (tree *, tree, tree, int, bool *)
+{
+ return NULL_TREE;
+}
+
+/* Handle a "simd" attribute. */
+
+static tree
+handle_simd_attribute (tree *node, tree name, tree args, int, bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ {
+ tree t = get_identifier ("omp declare simd");
+ tree attr = NULL_TREE;
+ if (args)
+ {
+ tree id = TREE_VALUE (args);
+
+ if (TREE_CODE (id) != STRING_CST)
+ {
+ error ("attribute %qE argument not a string", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (strcmp (TREE_STRING_POINTER (id), "notinbranch") == 0)
+ attr = build_omp_clause (DECL_SOURCE_LOCATION (*node),
+ OMP_CLAUSE_NOTINBRANCH);
+ else if (strcmp (TREE_STRING_POINTER (id), "inbranch") == 0)
+ attr = build_omp_clause (DECL_SOURCE_LOCATION (*node),
+ OMP_CLAUSE_INBRANCH);
+ else
+ {
+ error ("only %<inbranch%> and %<notinbranch%> flags are "
+ "allowed for %<__simd__%> attribute");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ }
+
+ DECL_ATTRIBUTES (*node)
+ = tree_cons (t, build_tree_list (NULL_TREE, attr),
+ DECL_ATTRIBUTES (*node));
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle an "omp declare target" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_omp_declare_target_attribute (tree *, tree, tree, int, bool *)
+{
+ return NULL_TREE;
+}
+
+/* Handle an "non overlapping" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_non_overlapping_attribute (tree *, tree, tree, int, bool *)
+{
+ return NULL_TREE;
+}
+
+/* Handle a "returns_twice" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_returns_twice_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ DECL_IS_RETURNS_TWICE (*node) = 1;
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_limit_stack" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_limit_stack_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ tree decl = *node;
+
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE attribute applies only to functions", name);
+ *no_add_attrs = true;
+ }
+ else if (DECL_INITIAL (decl))
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "cannot set %qE attribute after definition", name);
+ *no_add_attrs = true;
+ }
+ else
+ DECL_NO_LIMIT_STACK (decl) = 1;
+
+ return NULL_TREE;
+}
+
+/* Handle a "pure" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_pure_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ {
+ tree type = TREE_TYPE (*node);
+ if (VOID_TYPE_P (TREE_TYPE (type)))
+ warning (OPT_Wattributes, "%qE attribute on function "
+ "returning %<void%>", name);
+
+ DECL_PURE_P (*node) = 1;
+ /* ??? TODO: Support types. */
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Digest an attribute list destined for a transactional memory statement.
+ ALLOWED is the set of attributes that are allowed for this statement;
+ return the attribute we parsed. Multiple attributes are never allowed. */
+
+int
+parse_tm_stmt_attr (tree attrs, int allowed)
+{
+ tree a_seen = NULL;
+ int m_seen = 0;
+
+ for ( ; attrs ; attrs = TREE_CHAIN (attrs))
+ {
+ tree a = get_attribute_name (attrs);
+ tree ns = get_attribute_namespace (attrs);
+ int m = 0;
+
+ if (is_attribute_p ("outer", a)
+ && (ns == NULL_TREE || strcmp (IDENTIFIER_POINTER (ns), "gnu") == 0))
+ m = TM_STMT_ATTR_OUTER;
+
+ if ((m & allowed) == 0)
+ {
+ warning (OPT_Wattributes, "%qE attribute directive ignored", a);
+ continue;
+ }
+
+ if (m_seen == 0)
+ {
+ a_seen = a;
+ m_seen = m;
+ }
+ else if (m_seen == m)
+ warning (OPT_Wattributes, "%qE attribute duplicated", a);
+ else
+ warning (OPT_Wattributes, "%qE attribute follows %qE", a, a_seen);
+ }
+
+ return m_seen;
+}
+
+/* Transform a TM attribute name into a maskable integer and back.
+ Note that NULL (i.e. no attribute) is mapped to UNKNOWN, corresponding
+ to how the lack of an attribute is treated. */
+
+int
+tm_attr_to_mask (tree attr)
+{
+ if (attr == NULL)
+ return 0;
+ if (is_attribute_p ("transaction_safe", attr))
+ return TM_ATTR_SAFE;
+ if (is_attribute_p ("transaction_callable", attr))
+ return TM_ATTR_CALLABLE;
+ if (is_attribute_p ("transaction_pure", attr))
+ return TM_ATTR_PURE;
+ if (is_attribute_p ("transaction_unsafe", attr))
+ return TM_ATTR_IRREVOCABLE;
+ if (is_attribute_p ("transaction_may_cancel_outer", attr))
+ return TM_ATTR_MAY_CANCEL_OUTER;
+ return 0;
+}
+
+tree
+tm_mask_to_attr (int mask)
+{
+ const char *str;
+ switch (mask)
+ {
+ case TM_ATTR_SAFE:
+ str = "transaction_safe";
+ break;
+ case TM_ATTR_CALLABLE:
+ str = "transaction_callable";
+ break;
+ case TM_ATTR_PURE:
+ str = "transaction_pure";
+ break;
+ case TM_ATTR_IRREVOCABLE:
+ str = "transaction_unsafe";
+ break;
+ case TM_ATTR_MAY_CANCEL_OUTER:
+ str = "transaction_may_cancel_outer";
+ break;
+ default:
+ gcc_unreachable ();
+ }
+ return get_identifier (str);
+}
+
+/* Return the first TM attribute seen in LIST. */
+
+tree
+find_tm_attribute (tree list)
+{
+ for (; list ; list = TREE_CHAIN (list))
+ {
+ tree name = get_attribute_name (list);
+ if (tm_attr_to_mask (name) != 0)
+ return name;
+ }
+ return NULL_TREE;
+}
+
+/* Handle the TM attributes; arguments as in struct attribute_spec.handler.
+ Here we accept only function types, and verify that none of the other
+ function TM attributes are also applied. */
+/* ??? We need to accept class types for C++, but not C. This greatly
+ complicates this function, since we can no longer rely on the extra
+ processing given by function_type_required. */
+
+static tree
+handle_tm_attribute (tree *node, tree name, tree args,
+ int flags, bool *no_add_attrs)
+{
+ /* Only one path adds the attribute; others don't. */
+ *no_add_attrs = true;
+
+ switch (TREE_CODE (*node))
+ {
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ /* Only tm_callable and tm_safe apply to classes. */
+ if (tm_attr_to_mask (name) & ~(TM_ATTR_SAFE | TM_ATTR_CALLABLE))
+ goto ignored;
+ /* FALLTHRU */
+
+ case FUNCTION_TYPE:
+ case METHOD_TYPE:
+ {
+ tree old_name = find_tm_attribute (TYPE_ATTRIBUTES (*node));
+ if (old_name == name)
+ ;
+ else if (old_name != NULL_TREE)
+ error ("type was previously declared %qE", old_name);
+ else
+ *no_add_attrs = false;
+ }
+ break;
+
+ case FUNCTION_DECL:
+ {
+ /* transaction_safe_dynamic goes on the FUNCTION_DECL, but we also
+ want to set transaction_safe on the type. */
+ gcc_assert (is_attribute_p ("transaction_safe_dynamic", name));
+ if (!TYPE_P (DECL_CONTEXT (*node)))
+ error_at (DECL_SOURCE_LOCATION (*node),
+ "%<transaction_safe_dynamic%> may only be specified for "
+ "a virtual function");
+ *no_add_attrs = false;
+ decl_attributes (&TREE_TYPE (*node),
+ build_tree_list (get_identifier ("transaction_safe"),
+ NULL_TREE),
+ 0);
+ break;
+ }
+
+ case POINTER_TYPE:
+ {
+ enum tree_code subcode = TREE_CODE (TREE_TYPE (*node));
+ if (subcode == FUNCTION_TYPE || subcode == METHOD_TYPE)
+ {
+ tree fn_tmp = TREE_TYPE (*node);
+ decl_attributes (&fn_tmp, tree_cons (name, args, NULL), 0);
+ *node = build_pointer_type (fn_tmp);
+ break;
+ }
+ }
+ /* FALLTHRU */
+
+ default:
+ /* If a function is next, pass it on to be tried next. */
+ if (flags & (int) ATTR_FLAG_FUNCTION_NEXT)
+ return tree_cons (name, args, NULL);
+
+ ignored:
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ break;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle the TM_WRAP attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_tm_wrap_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree decl = *node;
+
+ /* We don't need the attribute even on success, since we
+ record the entry in an external table. */
+ *no_add_attrs = true;
+
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ else
+ {
+ tree wrap_decl = TREE_VALUE (args);
+ if (error_operand_p (wrap_decl))
+ ;
+ else if (TREE_CODE (wrap_decl) != IDENTIFIER_NODE
+ && !VAR_OR_FUNCTION_DECL_P (wrap_decl))
+ error ("%qE argument not an identifier", name);
+ else
+ {
+ if (TREE_CODE (wrap_decl) == IDENTIFIER_NODE)
+ wrap_decl = lookup_name (wrap_decl);
+ if (wrap_decl && TREE_CODE (wrap_decl) == FUNCTION_DECL)
+ {
+ if (lang_hooks.types_compatible_p (TREE_TYPE (decl),
+ TREE_TYPE (wrap_decl)))
+ record_tm_replacement (wrap_decl, decl);
+ else
+ error ("%qD is not compatible with %qD", wrap_decl, decl);
+ }
+ else
+ error ("%qE argument is not a function", name);
+ }
+ }
+
+ return NULL_TREE;
+}
+
+/* Ignore the given attribute. Used when this attribute may be usefully
+ overridden by the target, but is not used generically. */
+
+static tree
+ignore_attribute (tree * ARG_UNUSED (node), tree ARG_UNUSED (name),
+ tree ARG_UNUSED (args), int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+ return NULL_TREE;
+}
+
+/* Handle a "no vops" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_novops_attribute (tree *node, tree ARG_UNUSED (name),
+ tree ARG_UNUSED (args), int ARG_UNUSED (flags),
+ bool *ARG_UNUSED (no_add_attrs))
+{
+ gcc_assert (TREE_CODE (*node) == FUNCTION_DECL);
+ DECL_IS_NOVOPS (*node) = 1;
+ return NULL_TREE;
+}
+
+/* Handle a "deprecated" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+tree
+handle_deprecated_attribute (tree *node, tree name,
+ tree args, int flags,
+ bool *no_add_attrs)
+{
+ tree type = NULL_TREE;
+ int warn = 0;
+ tree what = NULL_TREE;
+
+ if (!args)
+ *no_add_attrs = true;
+ else if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
+ {
+ error ("deprecated message is not a string");
+ *no_add_attrs = true;
+ }
+
+ if (DECL_P (*node))
+ {
+ tree decl = *node;
+ type = TREE_TYPE (decl);
+
+ if (TREE_CODE (decl) == TYPE_DECL
+ || TREE_CODE (decl) == PARM_DECL
+ || VAR_OR_FUNCTION_DECL_P (decl)
+ || TREE_CODE (decl) == FIELD_DECL
+ || TREE_CODE (decl) == CONST_DECL
+ || objc_method_decl (TREE_CODE (decl)))
+ TREE_DEPRECATED (decl) = 1;
+ else
+ warn = 1;
+ }
+ else if (TYPE_P (*node))
+ {
+ if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ *node = build_variant_type_copy (*node);
+ TREE_DEPRECATED (*node) = 1;
+ type = *node;
+ }
+ else
+ warn = 1;
+
+ if (warn)
+ {
+ *no_add_attrs = true;
+ if (type && TYPE_NAME (type))
+ {
+ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
+ what = TYPE_NAME (*node);
+ else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (type)))
+ what = DECL_NAME (TYPE_NAME (type));
+ }
+ if (what)
+ warning (OPT_Wattributes, "%qE attribute ignored for %qE", name, what);
+ else
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "unavailable" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_unavailable_attribute (tree *node, tree name,
+ tree args, int flags,
+ bool *no_add_attrs)
+{
+ tree type = NULL_TREE;
+ int warn = 0;
+ tree what = NULL_TREE;
+
+ if (!args)
+ *no_add_attrs = true;
+ else if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
+ {
+ error ("the message attached to %<unavailable%> is not a string");
+ *no_add_attrs = true;
+ }
+
+ if (DECL_P (*node))
+ {
+ tree decl = *node;
+ type = TREE_TYPE (decl);
+
+ if (TREE_CODE (decl) == TYPE_DECL
+ || TREE_CODE (decl) == PARM_DECL
+ || VAR_OR_FUNCTION_DECL_P (decl)
+ || TREE_CODE (decl) == FIELD_DECL
+ || TREE_CODE (decl) == CONST_DECL
+ || objc_method_decl (TREE_CODE (decl)))
+ TREE_UNAVAILABLE (decl) = 1;
+ else
+ warn = 1;
+ }
+ else if (TYPE_P (*node))
+ {
+ if (!(flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
+ *node = build_variant_type_copy (*node);
+ TREE_UNAVAILABLE (*node) = 1;
+ type = *node;
+ }
+ else
+ warn = 1;
+
+ if (warn)
+ {
+ *no_add_attrs = true;
+ if (type && TYPE_NAME (type))
+ {
+ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
+ what = TYPE_NAME (*node);
+ else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+ && DECL_NAME (TYPE_NAME (type)))
+ what = DECL_NAME (TYPE_NAME (type));
+ }
+ if (what)
+ warning (OPT_Wattributes, "%qE attribute ignored for %qE", name, what);
+ else
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ }
+
+ return NULL_TREE;
+}
+
+/* Return the "base" type from TYPE that is suitable to apply attribute
+ vector_size to by stripping arrays, function types, etc. */
+static tree
+type_for_vector_size (tree type)
+{
+ /* We need to provide for vector pointers, vector arrays, and
+ functions returning vectors. For example:
+
+ __attribute__((vector_size(16))) short *foo;
+
+ In this case, the mode is SI, but the type being modified is
+ HI, so we need to look further. */
+
+ while (POINTER_TYPE_P (type)
+ || TREE_CODE (type) == FUNCTION_TYPE
+ || TREE_CODE (type) == METHOD_TYPE
+ || TREE_CODE (type) == ARRAY_TYPE
+ || TREE_CODE (type) == OFFSET_TYPE)
+ type = TREE_TYPE (type);
+
+ return type;
+}
+
+/* Given TYPE, return the base type to which the vector_size attribute
+ ATNAME with ARGS, when non-null, can be applied, if one exists.
+ On success and when both ARGS and PTRNUNITS are non-null, set
+ *PTRNUNINTS to the number of vector units. When PTRNUNITS is not
+ null, issue a warning when the attribute argument is not constant
+ and an error if there is no such type. Otherwise issue a warning
+ in the latter case and return null. */
+
+static tree
+type_valid_for_vector_size (tree type, tree atname, tree args,
+ unsigned HOST_WIDE_INT *ptrnunits)
+{
+ bool error_p = ptrnunits != NULL;
+
+ /* Get the mode of the type being modified. */
+ machine_mode orig_mode = TYPE_MODE (type);
+
+ if ((!INTEGRAL_TYPE_P (type)
+ && !SCALAR_FLOAT_TYPE_P (type)
+ && !FIXED_POINT_TYPE_P (type))
+ || (!SCALAR_FLOAT_MODE_P (orig_mode)
+ && GET_MODE_CLASS (orig_mode) != MODE_INT
+ && !ALL_SCALAR_FIXED_POINT_MODE_P (orig_mode))
+ || !tree_fits_uhwi_p (TYPE_SIZE_UNIT (type))
+ || TREE_CODE (type) == BOOLEAN_TYPE)
+ {
+ if (error_p)
+ error ("invalid vector type for attribute %qE", atname);
+ else
+ warning (OPT_Wattributes, "invalid vector type for attribute %qE",
+ atname);
+ return NULL_TREE;
+ }
+
+ /* When no argument has been provided this is just a request to validate
+ the type above. Return TYPE to indicate success. */
+ if (!args)
+ return type;
+
+ tree size = TREE_VALUE (args);
+ /* Erroneous arguments have already been diagnosed. */
+ if (size == error_mark_node)
+ return NULL_TREE;
+
+ if (size && TREE_CODE (size) != IDENTIFIER_NODE
+ && TREE_CODE (size) != FUNCTION_DECL)
+ size = default_conversion (size);
+
+ if (TREE_CODE (size) != INTEGER_CST)
+ {
+ if (error_p)
+ error ("%qE attribute argument value %qE is not an integer constant",
+ atname, size);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument value %qE is not an integer constant",
+ atname, size);
+ return NULL_TREE;
+ }
+
+ if (!TYPE_UNSIGNED (TREE_TYPE (size))
+ && tree_int_cst_sgn (size) < 0)
+ {
+ if (error_p)
+ error ("%qE attribute argument value %qE is negative",
+ atname, size);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument value %qE is negative",
+ atname, size);
+ return NULL_TREE;
+ }
+
+ /* The attribute argument value is constrained by the maximum bit
+ alignment representable in unsigned int on the host. */
+ unsigned HOST_WIDE_INT vecsize;
+ unsigned HOST_WIDE_INT maxsize = tree_to_uhwi (max_object_size ());
+ if (!tree_fits_uhwi_p (size)
+ || (vecsize = tree_to_uhwi (size)) > maxsize)
+ {
+ if (error_p)
+ error ("%qE attribute argument value %qE exceeds %wu",
+ atname, size, maxsize);
+ else
+ warning (OPT_Wattributes,
+ "%qE attribute argument value %qE exceeds %wu",
+ atname, size, maxsize);
+ return NULL_TREE;
+ }
+
+ if (vecsize % tree_to_uhwi (TYPE_SIZE_UNIT (type)))
+ {
+ if (error_p)
+ error ("vector size not an integral multiple of component size");
+ return NULL_TREE;
+ }
+
+ if (vecsize == 0)
+ {
+ error ("zero vector size");
+ return NULL;
+ }
+
+ /* Calculate how many units fit in the vector. */
+ unsigned HOST_WIDE_INT nunits = vecsize / tree_to_uhwi (TYPE_SIZE_UNIT (type));
+ if (nunits & (nunits - 1))
+ {
+ if (error_p)
+ error ("number of vector components %wu not a power of two", nunits);
+ else
+ warning (OPT_Wattributes,
+ "number of vector components %wu not a power of two", nunits);
+ return NULL_TREE;
+ }
+
+ if (nunits >= (unsigned HOST_WIDE_INT)INT_MAX)
+ {
+ if (error_p)
+ error ("number of vector components %wu exceeds %d",
+ nunits, INT_MAX - 1);
+ else
+ warning (OPT_Wattributes,
+ "number of vector components %wu exceeds %d",
+ nunits, INT_MAX - 1);
+ return NULL_TREE;
+ }
+
+ if (ptrnunits)
+ *ptrnunits = nunits;
+
+ return type;
+}
+
+/* Handle a "vector_size" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_vector_size_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+
+ /* Determine the "base" type to apply the attribute to. */
+ tree type = type_for_vector_size (*node);
+
+ /* Get the vector size (in bytes) and let the function compute
+ the number of vector units. */
+ unsigned HOST_WIDE_INT nunits;
+ type = type_valid_for_vector_size (type, name, args, &nunits);
+ if (!type)
+ return NULL_TREE;
+
+ gcc_checking_assert (args != NULL);
+
+ tree new_type = build_vector_type (type, nunits);
+
+ /* Build back pointers if needed. */
+ *node = lang_hooks.types.reconstruct_complex_type (*node, new_type);
+
+ return NULL_TREE;
+}
+
+/* Handle the "nonnull" attribute. */
+
+static tree
+handle_nonnull_attribute (tree *node, tree name,
+ tree args, int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ tree type = *node;
+
+ /* If no arguments are specified, all pointer arguments should be
+ non-null. Verify a full prototype is given so that the arguments
+ will have the correct types when we actually check them later.
+ Avoid diagnosing type-generic built-ins since those have no
+ prototype. */
+ if (!args)
+ {
+ if (!prototype_p (type)
+ && (!TYPE_ATTRIBUTES (type)
+ || !lookup_attribute ("type generic", TYPE_ATTRIBUTES (type))))
+ {
+ error ("%qE attribute without arguments on a non-prototype",
+ name);
+ *no_add_attrs = true;
+ }
+ return NULL_TREE;
+ }
+
+ for (int i = 1; args; ++i)
+ {
+ tree pos = TREE_VALUE (args);
+ /* NEXT is null when the attribute includes just one argument.
+ That's used to tell positional_argument to avoid mentioning
+ the argument number in diagnostics (since there's just one
+ mentioning it is unnecessary and coule be confusing). */
+ tree next = TREE_CHAIN (args);
+ if (tree val = positional_argument (type, name, pos, POINTER_TYPE,
+ next || i > 1 ? i : 0))
+ TREE_VALUE (args) = val;
+ else
+ {
+ *no_add_attrs = true;
+ break;
+ }
+ args = next;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle the "nonstring" variable attribute. */
+
+static tree
+handle_nonstring_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ gcc_assert (!args);
+ tree_code code = TREE_CODE (*node);
+
+ if (VAR_P (*node)
+ || code == FIELD_DECL
+ || code == PARM_DECL)
+ {
+ tree type = TREE_TYPE (*node);
+
+ if (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* Accept the attribute on arrays and pointers to all three
+ narrow character types. */
+ tree eltype = TREE_TYPE (type);
+ eltype = TYPE_MAIN_VARIANT (eltype);
+ if (eltype == char_type_node
+ || eltype == signed_char_type_node
+ || eltype == unsigned_char_type_node)
+ return NULL_TREE;
+ }
+
+ warning (OPT_Wattributes,
+ "%qE attribute ignored on objects of type %qT",
+ name, type);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (code == FUNCTION_DECL)
+ warning (OPT_Wattributes,
+ "%qE attribute does not apply to functions", name);
+ else if (code == TYPE_DECL)
+ warning (OPT_Wattributes,
+ "%qE attribute does not apply to types", name);
+ else
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+
+ *no_add_attrs = true;
+ return NULL_TREE;
+}
+
+/* Given a function type FUNCTYPE, returns the type of the parameter
+ ARGNO or null if ARGNO exceeds the number of parameters. On failure
+ set *NARGS to the number of function parameters. */
+
+static tree
+get_argument_type (tree functype, unsigned argno, unsigned *nargs)
+{
+ function_args_iterator iter;
+ function_args_iter_init (&iter, functype);
+
+ unsigned count = 0;
+
+ for ( ; iter.next; ++count, function_args_iter_next (&iter))
+ {
+ if (count + 1 == argno)
+ {
+ tree argtype = function_args_iter_cond (&iter);
+ if (VOID_TYPE_P (argtype))
+ break;
+ if (argtype != error_mark_node)
+ return argtype;
+ }
+ }
+
+ *nargs = count;
+ return NULL_TREE;
+}
+
+/* Given a function FNDECL return the function argument at the zero-
+ based position ARGNO or null if it can't be found. */
+
+static tree
+get_argument (tree fndecl, unsigned argno)
+{
+ if (!DECL_P (fndecl))
+ return NULL_TREE;
+
+ unsigned i = 0;
+ for (tree arg = DECL_ARGUMENTS (fndecl); arg; arg = TREE_CHAIN (arg))
+ if (i++ == argno)
+ return arg;
+
+ return NULL_TREE;
+}
+
+/* Attempt to append attribute access specification ATTRSPEC, optionally
+ described by the human-readable string ATTRSTR, for type T, to one in
+ ATTRS. VBLIST is an optional list of bounds of variable length array
+ parameters described by ATTRSTR.
+ Issue warning for conflicts and return null if any are found.
+ Return the concatenated access string on success. */
+
+static tree
+append_access_attr (tree node[3], tree attrs, const char *attrstr,
+ const char *attrspec, tree vblist = NULL_TREE)
+{
+ tree argstr = build_string (strlen (attrspec) + 1, attrspec);
+ tree ataccess = tree_cons (NULL_TREE, argstr, vblist);
+ ataccess = tree_cons (get_identifier ("access"), ataccess, NULL_TREE);
+
+ /* The access specification being applied. This may be an implicit
+ access spec synthesized for array (or VLA) parameters even for
+ a declaration with an explicit access spec already applied, if
+ this call corresponds to the first declaration of the function. */
+ rdwr_map new_idxs;
+ init_attr_rdwr_indices (&new_idxs, ataccess);
+
+ /* The current access specification alrady applied. */
+ rdwr_map cur_idxs;
+ init_attr_rdwr_indices (&cur_idxs, attrs);
+
+ std::string spec;
+ for (auto it = new_idxs.begin (); it != new_idxs.end (); ++it)
+ {
+ const auto &newaxsref = *it;
+
+ /* The map has two equal entries for each pointer argument that
+ has an associated size argument. Process just the entry for
+ the former. */
+ if ((unsigned)newaxsref.first != newaxsref.second.ptrarg)
+ continue;
+
+ const attr_access* const cura = cur_idxs.get (newaxsref.first);
+ if (!cura)
+ {
+ /* The new attribute needs to be added. */
+ tree str = newaxsref.second.to_internal_string ();
+ spec += TREE_STRING_POINTER (str);
+ continue;
+ }
+
+ /* The new access spec refers to an array/pointer argument for
+ which an access spec already exists. Check and diagnose any
+ conflicts. If no conflicts are found, merge the two. */
+ const attr_access* const newa = &newaxsref.second;
+
+ if (!attrstr)
+ {
+ tree str = NULL_TREE;
+ if (newa->mode != access_deferred)
+ str = newa->to_external_string ();
+ else if (cura->mode != access_deferred)
+ str = cura->to_external_string ();
+ if (str)
+ attrstr = TREE_STRING_POINTER (str);
+ }
+
+ location_t curloc = input_location;
+ if (node[2] && DECL_P (node[2]))
+ curloc = DECL_SOURCE_LOCATION (node[2]);
+
+ location_t prevloc = UNKNOWN_LOCATION;
+ if (node[1] && DECL_P (node[1]))
+ prevloc = DECL_SOURCE_LOCATION (node[1]);
+
+ if (newa->mode != cura->mode
+ && newa->mode != access_deferred
+ && cura->mode != access_deferred
+ && newa->internal_p == cura->internal_p)
+ {
+ /* Mismatch in access mode. */
+ auto_diagnostic_group d;
+ if (warning_at (curloc, OPT_Wattributes,
+ "attribute %qs mismatch with mode %qs",
+ attrstr, cura->mode_names[cura->mode])
+ && prevloc != UNKNOWN_LOCATION)
+ inform (prevloc, "previous declaration here");
+ continue;
+ }
+
+ /* Set if PTRARG refers to a VLA with an unspecified bound (T[*]).
+ Be prepared for either CURA or NEWA to refer to it, depending
+ on which happens to come first in the declaration. */
+ const bool cur_vla_ub = (cura->internal_p
+ && cura->sizarg == UINT_MAX
+ && cura->minsize == HOST_WIDE_INT_M1U);
+ const bool new_vla_ub = (newa->internal_p
+ && newa->sizarg == UINT_MAX
+ && newa->minsize == HOST_WIDE_INT_M1U);
+
+ if (newa->sizarg != cura->sizarg
+ && attrstr
+ && (!(cur_vla_ub ^ new_vla_ub)
+ || (!cura->internal_p && !newa->internal_p)))
+ {
+ /* Avoid diagnosing redeclarations of functions with no explicit
+ attribute access that add one. */
+ if (newa->mode == access_deferred
+ && cura->mode != access_deferred
+ && newa->sizarg == UINT_MAX
+ && cura->sizarg != UINT_MAX)
+ continue;
+
+ if (cura->mode == access_deferred
+ && newa->mode != access_deferred
+ && cura->sizarg == UINT_MAX
+ && newa->sizarg != UINT_MAX)
+ continue;
+
+ /* The two specs designate different size arguments. It's okay
+ for the explicit spec to specify a size where none is provided
+ by the implicit (VLA) one, as in:
+ __attribute__ ((access (read_write, 1, 2)))
+ void f (int*, int);
+ but not for two explicit access attributes to do that. */
+ bool warned = false;
+
+ auto_diagnostic_group d;
+
+ if (newa->sizarg == UINT_MAX)
+ /* Mismatch in the presence of the size argument. */
+ warned = warning_at (curloc, OPT_Wattributes,
+ "attribute %qs missing positional argument 2 "
+ "provided in previous designation by argument "
+ "%u", attrstr, cura->sizarg + 1);
+ else if (cura->sizarg == UINT_MAX)
+ /* Mismatch in the presence of the size argument. */
+ warned = warning_at (curloc, OPT_Wattributes,
+ "attribute %qs positional argument 2 "
+ "missing in previous designation",
+ attrstr);
+ else if (newa->internal_p || cura->internal_p)
+ /* Mismatch in the value of the size argument and a VLA bound. */
+ warned = warning_at (curloc, OPT_Wattributes,
+ "attribute %qs positional argument 2 "
+ "conflicts with previous designation "
+ "by argument %u",
+ attrstr, cura->sizarg + 1);
+ else
+ /* Mismatch in the value of the size argument between two
+ explicit access attributes. */
+ warned = warning_at (curloc, OPT_Wattributes,
+ "attribute %qs mismatched positional argument "
+ "values %i and %i",
+ attrstr, newa->sizarg + 1, cura->sizarg + 1);
+
+ if (warned)
+ {
+ /* If the previous declaration is a function (as opposed
+ to a typedef of one), find the location of the array
+ or pointer argument that uses the conflicting VLA bound
+ and point to it in the note. */
+ const attr_access* const pa = cura->size ? cura : newa;
+ tree size = pa->size ? TREE_VALUE (pa->size) : NULL_TREE;
+ if (size && DECL_P (size))
+ {
+ location_t argloc = UNKNOWN_LOCATION;
+ if (tree arg = get_argument (node[2], pa->ptrarg))
+ argloc = DECL_SOURCE_LOCATION (arg);
+
+ gcc_rich_location richloc (DECL_SOURCE_LOCATION (size));
+ if (argloc != UNKNOWN_LOCATION)
+ richloc.add_range (argloc);
+
+ inform (&richloc, "designating the bound of variable "
+ "length array argument %u",
+ pa->ptrarg + 1);
+ }
+ else if (prevloc != UNKNOWN_LOCATION)
+ inform (prevloc, "previous declaration here");
+ }
+
+ continue;
+ }
+
+ if (newa->internal_p == cura->internal_p)
+ continue;
+
+ /* Merge the CURA and NEWA. */
+ attr_access merged = newaxsref.second;
+
+ /* VLA seen in a declaration takes precedence. */
+ if (cura->minsize == HOST_WIDE_INT_M1U)
+ merged.minsize = HOST_WIDE_INT_M1U;
+
+ /* Use the explicitly specified size positional argument. */
+ if (cura->sizarg != UINT_MAX)
+ merged.sizarg = cura->sizarg;
+
+ /* Use the explicitly specified mode. */
+ if (merged.mode == access_deferred)
+ merged.mode = cura->mode;
+
+ tree str = merged.to_internal_string ();
+ spec += TREE_STRING_POINTER (str);
+ }
+
+ if (!spec.length ())
+ return NULL_TREE;
+
+ return build_string (spec.length (), spec.c_str ());
+}
+
+/* Convenience wrapper for the above. */
+
+tree
+append_access_attr (tree node[3], tree attrs, const char *attrstr,
+ char code, HOST_WIDE_INT idxs[2])
+{
+ char attrspec[80];
+ int n = sprintf (attrspec, "%c%u", code, (unsigned) idxs[0] - 1);
+ if (idxs[1])
+ n += sprintf (attrspec + n, ",%u", (unsigned) idxs[1] - 1);
+
+ return append_access_attr (node, attrs, attrstr, attrspec);
+}
+
+/* Handle the access attribute for function type NODE[0], with the function
+ DECL optionally in NODE[1]. The handler is called both in response to
+ an explict attribute access on a declaration with a mode and one or two
+ positional arguments, and for internally synthesized access specifications
+ with a string argument optionally followd by a DECL or expression
+ representing a VLA bound. To speed up parsing, the handler transforms
+ the attribute and its arguments into a string. */
+
+static tree
+handle_access_attribute (tree node[3], tree name, tree args, int flags,
+ bool *no_add_attrs)
+{
+ tree attrs = TYPE_ATTRIBUTES (*node);
+ tree type = *node;
+ if (POINTER_TYPE_P (type))
+ {
+ tree ptype = TREE_TYPE (type);
+ if (FUNC_OR_METHOD_TYPE_P (ptype))
+ type = ptype;
+ }
+
+ *no_add_attrs = true;
+
+ /* Verify a full prototype is provided so that the argument types
+ can be validated. Avoid diagnosing type-generic built-ins since
+ those have no prototype. */
+ if (!args
+ && !prototype_p (type)
+ && (!attrs || !lookup_attribute ("type generic", attrs)))
+ {
+ error ("attribute %qE without arguments on a non-prototype", name);
+ return NULL_TREE;
+ }
+
+ tree access_mode = TREE_VALUE (args);
+ if (TREE_CODE (access_mode) == STRING_CST)
+ {
+ const char* const str = TREE_STRING_POINTER (access_mode);
+ if (*str == '+')
+ {
+ /* This is a request to merge an internal specification for
+ a function declaration involving arrays but no explicit
+ attribute access. */
+ tree vblist = TREE_CHAIN (args);
+ tree axstr = append_access_attr (node, attrs, NULL, str + 1,
+ vblist);
+ if (!axstr)
+ return NULL_TREE;
+
+ /* Replace any existing access attribute specification with
+ the concatenation above. */
+ tree axsat = tree_cons (NULL_TREE, axstr, vblist);
+ axsat = tree_cons (name, axsat, NULL_TREE);
+
+ /* Recursively call self to "replace" the documented/external
+ form of the attribute with the condensend internal form. */
+ decl_attributes (node, axsat, flags | ATTR_FLAG_INTERNAL);
+ return NULL_TREE;
+ }
+
+ if (flags & ATTR_FLAG_INTERNAL)
+ {
+ /* This is a recursive call to handle the condensed internal
+ form of the attribute (see below). Since all validation
+ has been done simply return here, accepting the attribute
+ as is. */
+ *no_add_attrs = false;
+ return NULL_TREE;
+ }
+ }
+
+ /* Set to true when the access mode has the form of a function call
+ as in 'attribute (read_only (1, 2))'. That's an easy mistake to
+ make and so worth a special diagnostic. */
+ bool funcall = false;
+ if (TREE_CODE (access_mode) == CALL_EXPR)
+ {
+ access_mode = CALL_EXPR_FN (access_mode);
+ if (TREE_CODE (access_mode) != ADDR_EXPR)
+ {
+ error ("attribute %qE invalid mode", name);
+ return NULL_TREE;
+ }
+ access_mode = TREE_OPERAND (access_mode, 0);
+ access_mode = DECL_NAME (access_mode);
+ funcall = true;
+ }
+ else if (TREE_CODE (access_mode) != IDENTIFIER_NODE)
+ {
+ error ("attribute %qE mode %qE is not an identifier; expected one of "
+ "%qs, %qs, %qs, or %qs", name, access_mode,
+ "read_only", "read_write", "write_only", "none");
+ return NULL_TREE;
+ }
+
+ const char* const access_str = IDENTIFIER_POINTER (access_mode);
+ const char *ps = access_str;
+ if (ps[0] == '_' && ps[1] == '_')
+ {
+ size_t len = strlen (ps);
+ if (ps[len - 1] == '_' && ps[len - 2] == '_')
+ ps += 2;
+ }
+
+ int imode;
+
+ {
+ const int nmodes =
+ sizeof attr_access::mode_names / sizeof *attr_access::mode_names;
+
+ for (imode = 0; imode != nmodes; ++imode)
+ if (!strncmp (ps, attr_access::mode_names[imode],
+ strlen (attr_access::mode_names[imode])))
+ break;
+
+ if (imode == nmodes)
+ {
+ error ("attribute %qE invalid mode %qs; expected one of "
+ "%qs, %qs, %qs, or %qs", name, access_str,
+ "read_only", "read_write", "write_only", "none");
+ return NULL_TREE;
+ }
+ }
+
+ const ::access_mode mode = static_cast<::access_mode>(imode);
+
+ if (funcall)
+ {
+ error ("attribute %qE unexpected %<(%> after mode %qs; expected "
+ "a positional argument or %<)%>",
+ name, access_str);
+ return NULL_TREE;
+ }
+
+ args = TREE_CHAIN (args);
+ if (!args)
+ {
+ /* The first positional argument is required. It may be worth
+ dropping the requirement at some point and having read_only
+ apply to all const-qualified pointers and read_write or
+ write_only to the rest. */
+ error ("attribute %<%E(%s)%> missing an argument",
+ name, access_str);
+ return NULL_TREE;
+ }
+
+ /* One or more positional arguments have been specified. Validate
+ them. */
+ tree idxnodes[2] = { NULL_TREE, NULL_TREE };
+ tree argtypes[2] = { NULL_TREE, NULL_TREE };
+ /* 1-based attribute positional arguments or zero if not specified.
+ Invalid negative or excessive values are also stored but used
+ only in diagnostics. */
+ HOST_WIDE_INT idxs[2] = { 0, 0 };
+
+ /* Number of function formal arguments (used in diagnostics). */
+ unsigned nfuncargs = 0;
+ /* Number of (optional) attribute positional arguments. */
+ unsigned nattrargs = 0;
+
+ for (unsigned i = 0; i != 2; ++i, args = TREE_CHAIN (args), ++nattrargs)
+ {
+ if (!args)
+ break;
+
+ idxnodes[i] = TREE_VALUE (args);
+
+ if (TREE_CODE (idxnodes[i]) != IDENTIFIER_NODE
+ && TREE_CODE (idxnodes[i]) != FUNCTION_DECL)
+ idxnodes[i] = default_conversion (idxnodes[i]);
+
+ if (tree_fits_shwi_p (idxnodes[i]))
+ {
+ idxs[i] = tree_to_shwi (idxnodes[i]);
+ argtypes[i] = get_argument_type (type, idxs[i], &nfuncargs);
+ }
+ }
+
+ if ((nattrargs == 1 && !idxs[0])
+ || (nattrargs == 2 && (!idxs[0] || !idxs[1])))
+ {
+ if (idxnodes[1])
+ error ("attribute %<%E(%s, %E, %E)%> invalid positional argument %i",
+ name, access_str, idxnodes[0], idxnodes[1], idxs[0] ? 2 : 1);
+ else
+ error ("attribute %<%E(%s, %E)%> invalid positional argument %i",
+ name, access_str, idxnodes[0], idxs[0] ? 2 : 1);
+ return NULL_TREE;
+ }
+
+ /* Format the attribute specification to include in diagnostics. */
+ char attrstr[80];
+ if (idxnodes[1])
+ snprintf (attrstr, sizeof attrstr, "%s(%s, %lli, %lli)",
+ IDENTIFIER_POINTER (name), access_str,
+ (long long) idxs[0], (long long) idxs[1]);
+ else if (idxnodes[0])
+ snprintf (attrstr, sizeof attrstr, "%s(%s, %lli)",
+ IDENTIFIER_POINTER (name), access_str,
+ (long long) idxs[0]);
+ else
+ snprintf (attrstr, sizeof attrstr, "%s(%s)",
+ IDENTIFIER_POINTER (name), access_str);
+
+ /* Verify the positional argument values are in range. */
+ if (!argtypes[0] || (idxnodes[1] && !argtypes[1]))
+ {
+ if (idxnodes[0])
+ {
+ if (idxs[0] < 0 || idxs[1] < 0)
+ error ("attribute %qs positional argument %i invalid value %wi",
+ attrstr, idxs[0] < 0 ? 1 : 2,
+ idxs[0] < 0 ? idxs[0] : idxs[1]);
+ else
+ error ("attribute %qs positional argument %i value %wi exceeds "
+ "number of function arguments %u",
+ attrstr, idxs[0] ? 1 : 2,
+ idxs[0] ? idxs[0] : idxs[1],
+ nfuncargs);
+ }
+ else
+ error ("attribute %qs invalid positional argument", attrstr);
+
+ return NULL_TREE;
+ }
+
+ if (!POINTER_TYPE_P (argtypes[0]))
+ {
+ /* The first argument must have a pointer or reference type. */
+ error ("attribute %qs positional argument 1 references "
+ "non-pointer argument type %qT",
+ attrstr, argtypes[0]);
+ return NULL_TREE;
+ }
+
+ {
+ /* Pointers to functions are not allowed. */
+ tree ptrtype = TREE_TYPE (argtypes[0]);
+ if (FUNC_OR_METHOD_TYPE_P (ptrtype))
+ {
+ error ("attribute %qs positional argument 1 references "
+ "argument of function type %qT",
+ attrstr, ptrtype);
+ return NULL_TREE;
+ }
+ }
+
+ if (mode == access_read_write || mode == access_write_only)
+ {
+ /* Read_write and write_only modes must reference non-const
+ arguments. */
+ if (TYPE_READONLY (TREE_TYPE (argtypes[0])))
+ {
+ error ("attribute %qs positional argument 1 references "
+ "%qs-qualified argument type %qT",
+ attrstr, "const", argtypes[0]);
+ return NULL_TREE;
+ }
+ }
+ else if (!TYPE_READONLY (TREE_TYPE (argtypes[0])))
+ {
+ /* A read_only mode should ideally reference const-qualified
+ arguments but it's not diagnosed error if one doesn't.
+ This makes it possible to annotate legacy, const-incorrect
+ APIs. It might be worth a diagnostic along the lines of
+ -Wsuggest-const. */
+ ;
+ }
+
+ if (argtypes[1] && !INTEGRAL_TYPE_P (argtypes[1]))
+ {
+ error ("attribute %qs positional argument 2 references "
+ "non-integer argument type %qT",
+ attrstr, argtypes[1]);
+ return NULL_TREE;
+ }
+
+ /* Verify that the new attribute doesn't conflict with any existing
+ attributes specified on previous declarations of the same type
+ and if not, concatenate the two. */
+ const char code = attr_access::mode_chars[mode];
+ tree new_attrs = append_access_attr (node, attrs, attrstr, code, idxs);
+ if (!new_attrs)
+ return NULL_TREE;
+
+ /* Replace any existing access attribute specification with
+ the concatenation above. */
+ new_attrs = tree_cons (NULL_TREE, new_attrs, NULL_TREE);
+ new_attrs = tree_cons (name, new_attrs, NULL_TREE);
+
+ if (node[1])
+ {
+ /* Repeat for the previously declared type. */
+ attrs = TYPE_ATTRIBUTES (TREE_TYPE (node[1]));
+ new_attrs = append_access_attr (node, attrs, attrstr, code, idxs);
+ if (!new_attrs)
+ return NULL_TREE;
+
+ new_attrs = tree_cons (NULL_TREE, new_attrs, NULL_TREE);
+ new_attrs = tree_cons (name, new_attrs, NULL_TREE);
+ }
+
+ /* Recursively call self to "replace" the documented/external form
+ of the attribute with the condensed internal form. */
+ decl_attributes (node, new_attrs, flags | ATTR_FLAG_INTERNAL);
+ return NULL_TREE;
+}
+
+/* Extract attribute "arg spec" from each FNDECL argument that has it,
+ build a single attribute access corresponding to all the arguments,
+ and return the result. SKIP_VOIDPTR set to ignore void* parameters
+ (used for user-defined functions for which, unlike in for built-ins,
+ void* cannot be relied on to determine anything about the access
+ through it or whether it even takes place).
+
+ For example, the parameters in the declaration:
+
+ void f (int x, int y, char [x][1][y][3], char [y][2][y][5]);
+
+ result in the following attribute access:
+
+ value: "+^2[*],$0$1^3[*],$1$1"
+ list: < <0, x> <1, y> >
+
+ where the list has a single value which itself is is a list each
+ of whose <node>s corresponds to one VLA bound for each of the two
+ parameters. */
+
+tree
+build_attr_access_from_parms (tree parms, bool skip_voidptr)
+{
+ /* Maps each named integral argument DECL seen so far to its position
+ in the argument list; used to associate VLA sizes with arguments. */
+ hash_map<tree, unsigned> arg2pos;
+
+ /* The string representation of the access specification for all
+ arguments. */
+ std::string spec;
+ unsigned argpos = 0;
+
+ /* A TREE_LIST of VLA bounds. */
+ tree vblist = NULL_TREE;
+
+ for (tree arg = parms; arg; arg = TREE_CHAIN (arg), ++argpos)
+ {
+ if (!DECL_P (arg))
+ continue;
+
+ tree argtype = TREE_TYPE (arg);
+ if (DECL_NAME (arg) && INTEGRAL_TYPE_P (argtype))
+ arg2pos.put (arg, argpos);
+
+ tree argspec = DECL_ATTRIBUTES (arg);
+ if (!argspec)
+ continue;
+
+ if (POINTER_TYPE_P (argtype))
+ {
+ /* void* arguments in user-defined functions could point to
+ anything; skip them. */
+ tree reftype = TREE_TYPE (argtype);
+ if (skip_voidptr && VOID_TYPE_P (reftype))
+ continue;
+ }
+
+ /* Each parameter should have at most one "arg spec" attribute. */
+ argspec = lookup_attribute ("arg spec", argspec);
+ if (!argspec)
+ continue;
+
+ /* Attribute arg spec should have one or two arguments. */
+ argspec = TREE_VALUE (argspec);
+
+ /* The attribute arg spec string. */
+ tree str = TREE_VALUE (argspec);
+ const char *s = TREE_STRING_POINTER (str);
+
+ /* Create the attribute access string from the arg spec string,
+ optionally followed by position of the VLA bound argument if
+ it is one. */
+ {
+ size_t specend = spec.length ();
+ if (!specend)
+ {
+ spec = '+';
+ specend = 1;
+ }
+
+ /* Format the access string in place. */
+ int len = snprintf (NULL, 0, "%c%u%s",
+ attr_access::mode_chars[access_deferred],
+ argpos, s);
+ spec.resize (specend + len + 1);
+ sprintf (&spec[specend], "%c%u%s",
+ attr_access::mode_chars[access_deferred],
+ argpos, s);
+ /* Trim the trailing NUL. */
+ spec.resize (specend + len);
+ }
+
+ /* The (optional) list of expressions denoting the VLA bounds
+ N in ARGTYPE <arg>[Ni]...[Nj]...[Nk]. */
+ tree argvbs = TREE_CHAIN (argspec);
+ if (argvbs)
+ {
+ spec += ',';
+ /* Add ARGVBS to the list. Their presence is indicated by
+ appending a comma followed by the dollar sign and, when
+ it corresponds to a function parameter, the position of
+ each bound Ni, so it can be distinguished from
+ an unspecified bound (as in T[*]). The list is in reverse
+ order of arguments and needs to be reversed to access in
+ order. */
+ vblist = tree_cons (NULL_TREE, argvbs, vblist);
+
+ unsigned nelts = 0;
+ for (tree vb = argvbs; vb; vb = TREE_CHAIN (vb), ++nelts)
+ {
+ tree bound = TREE_VALUE (vb);
+ if (const unsigned *psizpos = arg2pos.get (bound))
+ {
+ /* BOUND previously seen in the parameter list. */
+ TREE_PURPOSE (vb) = size_int (*psizpos);
+ /* Format the position string in place. */
+ int len = snprintf (NULL, 0, "$%u", *psizpos);
+ size_t specend = spec.length ();
+ spec.resize (specend + len + 1);
+ sprintf (&spec[specend], "$%u", *psizpos);
+ /* Trim the trailing NUL. */
+ spec.resize (specend + len);
+ }
+ else
+ {
+ /* BOUND doesn't name a parameter (it could be a global
+ variable or an expression such as a function call). */
+ spec += '$';
+ }
+ }
+ }
+ }
+
+ if (!spec.length ())
+ return NULL_TREE;
+
+ /* Attribute access takes a two or three arguments. Wrap VBLIST in
+ another list in case it has more nodes than would otherwise fit. */
+ vblist = build_tree_list (NULL_TREE, vblist);
+
+ /* Build a single attribute access with the string describing all
+ array arguments and an optional list of any non-parameter VLA
+ bounds in order. */
+ tree str = build_string (spec.length (), spec.c_str ());
+ tree attrargs = tree_cons (NULL_TREE, str, vblist);
+ tree name = get_identifier ("access");
+ return build_tree_list (name, attrargs);
+}
+
+/* Handle a "nothrow" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_nothrow_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ TREE_NOTHROW (*node) = 1;
+ /* ??? TODO: Support types. */
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "cleanup" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_cleanup_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ tree decl = *node;
+ tree cleanup_id, cleanup_decl;
+
+ /* ??? Could perhaps support cleanups on TREE_STATIC, much like we do
+ for global destructors in C++. This requires infrastructure that
+ we don't have generically at the moment. It's also not a feature
+ we'd be missing too much, since we do have attribute constructor. */
+ if (!VAR_P (decl) || TREE_STATIC (decl))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* Verify that the argument is a function in scope. */
+ /* ??? We could support pointers to functions here as well, if
+ that was considered desirable. */
+ cleanup_id = TREE_VALUE (args);
+ if (TREE_CODE (cleanup_id) != IDENTIFIER_NODE)
+ {
+ error ("cleanup argument not an identifier");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ cleanup_decl = lookup_name (cleanup_id);
+ if (!cleanup_decl || TREE_CODE (cleanup_decl) != FUNCTION_DECL)
+ {
+ error ("cleanup argument not a function");
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ /* That the function has proper type is checked with the
+ eventual call to build_function_call. */
+
+ return NULL_TREE;
+}
+
+/* Handle a "warn_unused_result" attribute. No special handling. */
+
+static tree
+handle_warn_unused_result_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ /* Ignore the attribute for functions not returning any value. */
+ if (VOID_TYPE_P (TREE_TYPE (*node)))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "sentinel" attribute. */
+
+static tree
+handle_sentinel_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ if (!prototype_p (*node))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute requires prototypes with named arguments", name);
+ *no_add_attrs = true;
+ }
+ else
+ {
+ if (!stdarg_p (*node))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute only applies to variadic functions", name);
+ *no_add_attrs = true;
+ }
+ }
+
+ if (args)
+ {
+ tree position = TREE_VALUE (args);
+ if (position && TREE_CODE (position) != IDENTIFIER_NODE
+ && TREE_CODE (position) != FUNCTION_DECL)
+ position = default_conversion (position);
+
+ if (TREE_CODE (position) != INTEGER_CST
+ || !INTEGRAL_TYPE_P (TREE_TYPE (position)))
+ {
+ warning (OPT_Wattributes,
+ "requested position is not an integer constant");
+ *no_add_attrs = true;
+ }
+ else
+ {
+ if (tree_int_cst_lt (position, integer_zero_node))
+ {
+ warning (OPT_Wattributes,
+ "requested position is less than zero");
+ *no_add_attrs = true;
+ }
+ }
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "type_generic" attribute. */
+
+static 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))
+{
+ /* Ensure we have a function type. */
+ gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
+
+ /* Ensure we have a variadic function. */
+ gcc_assert (!prototype_p (*node) || stdarg_p (*node));
+
+ return NULL_TREE;
+}
+
+/* Handle a "target" attribute. */
+
+static tree
+handle_target_attribute (tree *node, tree name, tree args, int flags,
+ bool *no_add_attrs)
+{
+ /* Ensure we have a function type. */
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+ else if (lookup_attribute ("target_clones", DECL_ATTRIBUTES (*node)))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+ "with %qs attribute", name, "target_clones");
+ *no_add_attrs = true;
+ }
+ else if (! targetm.target_option.valid_attribute_p (*node, name, args,
+ flags))
+ *no_add_attrs = true;
+
+ /* Check that there's no empty string in values of the attribute. */
+ for (tree t = args; t != NULL_TREE; t = TREE_CHAIN (t))
+ {
+ tree value = TREE_VALUE (t);
+ if (TREE_CODE (value) == STRING_CST
+ && TREE_STRING_LENGTH (value) == 1
+ && TREE_STRING_POINTER (value)[0] == '\0')
+ {
+ warning (OPT_Wattributes, "empty string in attribute %<target%>");
+ *no_add_attrs = true;
+ }
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "target_clones" attribute. */
+
+static tree
+handle_target_clones_attribute (tree *node, tree name, tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ /* Ensure we have a function type. */
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ {
+ if (TREE_CODE (TREE_VALUE (args)) != STRING_CST)
+ {
+ error ("%qE attribute argument not a string constant", name);
+ *no_add_attrs = true;
+ }
+ else if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+ "with %qs attribute", name, "always_inline");
+ *no_add_attrs = true;
+ }
+ else if (lookup_attribute ("target", DECL_ATTRIBUTES (*node)))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+ "with %qs attribute", name, "target");
+ *no_add_attrs = true;
+ }
+ else
+ /* Do not inline functions with multiple clone targets. */
+ DECL_UNINLINABLE (*node) = 1;
+ }
+ else
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+ return NULL_TREE;
+}
+
+/* For handling "optimize" attribute. arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_optimize_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags), bool *no_add_attrs)
+{
+ /* Ensure we have a function type. */
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+ else
+ {
+ struct cl_optimization cur_opts;
+ tree old_opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node);
+
+ /* Save current options. */
+ cl_optimization_save (&cur_opts, &global_options, &global_options_set);
+ tree prev_target_node = build_target_option_node (&global_options,
+ &global_options_set);
+
+ /* If we previously had some optimization options, use them as the
+ default. */
+ gcc_options *saved_global_options = NULL;
+
+ /* When #pragma GCC optimize pragma is used, it modifies global_options
+ without calling targetm.override_options_after_change. That can leave
+ target flags inconsistent for comparison. */
+ if (flag_checking && optimization_current_node == optimization_default_node)
+ {
+ saved_global_options = XNEW (gcc_options);
+ *saved_global_options = global_options;
+ }
+
+ if (old_opts)
+ cl_optimization_restore (&global_options, &global_options_set,
+ TREE_OPTIMIZATION (old_opts));
+
+ /* Parse options, and update the vector. */
+ parse_optimize_options (args, true);
+ DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
+ = build_optimization_node (&global_options, &global_options_set);
+ tree target_node = build_target_option_node (&global_options,
+ &global_options_set);
+ if (prev_target_node != target_node)
+ DECL_FUNCTION_SPECIFIC_TARGET (*node) = target_node;
+
+ /* Restore current options. */
+ cl_optimization_restore (&global_options, &global_options_set,
+ &cur_opts);
+ cl_target_option_restore (&global_options, &global_options_set,
+ TREE_TARGET_OPTION (prev_target_node));
+
+ if (saved_global_options != NULL)
+ {
+ if (!seen_error ())
+ cl_optimization_compare (saved_global_options, &global_options);
+ free (saved_global_options);
+ }
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "no_split_stack" attribute. */
+
+static tree
+handle_no_split_stack_attribute (tree *node, tree name,
+ tree ARG_UNUSED (args),
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ tree decl = *node;
+
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE attribute applies only to functions", name);
+ *no_add_attrs = true;
+ }
+ else if (DECL_INITIAL (decl))
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "cannot set %qE attribute after definition", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "zero_call_used_regs" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_zero_call_used_regs_attribute (tree *node, tree name, tree args,
+ int ARG_UNUSED (flags),
+ bool *no_add_attrs)
+{
+ tree decl = *node;
+ tree id = TREE_VALUE (args);
+
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE attribute applies only to functions", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (TREE_CODE (id) != STRING_CST)
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%qE argument not a string", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ bool found = false;
+ for (unsigned int i = 0; zero_call_used_regs_opts[i].name != NULL; ++i)
+ if (strcmp (TREE_STRING_POINTER (id),
+ zero_call_used_regs_opts[i].name) == 0)
+ {
+ found = true;
+ break;
+ }
+
+ if (!found)
+ {
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "unrecognized %qE attribute argument %qs",
+ name, TREE_STRING_POINTER (id));
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
+/* Handle a "returns_nonnull" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_returns_nonnull_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ // Even without a prototype we still have a return type we can check.
+ if (TREE_CODE (TREE_TYPE (*node)) != POINTER_TYPE)
+ {
+ error ("%qE attribute on a function not returning a pointer", name);
+ *no_add_attrs = true;
+ }
+ return NULL_TREE;
+}
+
+/* Handle a "designated_init" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_designated_init_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != RECORD_TYPE)
+ {
+ error ("%qE attribute is only valid on %<struct%> type", name);
+ *no_add_attrs = true;
+ }
+ return NULL_TREE;
+}
+
+
+/* Handle a "fallthrough" attribute; arguments as in struct
+ attribute_spec.handler. */
+
+tree
+handle_fallthrough_attribute (tree *, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+}
+
+/* Handle a "patchable_function_entry" attributes; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_patchable_function_entry_attribute (tree *, tree name, tree args,
+ int, bool *no_add_attrs)
+{
+ for (; args; args = TREE_CHAIN (args))
+ {
+ tree val = TREE_VALUE (args);
+ if (val && TREE_CODE (val) != IDENTIFIER_NODE
+ && TREE_CODE (val) != FUNCTION_DECL)
+ val = default_conversion (val);
+
+ if (!tree_fits_uhwi_p (val))
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute argument %qE is not an integer constant",
+ name, val);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (tree_to_uhwi (val) > USHRT_MAX)
+ {
+ warning (OPT_Wattributes,
+ "%qE attribute argument %qE exceeds %u",
+ name, val, USHRT_MAX);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+ }
+ return NULL_TREE;
+}
+
+/* Handle a "NSObject" attributes; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_nsobject_attribute (tree *node, tree name, tree args,
+ int /*flags*/, bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+
+ /* This attribute only applies to typedefs (or field decls for properties),
+ we drop it otherwise - but warn about this if enabled. */
+ if (TREE_CODE (*node) != TYPE_DECL && TREE_CODE (*node) != FIELD_DECL)
+ {
+ warning (OPT_WNSObject_attribute, "%qE attribute may be put on a"
+ " typedef only; attribute is ignored", name);
+ return NULL_TREE;
+ }
+
+ /* The original implementation only allowed pointers to records, however
+ recent implementations also allow void *. */
+ tree type = TREE_TYPE (*node);
+ if (!type || !POINTER_TYPE_P (type)
+ || (TREE_CODE (TREE_TYPE (type)) != RECORD_TYPE
+ && !VOID_TYPE_P (TREE_TYPE (type))))
+ {
+ error ("%qE attribute is for pointer types only", name);
+ return NULL_TREE;
+ }
+
+ tree t = tree_cons (name, args, TYPE_ATTRIBUTES (type));
+ TREE_TYPE (*node) = build_type_attribute_variant (type, t);
+
+ return NULL_TREE;
+}
+
+/* Handle a "objc_root_class" attributes; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_objc_root_class_attribute (tree */*node*/, tree name, tree /*args*/,
+ int /*flags*/, bool *no_add_attrs)
+{
+ /* This has no meaning outside Objective-C. */
+ if (!c_dialect_objc())
+ warning (OPT_Wattributes, "%qE is only applicable to Objective-C"
+ " class interfaces, attribute ignored", name);
+
+ *no_add_attrs = true;
+ return NULL_TREE;
+}
+
+/* Handle an "objc_nullability" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_objc_nullability_attribute (tree *node, tree name, tree args,
+ int /*flags*/,
+ bool *no_add_attrs)
+{
+ *no_add_attrs = true;
+
+ tree type = TREE_TYPE (*node);
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ type = TREE_TYPE (type);
+
+ if (type && !POINTER_TYPE_P (type))
+ {
+ error ("%qE cannot be applied to non-pointer type %qT", name, type);
+ return NULL_TREE;
+ }
+
+ /* We accept objc_nullability() with a single argument.
+ string: "unspecified", "nullable", "nonnull" or "resettable"
+ integer: 0 and 3 where the values have the same meaning as
+ the strings. */
+ tree val = TREE_VALUE (args);
+ if (TREE_CODE (val) == INTEGER_CST)
+ {
+ val = default_conversion (val);
+ if (!tree_fits_uhwi_p (val) || tree_to_uhwi (val) > 3)
+ error ("%qE attribute argument %qE is not an integer constant"
+ " between 0 and 3", name, val);
+ else
+ *no_add_attrs = false; /* OK */
+ }
+ else if (TREE_CODE (val) == STRING_CST
+ && (strcmp (TREE_STRING_POINTER (val), "nullable") == 0
+ || strcmp (TREE_STRING_POINTER (val), "nonnull") == 0
+ || strcmp (TREE_STRING_POINTER (val), "unspecified") == 0
+ || strcmp (TREE_STRING_POINTER (val), "resettable") == 0))
+ *no_add_attrs = false; /* OK */
+ else if (val != error_mark_node)
+ error ("%qE attribute argument %qE is not recognised", name, val);
+
+ return NULL_TREE;
+}
+
+/* Handle a "tainted_args" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_tainted_args_attribute (tree *node, tree name, tree, int,
+ bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL
+ && TREE_CODE (*node) != FIELD_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored; valid only "
+ "for functions and function pointer fields",
+ name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ if (TREE_CODE (*node) == FIELD_DECL
+ && !(TREE_CODE (TREE_TYPE (*node)) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_TYPE (*node))) == FUNCTION_TYPE))
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored;"
+ " field must be a function pointer",
+ name);
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
+ *no_add_attrs = false; /* OK */
+
+ return NULL_TREE;
+}
+
+/* Attempt to partially validate a single attribute ATTR as if
+ it were to be applied to an entity OPER. */
+
+static bool
+validate_attribute (location_t atloc, tree oper, tree attr)
+{
+ /* Determine whether the name of the attribute is valid
+ and fail with an error if not. */
+ tree atname = get_attribute_name (attr);
+ if (!lookup_attribute_spec (atname))
+ {
+ if (atloc != UNKNOWN_LOCATION)
+ error_at (atloc, "unknown attribute %qE", atname);
+ return false;
+ }
+
+ tree args = TREE_VALUE (attr);
+ if (!args)
+ return true;
+
+ /* FIXME: Do some validation. */
+ const char *atstr = IDENTIFIER_POINTER (atname);
+ if (!strcmp (atstr, "format"))
+ return true;
+
+ /* Only when attribute arguments have been provided try to validate
+ the whole thing. decl_attributes doesn't return an indication of
+ success or failure so proceed regardless. */
+ const char tmpname[] = "__builtin_has_attribute_tmp.";
+ tree tmpid = get_identifier (tmpname);
+ tree tmpdecl;
+ if (!strcmp (atstr, "vector_size"))
+ {
+ tree type = TYPE_P (oper) ? oper : TREE_TYPE (oper);
+ /* Check for function type here since type_for_vector_size
+ strips it while looking for a function's return type. */
+ if (FUNC_OR_METHOD_TYPE_P (type))
+ {
+ warning_at (atloc, OPT_Wattributes,
+ "invalid operand type %qT for %qs", type, atstr);
+ return false;
+ }
+
+ type = type_for_vector_size (type);
+ if (VECTOR_TYPE_P (type))
+ type = TREE_TYPE (type);
+ /* Avoid trying to apply attribute vector_size to OPER since
+ it's overly restrictive. Simply make sure it has the right
+ type. */
+ return type_valid_for_vector_size (type, atname, args, NULL);
+ }
+
+ if (TYPE_P (oper))
+ tmpdecl = build_decl (atloc, TYPE_DECL, tmpid, oper);
+ else if (DECL_P (oper))
+ tmpdecl = build_decl (atloc, TREE_CODE (oper), tmpid, TREE_TYPE (oper));
+ else if (EXPR_P (oper))
+ tmpdecl = build_decl (atloc, TYPE_DECL, tmpid, TREE_TYPE (oper));
+ else
+ return false;
+
+ /* Temporarily clear CURRENT_FUNCTION_DECL to make decl_attributes
+ believe the DECL declared above is at file scope. (See bug 87526.) */
+ tree save_curfunc = current_function_decl;
+ current_function_decl = NULL_TREE;
+ if (DECL_P (tmpdecl))
+ {
+ if (DECL_P (oper))
+ /* An alias cannot be a definition so declare the symbol extern. */
+ DECL_EXTERNAL (tmpdecl) = true;
+ /* Attribute visibility only applies to symbols visible from other
+ translation units so make it "public." */
+ TREE_PUBLIC (tmpdecl) = TREE_PUBLIC (oper);
+ }
+ decl_attributes (&tmpdecl, attr, 0);
+ current_function_decl = save_curfunc;
+
+ /* FIXME: Change decl_attributes to indicate success or failure (and
+ parameterize it to avoid failing with errors). */
+ return true;
+}
+
+/* Return true if the DECL, EXPR, or TYPE t has been declared with
+ attribute ATTR. For DECL, consider also its type. For EXPR,
+ consider just its type. */
+
+bool
+has_attribute (location_t atloc, tree t, tree attr, tree (*convert)(tree))
+{
+ if (!attr || !t || t == error_mark_node)
+ return false;
+
+ if (!validate_attribute (atloc, t, attr))
+ return false;
+
+ tree type = NULL_TREE;
+ tree expr = NULL_TREE;
+ if (TYPE_P (t))
+ type = t;
+ else
+ {
+ do
+ {
+ /* Determine the array element/member declaration from
+ a COMPONENT_REF and an INDIRECT_REF involving a refeence. */
+ STRIP_NOPS (t);
+ tree_code code = TREE_CODE (t);
+ if (code == INDIRECT_REF)
+ {
+ tree op0 = TREE_OPERAND (t, 0);
+ if (TREE_CODE (TREE_TYPE (op0)) == REFERENCE_TYPE)
+ t = op0;
+ else
+ break;
+ }
+ else if (code == COMPONENT_REF)
+ t = TREE_OPERAND (t, 1);
+ else
+ break;
+ } while (true);
+ expr = t;
+ }
+
+ /* Set to true when an attribute is found in the referenced entity
+ that matches the specified attribute. */
+ bool found_match = false;
+
+ tree atname = get_attribute_name (attr);
+ const char *namestr = IDENTIFIER_POINTER (atname);
+
+ /* Iterate once for a type and twice for a function or variable
+ declaration: once for the DECL and the second time for its
+ TYPE. */
+ for (bool done = false; !found_match && !done; )
+ {
+ tree atlist;
+ if (type)
+ {
+ if (type == error_mark_node)
+ {
+ /* This could be a label. FIXME: add support for labels. */
+ warning_at (atloc, OPT_Wattributes,
+ (TYPE_P (t)
+ ? G_("%qs attribute not supported for %qT "
+ "in %<__builtin_has_attribute%>")
+ : G_("%qs attribute not supported for %qE "
+ "in %<__builtin_has_attribute%>")),
+ namestr, t);
+ return false;
+ }
+
+ /* Clear EXPR to prevent considering it again below. */
+ atlist = TYPE_ATTRIBUTES (type);
+ expr = NULL_TREE;
+ done = true;
+ }
+ else if (DECL_P (expr))
+ {
+ /* Set TYPE to the DECL's type to process it on the next
+ iteration. */
+ atlist = DECL_ATTRIBUTES (expr);
+ type = TREE_TYPE (expr);
+ }
+ else
+ {
+ type = TREE_TYPE (expr);
+ atlist = TYPE_ATTRIBUTES (type);
+ done = true;
+ }
+
+ /* True when an attribute with the sought name (though not necessarily
+ with the sought attributes) has been found on the attribute chain. */
+ bool found_attr = false;
+
+ /* When clear, the first mismatched attribute argument results
+ in failure. Otherwise, the first matched attribute argument
+ results in success. */
+ bool attr_nonnull = !strcmp ("nonnull", namestr);
+ bool ignore_mismatches = attr_nonnull;
+
+ /* Iterate over the instances of the sought attribute on the DECL or
+ TYPE (there may be multiple instances with different arguments). */
+ for (; (atlist = lookup_attribute (namestr, atlist));
+ found_attr = true, atlist = TREE_CHAIN (atlist))
+ {
+ /* If there are no arguments to match the result is true except
+ for nonnull where the attribute with no arguments must match. */
+ if (!TREE_VALUE (attr))
+ return attr_nonnull ? !TREE_VALUE (atlist) : true;
+
+ /* Attribute nonnull with no arguments subsumes all values of
+ the attribute. FIXME: This is overly broad since it only
+ applies to pointer arguments, but querying non-pointer
+ arguments is diagnosed. */
+ if (!TREE_VALUE (atlist) && attr_nonnull)
+ return true;
+
+ /* Iterate over the DECL or TYPE attribute argument's values. */
+ for (tree val = TREE_VALUE (atlist); val; val = TREE_CHAIN (val))
+ {
+ /* Iterate over the arguments in the sought attribute comparing
+ their values to those specified for the DECL or TYPE. */
+ for (tree arg = TREE_VALUE (attr); arg; arg = TREE_CHAIN (arg))
+ {
+ tree v1 = TREE_VALUE (val);
+ tree v2 = TREE_VALUE (arg);
+ if (v1 == v2)
+ return true;
+
+ if (!v1 || !v2)
+ break;
+
+ if (TREE_CODE (v1) == IDENTIFIER_NODE
+ || TREE_CODE (v2) == IDENTIFIER_NODE)
+ /* Two identifiers are the same if their values are
+ equal (that's handled above). Otherwise ther are
+ either not the same or oneis not an identifier. */
+ return false;
+
+ /* Convert to make them equality-comparable. */
+ v1 = convert (v1);
+ v2 = convert (v2);
+
+ /* A positive value indicates equality, negative means
+ "don't know." */
+ if (simple_cst_equal (v1, v2) == 1)
+ return true;
+
+ if (!ignore_mismatches)
+ break;
+ }
+ }
+ }
+
+ if (!found_attr)
+ {
+ /* Some attributes are encoded directly in the tree node. */
+ if (!strcmp ("aligned", namestr))
+ {
+ if (tree arg = TREE_VALUE (attr))
+ {
+ arg = convert (TREE_VALUE (arg));
+ if (!tree_fits_uhwi_p (arg))
+ /* Invalid argument. */;
+ else if (expr && DECL_P (expr)
+ && DECL_USER_ALIGN (expr))
+ found_match = DECL_ALIGN_UNIT (expr) == tree_to_uhwi (arg);
+ else if (type && TYPE_USER_ALIGN (type))
+ found_match = TYPE_ALIGN_UNIT (type) == tree_to_uhwi (arg);
+ }
+ else if (expr && DECL_P (expr))
+ found_match = DECL_USER_ALIGN (expr);
+ else if (type)
+ found_match = TYPE_USER_ALIGN (type);
+ }
+ else if (!strcmp ("const", namestr))
+ {
+ if (expr && DECL_P (expr))
+ found_match = TREE_READONLY (expr);
+ }
+ else if (!strcmp ("noreturn", namestr))
+ {
+ /* C11 _Noreturn sets the volatile bit without attaching
+ an attribute to the decl. */
+ if (expr
+ && DECL_P (expr)
+ && FUNC_OR_METHOD_TYPE_P (TREE_TYPE (expr)))
+ found_match = TREE_THIS_VOLATILE (expr);
+ }
+ else if (!strcmp ("pure", namestr))
+ {
+ if (expr && DECL_P (expr))
+ found_match = DECL_PURE_P (expr);
+ }
+ else if (!strcmp ("deprecated", namestr))
+ {
+ found_match = TREE_DEPRECATED (expr ? expr : type);
+ if (found_match)
+ return true;
+ }
+ else if (!strcmp ("vector_size", namestr))
+ {
+ if (!type || !VECTOR_TYPE_P (type))
+ return false;
+
+ if (tree arg = TREE_VALUE (attr))
+ {
+ /* Compare the vector size argument for equality. */
+ arg = convert (TREE_VALUE (arg));
+ return tree_int_cst_equal (arg, TYPE_SIZE_UNIT (type)) == 1;
+ }
+ else
+ return true;
+ }
+ else if (!strcmp ("warn_if_not_aligned", namestr))
+ {
+ if (tree arg = TREE_VALUE (attr))
+ {
+ arg = convert (TREE_VALUE (arg));
+ if (expr && DECL_P (expr))
+ found_match = (DECL_WARN_IF_NOT_ALIGN (expr)
+ == tree_to_uhwi (arg) * BITS_PER_UNIT);
+ else if (type)
+ found_match = (TYPE_WARN_IF_NOT_ALIGN (type)
+ == tree_to_uhwi (arg) * BITS_PER_UNIT);
+ }
+ else if (expr && DECL_P (expr))
+ found_match = DECL_WARN_IF_NOT_ALIGN (expr);
+ else if (type)
+ found_match = TYPE_WARN_IF_NOT_ALIGN (type);
+ }
+ else if (!strcmp ("transparent_union", namestr))
+ {
+ if (type)
+ found_match = TYPE_TRANSPARENT_AGGR (type) != 0;
+ }
+ else if (!strcmp ("mode", namestr))
+ {
+ /* Finally issue a warning for attributes that cannot
+ be supported in this context. Attribute mode is not
+ added to a symbol and cannot be determined from it. */
+ warning_at (atloc, OPT_Wattributes,
+ "%qs attribute not supported in "
+ "%<__builtin_has_attribute%>", namestr);
+ break;
+ }
+ }
+ }
+ return found_match;
+}