public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100939] New: Missing warning with misplaced attribute declaration in struct, enum, or union definition
@ 2021-06-07 3:48 johnfbennett at protonmail dot com
2021-06-10 4:23 ` [Bug c/100939] " johnfbennett at protonmail dot com
0 siblings, 1 reply; 2+ messages in thread
From: johnfbennett at protonmail dot com @ 2021-06-07 3:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100939
Bug ID: 100939
Summary: Missing warning with misplaced attribute declaration
in struct, enum, or union definition
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: johnfbennett at protonmail dot com
Target Milestone: ---
$ cat misplacedattribute.c
struct samplestruct {
int member1;
int member2;
};
int main(void) {
struct __attribute__((__unused__)) samplestruct samplestruct;
return 0;
}
$ gcc -Wall misplacedattribute.c
misplacedattribute.c: In function ‘main’:
misplacedattribute.c:7:50: warning: unused variable ‘samplestruct’
[-Wunused-variable]
7 | struct __attribute__((__unused__)) samplestruct samplestruct;
| ^~~~~~~~~~~~
$
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/100939] Missing warning with misplaced attribute declaration in struct, enum, or union definition
2021-06-07 3:48 [Bug c/100939] New: Missing warning with misplaced attribute declaration in struct, enum, or union definition johnfbennett at protonmail dot com
@ 2021-06-10 4:23 ` johnfbennett at protonmail dot com
0 siblings, 0 replies; 2+ messages in thread
From: johnfbennett at protonmail dot com @ 2021-06-10 4:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100939
--- Comment #1 from johnfbennett at protonmail dot com ---
G++ does have a good warning for this scenario:
$ g++ -Wall misplacedattribute.c
misplacedattribute.c: In function ‘int main()’:
misplacedattribute.c:7:37: warning: attributes ignored on
elaborated-type-specifier that is not a forward declaration [-Wattributes]
7 | struct __attribute__((__unused__)) samplestruct samplestruct;
| ^~~~~~~~~~~~
misplacedattribute.c:7:50: warning: unused variable ‘samplestruct’
[-Wunused-variable]
7 | struct __attribute__((__unused__)) samplestruct samplestruct;
| ^~~~~~~~~~~~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-10 4:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 3:48 [Bug c/100939] New: Missing warning with misplaced attribute declaration in struct, enum, or union definition johnfbennett at protonmail dot com
2021-06-10 4:23 ` [Bug c/100939] " johnfbennett at protonmail dot com
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).