When developing developing software I will get this error once in a while structure has no member named '<member-name>' due to typos and other typical development gotchas. It would be useful if the error message included the structure name if known or associated pointer or variable if the compiler has the information available for the error message. I often use the same structure member names in mulitple structures since I use names that convey the use of member. If the message was something like this structure '<structure-name>' has no member named '<member-name>' or this '<variable>' structure '<structure-name>' has no member named '<member-name>' it would make it easier to locate the proper reference in more complicated statements.
Confirmed on the mainline here is a small testcase to go with this report: struct t { int k; }; void j() { struct t p; p.d = 1; } We should say that d is not a member of the struct t.
As a side note, the C++ frontend emits this diagnostic for the same testcase: diag.cc: In function `void j()': diag.cc:8: error: 'struct t' has no member named 'd'
Subject: Re: Error message enhancement Request "giovannibajo at libero dot it" <gcc-bugzilla@gcc.gnu.org> writes: | As a side note, the C++ frontend emits this diagnostic for the same testcase: | | diag.cc: In function `void j()': | diag.cc:8: error: 'struct t' has no member named 'd' Yes, this is because the C front-end uses a different diagnostic (more primitive) infrastructure than C++. I have been unifying them, but did not have time to finish. -- Gaby
Subject: Bug 13804 CVSROOT: /cvs/gcc Module name: gcc Changes by: jsm28@gcc.gnu.org 2004-09-27 19:33:55 Modified files: gcc : ChangeLog c-typeck.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: pr13804-1.c Log message: PR c/13804 * c-typeck.c (build_component_ref): Name type involved in diagnostic for structure or union without a member of the given name. testsuite: * gcc.dg/pr13804-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5643&r2=2.5644 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.380&r2=1.381 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4358&r2=1.4359 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr13804-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed.