linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ftp.linux.org.uk>
To: Pavel Roskin <proski@gnu.org>
Cc: linux-sparse@vger.kernel.org
Subject: Re: Structures from -include are "weak"
Date: Sun, 8 Jul 2007 07:06:09 +0100	[thread overview]
Message-ID: <20070708060609.GE21668@ftp.linux.org.uk> (raw)
In-Reply-To: <20070708054218.GD21668@ftp.linux.org.uk>

On Sun, Jul 08, 2007 at 06:42:18AM +0100, Al Viro wrote:
> {
> 	struct st;
> 	struct st *p;
> 	...
> 	struct st {....} x;
> 	...
> }
> 
> will make p a pointer to struct st from that scope.  If you omit it,
> p will be a pointer to struct st from the outer scope and x will have
> a different type.  Too late beginning of file scope, perhaps?

Gyah...  So it is.  We put the stuff from -include into builtin_scope
and start the file scope only in __sparse().

See if adding
int is_outer_scope(struct scope *scope)
{
	if (scope == block_scope)
		return 0;
	if (scope == &builtin_scope && block_scope->next == &builtin_scope)
		return 0;
	return 1;
}
to scope.c and replacing
		sym = lookup_symbol(token->ident, NS_STRUCT);
		if (!sym ||
		    (sym->scope != block_scope &&
		     (match_op(token->next,';') || match_op(token->next,'{')))) {
with
		sym = lookup_symbol(token->ident, NS_STRUCT);
		if (!sym ||
		    (is_outer_scope(sym->scope) &&
		     (match_op(token->next,';') || match_op(token->next,'{')))) {
in parse.c:struct_union_enum_specifier() would fix all problems of that kind.

  reply	other threads:[~2007-07-08  6:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-08  3:32 Structures from -include are "weak" Pavel Roskin
2007-07-08  5:42 ` Al Viro
2007-07-08  6:06   ` Al Viro [this message]
2007-07-08  6:25     ` Pavel Roskin

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=20070708060609.GE21668@ftp.linux.org.uk \
    --to=viro@ftp.linux.org.uk \
    --cc=linux-sparse@vger.kernel.org \
    --cc=proski@gnu.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).