linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* __attribute__((force)) should not be a storage class
@ 2014-02-01 18:49 Josh Triplett
  2014-02-02  5:51 ` Christopher Li
  0 siblings, 1 reply; 4+ messages in thread
From: Josh Triplett @ 2014-02-01 18:49 UTC (permalink / raw)
  To: linux-sparse; +Cc: Al Viro

Commit 3829c4d8b097776e6b3472290a9fae08a705ab7a ("Don't mix storage
class bits with ctype->modifiers while parsing type") in 2009 separated
storage classes from modifiers; in the process, it changed
__attribute__((force)) from a modifier to a storage class.  I don't
think it makes sense to have force as a storage class, for one critical
reason: storage classes are mutually exclusive.

$ cat /tmp/test.c
static __attribute__((force)) int *p;
static int q = *p;
$ ./sparse /tmp/test.c
/tmp/test.c:1:28: error: multiple storage classes

Given this, I think force should become a modifier again.  Any
objections?

- Josh Triplett

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

* Re: __attribute__((force)) should not be a storage class
  2014-02-01 18:49 __attribute__((force)) should not be a storage class Josh Triplett
@ 2014-02-02  5:51 ` Christopher Li
  2014-02-02  8:38   ` Josh Triplett
  0 siblings, 1 reply; 4+ messages in thread
From: Christopher Li @ 2014-02-02  5:51 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Linux-Sparse, Al Viro

On Sat, Feb 1, 2014 at 10:49 AM, Josh Triplett <josh@joshtriplett.org> wrote:
> Commit 3829c4d8b097776e6b3472290a9fae08a705ab7a ("Don't mix storage
> class bits with ctype->modifiers while parsing type") in 2009 separated
> storage classes from modifiers; in the process, it changed
> __attribute__((force)) from a modifier to a storage class.  I don't
> think it makes sense to have force as a storage class, for one critical
> reason: storage classes are mutually exclusive.

I am not convinced yet.

The current usage case for attribute "force" is to silence the type
mismatch during the type conversion. For variable declaration, there is
not need to silence any mismatch because there is no type conversion.

What you are purposing here is a new usage case. Do you want
to silence every single type mismatch in every assignment to that
variable? How about assignment from that variable?

That seems a lot of complexity to keep track of the attribute
belong to which level of the type tree.

>
> $ cat /tmp/test.c
> static __attribute__((force)) int *p;
> static int q = *p;

In this example, the attribute "force" is not needed.
I think it compiles fine without forcing it. The "force" don't
actually do any thing. So why do we want to support this?

I want to justify the extra complexity it add to the code
base.

Chris

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

* Re: __attribute__((force)) should not be a storage class
  2014-02-02  5:51 ` Christopher Li
@ 2014-02-02  8:38   ` Josh Triplett
  2014-02-27 21:00     ` Christopher Li
  0 siblings, 1 reply; 4+ messages in thread
From: Josh Triplett @ 2014-02-02  8:38 UTC (permalink / raw)
  To: Christopher Li; +Cc: Linux-Sparse, Al Viro

On Sat, Feb 01, 2014 at 09:51:11PM -0800, Christopher Li wrote:
> On Sat, Feb 1, 2014 at 10:49 AM, Josh Triplett <josh@joshtriplett.org> wrote:
> > Commit 3829c4d8b097776e6b3472290a9fae08a705ab7a ("Don't mix storage
> > class bits with ctype->modifiers while parsing type") in 2009 separated
> > storage classes from modifiers; in the process, it changed
> > __attribute__((force)) from a modifier to a storage class.  I don't
> > think it makes sense to have force as a storage class, for one critical
> > reason: storage classes are mutually exclusive.
> 
> I am not convinced yet.
> 
> The current usage case for attribute "force" is to silence the type
> mismatch during the type conversion. For variable declaration, there is
> not need to silence any mismatch because there is no type conversion.
> 
> What you are purposing here is a new usage case. Do you want
> to silence every single type mismatch in every assignment to that
> variable? How about assignment from that variable?

I'd suggest that either it should have exactly the same behavior as it does
when applied to the type of a function argument (suppressing
Sparse-specific pointer qualifier mismatches on input), or it should be
prohibited entirely on standalone variable declarations.  I'd be fine
with the latter, if you prefer.

> > $ cat /tmp/test.c
> > static __attribute__((force)) int *p;
> > static int q = *p;
> 
> In this example, the attribute "force" is not needed.
> I think it compiles fine without forcing it. The "force" don't
> actually do any thing. So why do we want to support this?

This particular case was simply an unrelated test case which happened to
trigger the error about having multiple storage classes.  The original
test case came from http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59850#c3
; I noticed the use of -Wno-decl, presumably to suppress the warnings
about the two variables not being static, so I marked them as static and
got the error that motivated this thread.

- Josh Triplett

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

* Re: __attribute__((force)) should not be a storage class
  2014-02-02  8:38   ` Josh Triplett
@ 2014-02-27 21:00     ` Christopher Li
  0 siblings, 0 replies; 4+ messages in thread
From: Christopher Li @ 2014-02-27 21:00 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Linux-Sparse, Al Viro

On Sun, Feb 2, 2014 at 12:38 AM, Josh Triplett <josh@joshtriplett.org> wrote:
> I'd suggest that either it should have exactly the same behavior as it does
> when applied to the type of a function argument (suppressing
> Sparse-specific pointer qualifier mismatches on input), or it should be
> prohibited entirely on standalone variable declarations.  I'd be fine
> with the latter, if you prefer.

BTW, patch are welcome to make it consistent, hopefully in a not too
complicate way.

Chris

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

end of thread, other threads:[~2014-02-27 21:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-01 18:49 __attribute__((force)) should not be a storage class Josh Triplett
2014-02-02  5:51 ` Christopher Li
2014-02-02  8:38   ` Josh Triplett
2014-02-27 21:00     ` Christopher Li

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