linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: linux-sparse@vger.kernel.org
Subject: [PATCH] Improve error message if using a member of an incomplete struct or union
Date: Tue, 05 Jun 2007 18:01:46 -0400	[thread overview]
Message-ID: <20070605220145.5683.71073.stgit@dv.roinet.com> (raw)

sparse should distinguish two cases.  One is when the structure or union
is declared and the member is not found.  Another is when the structure
or union is not yet declared.  In the later case, the message should
indicate that the type is incomplete, rather than complain that the
particular member is not found.

Mention the incomplete type like gcc does, but provide the member name
too, it may be useful.

Signed-off-by: Pavel Roskin <proski@gnu.org>
---

 evaluate.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/evaluate.c b/evaluate.c
index 80ac7d1..f68b55e 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1723,8 +1723,13 @@ static struct symbol *evaluate_member_dereference(struct expression *expr)
 			name = ctype->ident->name;
 			namelen = ctype->ident->len;
 		}
-		expression_error(expr, "no member '%s' in %s %.*s",
-			show_ident(ident), type, namelen, name);
+		if (ctype->symbol_list)
+			expression_error(expr, "no member '%s' in %s %.*s",
+				show_ident(ident), type, namelen, name);
+		else
+			expression_error(expr, "using member '%s' in "
+				"incomplete %s %.*s", show_ident(ident),
+				type, namelen, name);
 		return NULL;
 	}
 

             reply	other threads:[~2007-06-05 22:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-05 22:01 Pavel Roskin [this message]
2007-06-09  7:26 ` [PATCH] Improve error message if using a member of an incomplete struct or union Josh Triplett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070605220145.5683.71073.stgit@dv.roinet.com \
    --to=proski@gnu.org \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).