Message ID | 5776442102000078000FA511@prv-mh.provo.novell.com |
---|---|
State | New |
Headers | show |
On 07/01/2016 10:21 AM, Jan Beulich wrote: > Just like gas, which has recently learned to reject such initializers, > gcc shouldn't accept such either. > --- > v2: Use dg-require-named-sections. > > gcc/ > 2016-07-01 Jan Beulich <jbeulich@suse.com> > > * varasm.c (get_variable_section): Validate initializer in > named .bss-like sections. > > gcc/testsuite/ > 2016-07-01 Jan Beulich <jbeulich@suse.com> > > * gcc.dg/bss.c: New. Looks ok, except why the empty dg-options string in the testcase? Bernd
>>> On 01.07.16 at 15:36, <bschmidt@redhat.com> wrote: > On 07/01/2016 10:21 AM, Jan Beulich wrote: >> Just like gas, which has recently learned to reject such initializers, >> gcc shouldn't accept such either. >> --- >> v2: Use dg-require-named-sections. >> >> gcc/ >> 2016-07-01 Jan Beulich <jbeulich@suse.com> >> >> * varasm.c (get_variable_section): Validate initializer in >> named .bss-like sections. >> >> gcc/testsuite/ >> 2016-07-01 Jan Beulich <jbeulich@suse.com> >> >> * gcc.dg/bss.c: New. > > Looks ok, except why the empty dg-options string in the testcase? Because I've seen in it that way in various other test cases (and yes, yet others don't have it). I had to decide for one of the variants, and if it's not required (nor wanted) I can certainly drop it. Jan
On 07/01/2016 03:42 PM, Jan Beulich wrote: >>>> On 01.07.16 at 15:36, <bschmidt@redhat.com> wrote: >> Looks ok, except why the empty dg-options string in the testcase? > > Because I've seen in it that way in various other test cases (and > yes, yet others don't have it). I had to decide for one of the > variants, and if it's not required (nor wanted) I can certainly drop > it. Yes, if there's no real reason, drop it. Bernd
>>> On 01.07.16 at 15:44, <bschmidt@redhat.com> wrote: > On 07/01/2016 03:42 PM, Jan Beulich wrote: >>>>> On 01.07.16 at 15:36, <bschmidt@redhat.com> wrote: > >>> Looks ok, except why the empty dg-options string in the testcase? >> >> Because I've seen in it that way in various other test cases (and >> yes, yet others don't have it). I had to decide for one of the >> variants, and if it's not required (nor wanted) I can certainly drop >> it. > > Yes, if there's no real reason, drop it. Do I need to re-submit, or can I take the above as approved-with- that-change? Jan
On 07/01/2016 03:57 PM, Jan Beulich wrote: > Do I need to re-submit, or can I take the above as approved-with- > that-change? Ok with that change. Bernd
--- 2016-06-30/gcc/testsuite/gcc.dg/bss.c +++ 2016-06-30/gcc/testsuite/gcc.dg/bss.c @@ -0,0 +1,9 @@ +/* Test non-zero initializers in .bss-like sections get properly refused. */ +/* { dg-do compile } */ +/* { dg-require-named-sections "" } */ +/* { dg-options "" } */ + +int __attribute__((section(".bss.local"))) x = 1; /* { dg-error "" "zero init" } */ +int *__attribute__((section(".bss.local"))) px = &x; /* { dg-error "" "zero init" } */ +int __attribute__((section(".bss.local"))) y = 0; +int *__attribute__((section(".bss.local"))) py = (void*)0; --- 2016-06-30/gcc/varasm.c +++ 2016-06-30/gcc/varasm.c @@ -1150,7 +1150,18 @@ get_variable_section (tree decl, bool pr resolve_unique_section (decl, reloc, flag_data_sections); if (IN_NAMED_SECTION (decl)) - return get_named_section (decl, NULL, reloc); + { + section *sect = get_named_section (decl, NULL, reloc); + + if ((sect->common.flags & SECTION_BSS) && !bss_initializer_p (decl)) + { + error_at (DECL_SOURCE_LOCATION (decl), + "only zero initializers are allowed in section %qs", + sect->named.name); + DECL_INITIAL (decl) = error_mark_node; + } + return sect; + } if (ADDR_SPACE_GENERIC_P (as) && !DECL_THREAD_LOCAL_P (decl)