static int __attribute__ ((section ("__libc_freeres_fn")))
free_slotinfo (struct dtv_slotinfo_list **elemp)
+/* { dg-warning "'.*' without 'used' attribute and '.*' with 'used' attribute are placed in a section with the same name" "" { target R_flag_in_section } .-1 } */
{
if (!free_slotinfo (&(*elemp)->next))
return 0;
int __attribute__((used,section(".data.foo"))) foo2 = 2;
int __attribute__((section(".data.foo"))) foo1 = 1;
+/* { dg-warning "'.*' without 'used' attribute and '.*' with 'used' attribute are placed in a section with the same name" "" { target R_flag_in_section } .-1 } */
/* { dg-final { scan-assembler ".data.foo,\"aw\"" { target R_flag_in_section } } } */
/* { dg-final { scan-assembler ".data.foo,\"awR\"" { target R_flag_in_section } } } */
/* { dg-options "-Wall -O2" } */
int __attribute__((section(".data.foo"))) foo1 = 1;
+/* { dg-warning "'.*' without 'used' attribute and '.*' with 'used' attribute are placed in a section with the same name" "" { target R_flag_in_section } .-1 } */
int __attribute__((used,section(".data.foo"))) foo2 = 2;
/* { dg-final { scan-assembler ".data.foo,\"aw\"" { target R_flag_in_section } } } */
{
/* If the SECTION_RETAIN bit doesn't match, switch to a new
section. */
+ tree used_decl, no_used_decl;
+
if (DECL_PRESERVE_P (decl))
- new_section->common.flags |= SECTION_RETAIN;
+ {
+ new_section->common.flags |= SECTION_RETAIN;
+ used_decl = decl;
+ no_used_decl = new_section->named.decl;
+ }
else
- new_section->common.flags &= ~(SECTION_RETAIN
- | SECTION_DECLARED);
+ {
+ new_section->common.flags &= ~(SECTION_RETAIN
+ | SECTION_DECLARED);
+ used_decl = new_section->named.decl;
+ no_used_decl = decl;
+ }
+ warning (OPT_Wattributes,
+ "%+qD without %<used%> attribute and %qD with "
+ "%<used%> attribute are placed in a section with "
+ "the same name", no_used_decl, used_decl);
+ inform (DECL_SOURCE_LOCATION (used_decl),
+ "%qD was declared here", used_decl);
}
else
return;