linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 3/5] C11: teach sparse about '_Alignof()'
Date: Thu,  5 Jan 2017 04:22:18 +0100	[thread overview]
Message-ID: <20170105032220.7339-4-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170105032220.7339-1-luc.vanoostenryck@gmail.com>

This is a new name for GCC's '__alignof()' operator which was
already supported.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 expression.c             |  1 +
 ident-list.h             |  1 +
 validation/c11-alignof.c | 12 ++++++++++++
 3 files changed, 14 insertions(+)
 create mode 100644 validation/c11-alignof.c

diff --git a/expression.c b/expression.c
index 7293d472..638639df 100644
--- a/expression.c
+++ b/expression.c
@@ -617,6 +617,7 @@ static struct token *unary_expression(struct token *token, struct expression **t
 				{ &sizeof_ident, EXPR_SIZEOF },
 				{ &__alignof___ident, EXPR_ALIGNOF },
 				{ &__alignof_ident, EXPR_ALIGNOF },
+				{ &_Alignof_ident, EXPR_ALIGNOF },
 				{ &__sizeof_ptr___ident, EXPR_PTRSIZEOF },
 			};
 			int i;
diff --git a/ident-list.h b/ident-list.h
index b65b667d..8cc66a50 100644
--- a/ident-list.h
+++ b/ident-list.h
@@ -31,6 +31,7 @@ IDENT(L);
 /* Extended gcc identifiers */
 IDENT(asm); IDENT_RESERVED(__asm); IDENT_RESERVED(__asm__);
 IDENT(alignof); IDENT_RESERVED(__alignof); IDENT_RESERVED(__alignof__); 
+IDENT_RESERVED(_Alignof);
 IDENT_RESERVED(__sizeof_ptr__);
 IDENT_RESERVED(__builtin_types_compatible_p);
 IDENT_RESERVED(__builtin_offsetof);
diff --git a/validation/c11-alignof.c b/validation/c11-alignof.c
new file mode 100644
index 00000000..238ef994
--- /dev/null
+++ b/validation/c11-alignof.c
@@ -0,0 +1,12 @@
+static int foo(void)
+{
+	return _Alignof(short);
+}
+
+/*
+ * check-name: c11-alignof
+ * check-command: test-linearize -std=c11 $file
+ *
+ * check-output-ignore
+ * check-output-contains: ret\\.32 *\$2
+ */
-- 
2.11.0


  parent reply	other threads:[~2017-01-05  3:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-05  3:22 [PATCH 0/5] add basic support for C11 Luc Van Oostenryck
2017-01-05  3:22 ` [PATCH 1/5] C11: teach sparse about '_Thread_local' Luc Van Oostenryck
2017-01-05  3:22 ` [PATCH 2/5] C11: teach sparse about '_Noreturn' Luc Van Oostenryck
2017-01-05  3:22 ` Luc Van Oostenryck [this message]
2017-01-05  3:22 ` [PATCH 4/5] C11: teach sparse about '_Alignas()' Luc Van Oostenryck
2017-01-05  3:22 ` [PATCH 5/5] C11: teach sparse about '--std={c11,gnu11}' Luc Van Oostenryck

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=20170105032220.7339-4-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --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).