On 11/15/20 3:05 PM, Jozef Lawrynowicz wrote: > Attribute handlers may want to examine DECL_INITIAL for a decl, to > validate the attribute being applied. For C++, DECL_INITIAL is currently > not set until cp_finish_decl, by which time attribute validation has > already been performed. > > For msp430-elf this causes the "persistent" attribute to always be > rejected for C++, since DECL_INITIAL must be non-null for the > attribute to be applied to a decl. > > This patch ensures DECL_INITIAL is set for initialized decls early in > start_decl, before attribute handlers run. This allows the > initialization status of the decl to be examined by the handlers. > DECL_INITIAL must be restored to it's initial value after attribute > validation is performed, so as to not interfere with later decl > processing. > > Successfully regtested for arm-none-eabi. > > Ok for trunk? > > 0002-cp-decl.c-Set-DECL_INITIAL-before-attribute-processi.patch > > From f87d3c3aa131cadeaa2f32c9a36609b4dd42db96 Mon Sep 17 00:00:00 2001 > From: Jozef Lawrynowicz <joze...@mittosystems.com> > Date: Sun, 15 Nov 2020 21:43:00 +0000 > Subject: [PATCH 2/3] cp/decl.c: Set DECL_INITIAL before attribute processing > > Attribute handlers may want to examine DECL_INITIAL for a decl, to > validate the attribute being applied. For C++, DECL_INITIAL is currently > not set until cp_finish_decl, by which time attribute validation has > already been performed. > > For msp430-elf this causes the "persistent" attribute to always be > rejected for C++, since DECL_INITIAL must be non-null for the > attribute to be applied to a decl. > > This patch ensures DECL_INITIAL is set for initialized decls early in > start_decl, before attribute handlers run. This allows the > initialization status of the decl to be examined by the handlers. > DECL_INITIAL must be restored to it's initial value after attribute > validation is performed, so as to not interfere with later decl > processing. > > gcc/cp/ChangeLog: > > * decl.c (start_decl): Set DECL_INITIAL for initialized decls > before attribute processing. > > gcc/testsuite/ChangeLog: > > * gcc.target/msp430/data-attributes-2.c: Adjust test. > * g++.target/msp430/data-attributes.C: New test. > * g++.target/msp430/msp430.exp: New test. Normally I'd leave this to the C++ maintainers, but it's simple enough that I'm comfortable ACKing. Even more so since my first thought after reading the description was to shove an error_mark_node into DECL_INITIAL for the duration of the attribute processing. The other alternative would be to make the attribute processing only conditionally look at DECL_INITIAL. jeff