All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsayjones.plus.com>
To: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	linux-sparse@vger.kernel.org
Cc: Jacob Keller <jacob.e.keller@intel.com>
Subject: Re: [PATCH v2 04/16] add testcases for type attributes
Date: Mon, 28 Dec 2020 16:13:54 +0000	[thread overview]
Message-ID: <f39438bd-3ab3-b827-a488-510b49351eb5@ramsayjones.plus.com> (raw)
In-Reply-To: <20201226175129.9621-5-luc.vanoostenryck@gmail.com>



On 26/12/2020 17:51, Luc Van Oostenryck wrote:
> Currently, type attributes are not handled correctly.
> 
> Add some testcases for them.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  validation/type-attribute-align.c | 20 ++++++++++++++++++
>  validation/type-attribute-as.c    | 34 +++++++++++++++++++++++++++++++
>  validation/type-attribute-mod.c   | 22 ++++++++++++++++++++
>  validation/type-attribute-qual.c  | 12 +++++++++++
>  4 files changed, 88 insertions(+)
>  create mode 100644 validation/type-attribute-align.c
>  create mode 100644 validation/type-attribute-as.c
>  create mode 100644 validation/type-attribute-mod.c
>  create mode 100644 validation/type-attribute-qual.c
> 
> diff --git a/validation/type-attribute-align.c b/validation/type-attribute-align.c
> new file mode 100644
> index 000000000000..d9358bff8327
> --- /dev/null
> +++ b/validation/type-attribute-align.c
> @@ -0,0 +1,20 @@
> +#define __aligned(N)	__attribute__((aligned(N)))
> +#define alignof(X)	__alignof__(X)
> +
> +struct s {
> +	short a, b, c;
> +} __aligned(2*sizeof(short));
> +
> +static int fs(void) { return  sizeof(struct s); }
> +static int fa(void) { return alignof(struct s); }
> +
> +void main(void)
> +{
> +	_Static_assert( sizeof(struct s) == 4 * sizeof(short), "size");
> +	_Static_assert(alignof(struct s) == 2 * sizeof(short), "alignment");
> +}
> +
> +/*
> + * check-name: type-attribute-align
> + * check-known-to-fail
> + */
> diff --git a/validation/type-attribute-as.c b/validation/type-attribute-as.c
> new file mode 100644
> index 000000000000..b40b4e7dddf5
> --- /dev/null
> +++ b/validation/type-attribute-as.c
> @@ -0,0 +1,34 @@
> +#define	__as		__attribute__((address_space(__as)))
> +
> +struct s {
> +	int i;
> +} __as;
> +
> +
> +extern void use0(void *);
> +extern void use1(void __as *);
> +
> +void main(void)
> +{
> +	struct s s;
> +	int i;
> +
> +	use0(&s);	// KO
> +	use0(&i);	// OK
> +	use1(&s);	// OK
> +	use1(&i);	// KO
> +}
> +
> +/*
> + * check-name: type-attribute-as
> + * check-known-to-fail
> + *
> + * check-error-start
> +type-attribute-as.c:16:15: warning: incorrect type in argument 1 (different address spaces)
> +type-attribute-as.c:16:15:    expected void *
> +type-attribute-as.c:16:15:    got struct s __as *
> +type-attribute-as.c:19:15: warning: incorrect type in argument 1 (different address spaces)
> +type-attribute-as.c:19:15:    expected void __as *
> +type-attribute-as.c:19:15:    got int *
> + * check-error-end
> + */
> diff --git a/validation/type-attribute-mod.c b/validation/type-attribute-mod.c
> new file mode 100644
> index 000000000000..0e7b166a4aec
> --- /dev/null
> +++ b/validation/type-attribute-mod.c
> @@ -0,0 +1,22 @@
> +#define	__noderef	__attribute__((noderef))
> +
> +struct s {
> +	int i;
> +} __noderef;
> +
> +
> +void main(void)
> +{
> +	struct s s;
> +
> +	s.i = 0;
> +}
> +
> +/*
> + * check-name: type-attribute-mod
> + * check-known-to-fail
> + *
> + * check-error-start
> +type-attribute-mod.c:12:9: warning: dereference of noderef expression
> + * check-error-end
> + */
> diff --git a/validation/type-attribute-qual.c b/validation/type-attribute-qual.c
> new file mode 100644
> index 000000000000..ab19a605bda1
> --- /dev/null
> +++ b/validation/type-attribute-qual.c
> @@ -0,0 +1,12 @@
> +static const struct s {
> +	int x;
> +} map[2];
> +
> +static void foo(struct s *p, int v)
> +{
> +	p->x += v;
> +}

Hmm, I don't understand what this is testing! :(

ATB,
Ramsay Jones

> +
> +/*
> + * check-name: type-attribute-qual
> + */
> 

  reply	other threads:[~2020-12-28 16:14 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-26 17:51 [PATCH 00/16] support __packed struct Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 01/16] add testcases for dubious enum values Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 02/16] add testcases for exotic " Luc Van Oostenryck
2020-12-28 16:10   ` Ramsay Jones
2020-12-28 20:00     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 03/16] add testcases for enum attributes Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 04/16] add testcases for type attributes Luc Van Oostenryck
2020-12-28 16:13   ` Ramsay Jones [this message]
2020-12-28 19:59     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 05/16] add testcases for packed structures Luc Van Oostenryck
2020-12-28 16:17   ` Ramsay Jones
2020-12-28 20:01     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 06/16] add testcases for packed bitfields Luc Van Oostenryck
2020-12-28 16:28   ` Ramsay Jones
2020-12-28 20:05     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 07/16] apply_ctype: use self-explanatory argument name Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 08/16] apply_ctype: reverse the order of arguments Luc Van Oostenryck
2020-12-28 16:47   ` Ramsay Jones
2020-12-28 20:37     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 09/16] apply_ctype: move up its declaration Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 10/16] struct-attr: prepare to handle attributes at the end of struct definitions (1) Luc Van Oostenryck
2020-12-28 16:54   ` Ramsay Jones
2020-12-28 20:49     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 11/16] struct-attr: prepare to handle attributes at the end of struct definitions (2) Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 12/16] struct-attr: prepare to handle attributes at the end of struct definitions (3) Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 13/16] struct-attr: fix type attribute like 'struct __attr { ... }' Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 14/16] struct-attr: fix: do not ignore struct/union/enum type attributes Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 15/16] packed: no out-of-bound access of packed bitfields Luc Van Oostenryck
2020-12-28 17:10   ` Ramsay Jones
2020-12-28 21:12     ` Luc Van Oostenryck
2020-12-26 17:51 ` [PATCH v2 16/16] packed: add support for __packed struct Luc Van Oostenryck
2020-12-28 17:18 ` [PATCH 00/16] support " Ramsay Jones
2020-12-28 21:33   ` Luc Van Oostenryck
2021-01-05 17:56     ` Jacob Keller
2021-01-05 20:39       ` Luc Van Oostenryck
2021-01-05 22:07         ` Jacob Keller
2021-01-05 17:55 ` Jacob Keller

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=f39438bd-3ab3-b827-a488-510b49351eb5@ramsayjones.plus.com \
    --to=ramsay@ramsayjones.plus.com \
    --cc=jacob.e.keller@intel.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.