Message ID | 1417652468-13636-1-git-send-email-tsaunders@mozilla.com |
---|---|
State | New |
Headers | show |
> From: Trevor Saunders <tsaunders@mozilla.com> > > Hi, > > In this pr we have a section attribute being applied to something in a comdat > group. Since its ok for things to be in a comdat group and have an implicit > section it seems it should also be fine to have a section from the attribute. > > bootstrapped + regtested x86_64-unknown-linux-gnu, ok? > > Trev > > gcc/ > > * symtab.c (symtab_node::verify): Check for section attribute before asserting something isn't in a section and a comdat group. OK (if Jason is happy about user defined comdat sections, I am happy too ;) Honza > > diff --git a/gcc/symtab.c b/gcc/symtab.c > index 29839e6..0535670 100644 > --- a/gcc/symtab.c > +++ b/gcc/symtab.c > @@ -1102,7 +1102,8 @@ symtab_node::verify_base (void) > error_found = true; > } > if (get_section () && get_comdat_group () > - && !implicit_section) > + && !implicit_section > + && !lookup_attribute ("section", DECL_ATTRIBUTES (decl))) > { > error ("Both section and comdat group is set"); > error_found = true; > diff --git a/gcc/testsuite/g++.dg/ipa/pr63621.C b/gcc/testsuite/g++.dg/ipa/pr63621.C > new file mode 100644 > index 0000000..c8262b8 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/ipa/pr63621.C > @@ -0,0 +1,29 @@ > +// { dg-do compile } > + class A > +{ > + public: > + int __attribute__((section("a"))) f1(bool); > + int f2(void *); > + int f3(bool); > +}; > + > +inline int A::f1(bool b) > +{ > + static int c; > + if (c) > + ; > + return 0; > +} > + > +inline int A::f3(bool b) > +{ > + static __attribute__((section(""))) int c; > + if (c) > + ; > + return 0; > +} > + > +int A::f2(void *c) > +{ > + return f1(c) + f3(c); > +} > -- > 2.1.3
diff --git a/gcc/symtab.c b/gcc/symtab.c index 29839e6..0535670 100644 --- a/gcc/symtab.c +++ b/gcc/symtab.c @@ -1102,7 +1102,8 @@ symtab_node::verify_base (void) error_found = true; } if (get_section () && get_comdat_group () - && !implicit_section) + && !implicit_section + && !lookup_attribute ("section", DECL_ATTRIBUTES (decl))) { error ("Both section and comdat group is set"); error_found = true; diff --git a/gcc/testsuite/g++.dg/ipa/pr63621.C b/gcc/testsuite/g++.dg/ipa/pr63621.C new file mode 100644 index 0000000..c8262b8 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63621.C @@ -0,0 +1,29 @@ +// { dg-do compile } + class A +{ + public: + int __attribute__((section("a"))) f1(bool); + int f2(void *); + int f3(bool); +}; + +inline int A::f1(bool b) +{ + static int c; + if (c) + ; + return 0; +} + +inline int A::f3(bool b) +{ + static __attribute__((section(""))) int c; + if (c) + ; + return 0; +} + +int A::f2(void *c) +{ + return f1(c) + f3(c); +}
From: Trevor Saunders <tsaunders@mozilla.com> Hi, In this pr we have a section attribute being applied to something in a comdat group. Since its ok for things to be in a comdat group and have an implicit section it seems it should also be fine to have a section from the attribute. bootstrapped + regtested x86_64-unknown-linux-gnu, ok? Trev gcc/ * symtab.c (symtab_node::verify): Check for section attribute before asserting something isn't in a section and a comdat group.