* Re: [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
@ 2017-05-30 11:51 Nick Clifton
2017-06-08 15:50 ` Jozef Lawrynowicz
0 siblings, 1 reply; 8+ messages in thread
From: Nick Clifton @ 2017-05-30 11:51 UTC (permalink / raw)
To: Jozef Lawrynowicz; +Cc: gcc-patches
Hi Jozef,
> Attached patch with the string wrapped in G_().
When I applied this patch to the sources and ran the new test, I encountered
an internal compiler error:
msp430-elf/gcc/xgcc [...] pr78818-auto-warn.c [...]
[...]
gcc/testsuite/gcc.target/msp430/pr78818-auto-warn.c: In function 'main':
gcc/testsuite/gcc.target/msp430/pr78818-auto-warn.c:10:3: internal compiler error: in get, at cgraph.h:403
0xd30d3b symtab_node::get(tree_node const*)
gcc/current/gcc/cgraph.h:400
0xd30d3b decl_section_name(tree_node const*)
gcc/current/gcc/tree.c:700
0xd9ff22 msp430_data_attr
gcc/current/gcc/config/msp430/msp430.c:1998
It seems that there is a problem with calling the DECL_SECTION_NAME macro on the
line just before your new code. Are you able to reproduce this problem ?
Cheers
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
2017-05-30 11:51 [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818) Nick Clifton
@ 2017-06-08 15:50 ` Jozef Lawrynowicz
2017-06-13 15:54 ` Nick Clifton
0 siblings, 1 reply; 8+ messages in thread
From: Jozef Lawrynowicz @ 2017-06-08 15:50 UTC (permalink / raw)
To: Nick Clifton; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1824 bytes --]
On 30/05/2017 12:50, Nick Clifton wrote:
> When I applied this patch to the sources and ran the new test, I encountered
> an internal compiler error:
>
> msp430-elf/gcc/xgcc [...] pr78818-auto-warn.c [...]
> [...]
> gcc/testsuite/gcc.target/msp430/pr78818-auto-warn.c: In function 'main':
>
> gcc/testsuite/gcc.target/msp430/pr78818-auto-warn.c:10:3: internal compiler error: in get, at cgraph.h:403
>
> 0xd30d3b symtab_node::get(tree_node const*)
> gcc/current/gcc/cgraph.h:400
>
> 0xd30d3b decl_section_name(tree_node const*)
> gcc/current/gcc/tree.c:700
>
> 0xd9ff22 msp430_data_attr
> gcc/current/gcc/config/msp430/msp430.c:1998
>
>
> It seems that there is a problem with calling the DECL_SECTION_NAME macro on the
> line just before your new code. Are you able to reproduce this problem ?
>
Hi Nick,
Apologies for the delay in replying.
I have reproduced this issue with current trunk and on the gcc-7-branch,
but it does not reproduce on the gcc-6-branch.
The ICE isn't caused by my patch but the pr78818-auto-warn.c test does
expose it.
I've attached an additional patch to fix the ICE (0001*). The ICE was
caused by a new gcc_checking_assert added in GCC7 that checks that
"symtab_node" has been called on a sane object. Added some additional
check in msp430.c:data_attr that prevent section names being looked up
on variables that can't have a section.
The 0002* patch has been updated as this also caused an ICE when running
the test case for the same reason as above, which was exposed when the
first ICE was fixed.
I have tested these patches on trunk this time (previous testing was
done on performed on gcc-6-branch only) and can confirm there are no
regressions and the new tests build successfully.
Ok for trunk and gcc-7-branch?
Thanks,
Jozef
[-- Attachment #2: 0001-MSP430-Check-if-a-variable-can-have-a-section-before.patch --]
[-- Type: text/plain, Size: 1449 bytes --]
From 8a41a45f2f771ae540b16ec007ded499a9ed5244 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Mon, 5 Jun 2017 18:07:22 +0000
Subject: [PATCH 1/3] MSP430: Check if a variable can have a section before
checking for a section name
2017-06-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
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.
---
gcc/config/msp430/msp430.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index dd53dea..cdd765b 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -1995,8 +1995,10 @@ msp430_data_attr (tree * node,
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";
+ /* 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 = "%qE attribute cannot be applied to variables with specific sections";
/* 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. */
--
1.8.3.1
[-- Attachment #3: 0002-MSP430-Fix-persistent-attribute-not-placing-data-int.patch --]
[-- Type: text/plain, Size: 4952 bytes --]
From e9404da28ade51c0303394f6ab12528b1c62afca Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Fri, 12 May 2017 13:04:59 +0000
Subject: [PATCH 2/3] MSP430: Fix persistent attribute not placing data into
the .persistent section
2017-06-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
gcc/
PR target/78818
* config/msp430/msp430.c (msp430_unique_section): Set section to
.persistent if persistent attribute is set.
gcc/testsuite
PR target/78818
* gcc.target/msp430/msp430.exp: Search for tests in subfolders as well as
main directory.
* gcc.target/msp430/pr78818/pr78818-real.c: New template for tests.
* gcc.target/msp430/pr78818/pr78818-auto.c: New test.
* gcc.target/msp430/pr78818/pr78818-data-region.c: New test.
* gcc.target/msp430/pr78818/pr78818-data-sec.c: Likewise.
---
gcc/config/msp430/msp430.c | 8 ++++++++
gcc/testsuite/gcc.target/msp430/msp430.exp | 4 ++--
gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c | 5 +++++
gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c | 7 +++++++
gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c | 8 ++++++++
gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c | 9 +++++++++
6 files changed, 39 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index cdd765b..c359c77 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -2000,6 +2000,14 @@ msp430_data_attr (tree * node,
&& DECL_SECTION_NAME (* node))
message = "%qE attribute cannot be applied to variables with specific sections";
+ /* 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. */
if (DECL_COMMON (* node))
diff --git a/gcc/testsuite/gcc.target/msp430/msp430.exp b/gcc/testsuite/gcc.target/msp430/msp430.exp
index e54d531..a056417 100644
--- a/gcc/testsuite/gcc.target/msp430/msp430.exp
+++ b/gcc/testsuite/gcc.target/msp430/msp430.exp
@@ -34,8 +34,8 @@ if ![info exists DEFAULT_CFLAGS] then {
dg-init
# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
- "" $DEFAULT_CFLAGS
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/{*,*/*}.\[cCS\]]] \
+ "" $DEFAULT_CFLAGS
# All done.
dg-finish
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c
new file mode 100644
index 0000000..1fb0b28
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+/* { dg-final { scan-assembler-not "\\.comm" } } */
+
+#include "pr78818-real.c"
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c
new file mode 100644
index 0000000..5da6a82
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-region.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+/* { dg-options "-mdata-region=either" } */
+
+/* { dg-final { scan-assembler-not "\\.either" } } */
+
+#include "pr78818-real.c"
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c
new file mode 100644
index 0000000..2d40ea7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-data-sec.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+/* { dg-options "-fdata-sections" } */
+
+/* { dg-final { scan-assembler-not "\\.data" } } */
+/* { dg-final { scan-assembler-not "\\.bss" } } */
+
+#include "pr78818-real.c"
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c
new file mode 100644
index 0000000..504ed4a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-real.c
@@ -0,0 +1,9 @@
+__attribute__((persistent)) int persistent_1 = 1;
+__attribute__((persistent)) int persistent_2 = 0;
+static __attribute__((persistent)) int persistent_3 = 1;
+static __attribute__((persistent)) int persistent_4 = 0;
+
+int main (void)
+{
+ return 0;
+}
--
1.8.3.1
[-- Attachment #4: 0003-MSP430-Emit-warning-when-persistent-attribute-is-use.patch --]
[-- Type: text/plain, Size: 2685 bytes --]
From 0edf1ea2774381eeaac395d1b010aae03ec98418 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Fri, 5 May 2017 15:31:39 +0000
Subject: [PATCH 3/3] MSP430: Emit warning when persistent attribute is used on
an automatic variable
2017-06-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
gcc/
PR target/78818
* config/msp430/msp430.c (msp430_unique_section): Warn if .persistent
attribute is used on an automatic variable.
gcc/testsuite
PR target/78818
* gcc.target/msp430/pr78818/pr78818-auto-warn.c: New test.
---
gcc/config/msp430/msp430.c | 5 +++++
.../gcc.target/msp430/pr78818/pr78818-auto-warn.c | 15 +++++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index c359c77..dfd2af6 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"
@@ -2000,6 +2001,10 @@ msp430_data_attr (tree * node,
&& DECL_SECTION_NAME (* node))
message = "%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.
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
new file mode 100644
index 0000000..1d92fe1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+__attribute__((persistent)) int persistent_1_g = 1;
+__attribute__((persistent)) int persistent_2_g = 0;
+static __attribute__((persistent)) int persistent_3_g = 1;
+static __attribute__((persistent)) int persistent_4_g = 0;
+
+int main (void)
+{
+ __attribute__((persistent)) int persistent_1 = 1; /* { dg-warning "attribute has no effect on automatic" } */
+ __attribute__((persistent)) int persistent_2 = 0; /* { dg-warning "attribute has no effect on automatic" } */
+ static __attribute__((persistent)) int persistent_3 = 1;
+ static __attribute__((persistent)) int persistent_4 = 0;
+ return 0;
+}
--
1.8.3.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
2017-06-08 15:50 ` Jozef Lawrynowicz
@ 2017-06-13 15:54 ` Nick Clifton
2017-06-13 17:46 ` Jozef Lawrynowicz
0 siblings, 1 reply; 8+ messages in thread
From: Nick Clifton @ 2017-06-13 15:54 UTC (permalink / raw)
To: Jozef Lawrynowicz; +Cc: gcc-patches
Hi Jozef,
> Ok for trunk and gcc-7-branch?
Approved - please apply (to both).
Cheers
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
2017-06-13 15:54 ` Nick Clifton
@ 2017-06-13 17:46 ` Jozef Lawrynowicz
2017-06-15 13:39 ` Nick Clifton
0 siblings, 1 reply; 8+ messages in thread
From: Jozef Lawrynowicz @ 2017-06-13 17:46 UTC (permalink / raw)
To: Nick Clifton; +Cc: gcc-patches
On 13/06/2017 16:54, Nick Clifton wrote:
> Hi Jozef,
>
>> Ok for trunk and gcc-7-branch?
>
> Approved - please apply (to both).
>
> Cheers
> Nick
>
>
Sorry, didn't mention in that last post that I don't have write access,
could someone please apply this for me.
Thanks,
Jozef
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
2017-06-13 17:46 ` Jozef Lawrynowicz
@ 2017-06-15 13:39 ` Nick Clifton
0 siblings, 0 replies; 8+ messages in thread
From: Nick Clifton @ 2017-06-15 13:39 UTC (permalink / raw)
To: Jozef Lawrynowicz; +Cc: gcc-patches
Hi Jozef,
> Sorry, didn't mention in that last post that I don't have write access,
> could someone please apply this for me.
Applied. Sorry about the delay (again).
Cheers
Nick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
@ 2017-05-18 18:05 Jozef Lawrynowicz
0 siblings, 0 replies; 8+ messages in thread
From: Jozef Lawrynowicz @ 2017-05-18 18:05 UTC (permalink / raw)
To: Martin Sebor, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 666 bytes --]
On 18 May 2017 at 16:46, Martin Sebor <msebor@gmail.com> wrote:
> + if (!message && TREE_NAME_EQ (name, ATTR_PERSIST) && !TREE_STATIC (*
> node)
> + && !TREE_PUBLIC (* node) && !DECL_EXTERNAL (* node))
> + message = "%qE attribute has no effect on automatic variables";
>
> In code like this (both existing and new) where the format string
> is being assigned to a pointer that is then passed to one of the
> diagnostic functions, I believe the string literal needs to wrapped
> in G_() so that it can be translated.
Attached patch with the string wrapped in G_().
I'll update the other diagnostic strings without G_() in a separate patch.
Thanks,
Jozef
[-- Attachment #2: 0002-MSP430-Emit-warning-when-persistent-attribute-is-use.patch --]
[-- Type: application/octet-stream, Size: 2681 bytes --]
From 4790629950819460a22738da88b01c104012d98e Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Fri, 5 May 2017 15:31:39 +0000
Subject: [PATCH 2/2] MSP430: Emit warning when persistent attribute is used on
an automatic variable
2017-05-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
gcc/
PR target/78818
* config/msp430/msp430.c (msp430_unique_section): Warn if .persistent
attribute is used on an automatic variable.
gcc/testsuite
PR target/78818
* gcc.target/msp430/pr78818/pr78818-auto-warn.c: New test.
---
gcc/config/msp430/msp430.c | 5 +++++
.../gcc.target/msp430/pr78818/pr78818-auto-warn.c | 15 +++++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index c70121e..959f235 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -39,6 +39,7 @@
#include "expr.h"
#include "langhooks.h"
#include "builtins.h"
+#include "intl.h"
/* This file should be included last. */
#include "target-def.h"
@@ -1975,6 +1976,10 @@ msp430_data_attr (tree * node,
if (DECL_SECTION_NAME (* node))
message = "%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.
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
new file mode 100644
index 0000000..1d92fe1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+__attribute__((persistent)) int persistent_1_g = 1;
+__attribute__((persistent)) int persistent_2_g = 0;
+static __attribute__((persistent)) int persistent_3_g = 1;
+static __attribute__((persistent)) int persistent_4_g = 0;
+
+int main (void)
+{
+ __attribute__((persistent)) int persistent_1 = 1; /* { dg-warning "attribute has no effect on automatic" } */
+ __attribute__((persistent)) int persistent_2 = 0; /* { dg-warning "attribute has no effect on automatic" } */
+ static __attribute__((persistent)) int persistent_3 = 1;
+ static __attribute__((persistent)) int persistent_4 = 0;
+ return 0;
+}
--
1.8.3.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
2017-05-17 15:47 Jozef Lawrynowicz
@ 2017-05-18 16:08 ` Martin Sebor
0 siblings, 0 replies; 8+ messages in thread
From: Martin Sebor @ 2017-05-18 16:08 UTC (permalink / raw)
To: Jozef Lawrynowicz, gcc-patches
On 05/17/2017 09:45 AM, Jozef Lawrynowicz wrote:
> Add warning to back end and add test.
>
> Patch is attached.
>
> If the patch is acceptable, I would appreciate if someone could commit
> it for me as I do not have write access.
>
> 2017-05-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
> gcc/
> PR target/78818
> * config/msp430/msp430.c (msp430_unique_section): Warn if .persistent
> attribute is used on an automatic variable.
+ if (!message && TREE_NAME_EQ (name, ATTR_PERSIST) && !TREE_STATIC (*
node)
+ && !TREE_PUBLIC (* node) && !DECL_EXTERNAL (* node))
+ message = "%qE attribute has no effect on automatic variables";
In code like this (both existing and new) where the format string
is being assigned to a pointer that is then passed to one of the
diagnostic functions, I believe the string literal needs to wrapped
in G_() so that it can be translated.
Martin
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818)
@ 2017-05-17 15:47 Jozef Lawrynowicz
2017-05-18 16:08 ` Martin Sebor
0 siblings, 1 reply; 8+ messages in thread
From: Jozef Lawrynowicz @ 2017-05-17 15:47 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 480 bytes --]
Add warning to back end and add test.
Patch is attached.
If the patch is acceptable, I would appreciate if someone could commit
it for me as I do not have write access.
2017-05-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
gcc/
PR target/78818
* config/msp430/msp430.c (msp430_unique_section): Warn if .persistent
attribute is used on an automatic variable.
gcc/testsuite
PR target/78818
* gcc.target/msp430/pr78818/pr78818-auto-warn.c: New test.
[-- Attachment #2: 0002-MSP430-Emit-warning-when-persistent-attribute-is-use.patch --]
[-- Type: application/octet-stream, Size: 2503 bytes --]
From 24726c1e0d68eebeaed6bf5f3fd3f39b00a93a7e Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@somniumtech.com>
Date: Fri, 5 May 2017 15:31:39 +0000
Subject: [PATCH 2/2] MSP430: Emit warning when persistent attribute is used on
an automatic variable
2017-05-XX Jozef Lawrynowicz <jozef.l@somniumtech.com>
gcc/
PR target/78818
* config/msp430/msp430.c (msp430_unique_section): Warn if .persistent
attribute is used on an automatic variable.
gcc/testsuite
PR target/78818
* gcc.target/msp430/pr78818/pr78818-auto-warn.c: New test.
---
gcc/config/msp430/msp430.c | 4 ++++
.../gcc.target/msp430/pr78818/pr78818-auto-warn.c | 15 +++++++++++++++
2 files changed, 19 insertions(+)
create mode 100644 gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c
index c70121e..9c3720d 100644
--- a/gcc/config/msp430/msp430.c
+++ b/gcc/config/msp430/msp430.c
@@ -1975,6 +1975,10 @@ msp430_data_attr (tree * node,
if (DECL_SECTION_NAME (* node))
message = "%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 = "%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.
diff --git a/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
new file mode 100644
index 0000000..1d92fe1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/msp430/pr78818/pr78818-auto-warn.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+
+__attribute__((persistent)) int persistent_1_g = 1;
+__attribute__((persistent)) int persistent_2_g = 0;
+static __attribute__((persistent)) int persistent_3_g = 1;
+static __attribute__((persistent)) int persistent_4_g = 0;
+
+int main (void)
+{
+ __attribute__((persistent)) int persistent_1 = 1; /* { dg-warning "attribute has no effect on automatic" } */
+ __attribute__((persistent)) int persistent_2 = 0; /* { dg-warning "attribute has no effect on automatic" } */
+ static __attribute__((persistent)) int persistent_3 = 1;
+ static __attribute__((persistent)) int persistent_4 = 0;
+ return 0;
+}
--
1.8.3.1
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-06-15 13:39 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 11:51 [PATCH 2/2] [MSP430] Fix issues handling .persistent attribute (PR 78818) Nick Clifton
2017-06-08 15:50 ` Jozef Lawrynowicz
2017-06-13 15:54 ` Nick Clifton
2017-06-13 17:46 ` Jozef Lawrynowicz
2017-06-15 13:39 ` Nick Clifton
-- strict thread matches above, loose matches on Subject: below --
2017-05-18 18:05 Jozef Lawrynowicz
2017-05-17 15:47 Jozef Lawrynowicz
2017-05-18 16:08 ` Martin Sebor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).