linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* address_space and noderef on non-pointer types
@ 2022-10-13 19:37 David Malcolm
  2022-10-13 23:21 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: David Malcolm @ 2022-10-13 19:37 UTC (permalink / raw)
  To: linux-sparse, linux-toolchains
  Cc: David Faust, Julia Lawall, Jose E. Marchesi, Elena Zannoni

Is it valid to apply the sparse attributes 'noderef' or 'address_space'
to non-pointers, and if so, what does this mean?

I see examples of using them on non-pointers in sparse's own test
suite.

For example, in:
https://git.kernel.org/pub/scm/devel/sparse/sparse.git/tree/validation/type-attribute-as.c
"struct s" is annotated with
  __attribute__((address_space(__as)))

Similarly, there's
https://git.kernel.org/pub/scm/devel/sparse/sparse.git/tree/validation/noderef.c#n18
where sparse accepts:
  struct x __A x;
e.g.:
  struct x __attribute__((noderef)) x;

The docs for noderef: 
https://git.kernel.org/pub/scm/devel/sparse/sparse.git/tree/Documentation/annotations.rst#n54
say:
"This attribute is to be used on a r-value to specify it cannot be
dereferenced. A pointer so annotated is in all other aspects exactly
like a pointer  but trying to actually access anything through it will
cause a warning."
What is the intended meaning of "noderef" for a non-pointer?

Similarly, the docs for "address_space" say:
"This attribute is to be used on pointers to specify that its target is
in address space *name* (an identifier or a constant integer)."

but don't specify what it means to use in on a non-pointer.

Sorry if this is a silly question.

The background here is that I'm a GCC developer and have been
experimenting with implementing some sparse attributes and warnings
"natively" in GCC; see e.g. the RFE in GCC bugzilla for implementing
address_space, noderef and force here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59850 ; I'm trying to get
my patched GCC to handle Sparse's own test suite and hence running into
this issue.

Thanks
Dave


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-13 23:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13 19:37 address_space and noderef on non-pointer types David Malcolm
2022-10-13 23:21 ` Linus Torvalds

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).