diff options
author | Jozef Lawrynowicz <jozef.l@somniumtech.com> | 2017-06-15 13:38:52 +0000 |
---|---|---|
committer | Nick Clifton <nickc@gcc.gnu.org> | 2017-06-15 13:38:52 +0000 |
commit | 61f5d85294a6a2757a1ab870c6f335e092c0c83a (patch) | |
tree | c687e904fefd96cf91a4784dfa2a87fc8ed968e4 /gcc/config/msp430 | |
parent | 0948d23fffba754853cc93984e106d2aaf9a3897 (diff) | |
download | gcc-61f5d85294a6a2757a1ab870c6f335e092c0c83a.zip gcc-61f5d85294a6a2757a1ab870c6f335e092c0c83a.tar.gz gcc-61f5d85294a6a2757a1ab870c6f335e092c0c83a.tar.bz2 |
Fix problems with the MSP430 port's handling of persistent data.
PR target/78818
gcc * config/msp430/msp430.c (msp430_data_attr): Check that it's possible
for a variable to have a section before checking if the section has a
name.
Set section to.persistent if persistent attribute is set.
Warn if .persistent attribute is used on an automatic variable.
tests * gcc.target/msp430/pr78818-real.c: New template for tests.
* gcc.target/msp430/pr78818-auto.c: New test.
* gcc.target/msp430/pr78818-data-region.c: New test.
* gcc.target/msp430/pr78818-data-sec.c: New test.
* gcc.target/msp430/pr78818-auto-warn.c: New test.
From-SVN: r249222
Diffstat (limited to 'gcc/config/msp430')
-rw-r--r-- | gcc/config/msp430/msp430.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index dd53dea..6acab1e 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -40,6 +40,7 @@ #include "expr.h" #include "langhooks.h" #include "builtins.h" +#include "intl.h" /* This file should be included last. */ #include "target-def.h" @@ -1993,10 +1994,24 @@ msp430_data_attr (tree * node, gcc_assert (args == NULL); if (TREE_CODE (* node) != VAR_DECL) - message = "%qE attribute only applies to variables"; - - if (DECL_SECTION_NAME (* node)) - message = "%qE attribute cannot be applied to variables with specific sections"; + message = G_("%qE attribute only applies to variables"); + + /* Check that it's possible for the variable to have a section. */ + if ((TREE_STATIC (* node) || DECL_EXTERNAL (* node) || in_lto_p) + && DECL_SECTION_NAME (* node)) + message = G_("%qE attribute cannot be applied to variables with specific sections"); + + if (!message && TREE_NAME_EQ (name, ATTR_PERSIST) && !TREE_STATIC (* node) + && !TREE_PUBLIC (* node) && !DECL_EXTERNAL (* node)) + message = G_("%qE attribute has no effect on automatic variables"); + + /* It's not clear if there is anything that can be set here to prevent the + front end placing the variable before the back end can handle it, in a + similar way to how DECL_COMMON is used below. + So just place the variable in the .persistent section now. */ + if ((TREE_STATIC (* node) || DECL_EXTERNAL (* node) || in_lto_p) + && TREE_NAME_EQ (name, ATTR_PERSIST)) + set_decl_section_name (* node, ".persistent"); /* If this var is thought to be common, then change this. Common variables are assigned to sections before the backend has a chance to process them. */ |