Bug 13804 - Error message enhancement Request
Summary: Error message enhancement Request
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 2.95
: P3 enhancement
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2004-01-22 02:07 UTC by Donald R. Laster Jr.
Modified: 2004-09-27 20:19 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-08-19 00:22:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Donald R. Laster Jr. 2004-01-22 02:07:40 UTC
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.
Comment 1 Andrew Pinski 2004-01-22 02:11:57 UTC
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.
Comment 2 Giovanni Bajo 2004-01-22 02:33:25 UTC
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'
Comment 3 Gabriel Dos Reis 2004-01-22 08:46:00 UTC
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
Comment 4 GCC Commits 2004-09-27 19:33:58 UTC
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

Comment 5 Andrew Pinski 2004-09-27 20:19:27 UTC
Fixed.