]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/testsuite/g++.target/msp430/msp430.exp
cp/decl.c: Set DECL_INITIAL before attribute processing
authorJozef Lawrynowicz <jozef.l@mittosystems.com>
Mon, 23 Nov 2020 12:06:15 +0000 (12:06 +0000)
committerJozef Lawrynowicz <jozef.l@mittosystems.com>
Mon, 23 Nov 2020 12:06:15 +0000 (12:06 +0000)
commitfb8309d4abdcd4c8de07bd4c42e22d1e80471765
treef2bbbaa05ee7dd1fc45845ae0d1277765032e6f5
parentb510765dedfec573c756cb1fcfcb5b0c3830c5e9
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.
gcc/cp/decl.c
gcc/testsuite/g++.target/msp430/data-attributes.C [new file with mode: 0644]
gcc/testsuite/g++.target/msp430/msp430.exp [new file with mode: 0644]
gcc/testsuite/gcc.target/msp430/data-attributes-2.c