public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] stdckdint.h _BitInt test
@ 2023-08-10 15:39 Jakub Jelinek
  2023-08-10 22:31 ` Joseph Myers
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2023-08-10 15:39 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches

Hi!

The following patch (on top of the stdckdint.h patch and _BitInt patch
series) adds a test for _BitInt diagnostics of ckd_{add,sub,mul} macros.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2023-08-10  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/stdckdint-3.c: New test.

--- gcc/testsuite/gcc.dg/stdckdint-3.c.jj	2023-08-10 13:02:10.520431079 +0200
+++ gcc/testsuite/gcc.dg/stdckdint-3.c	2023-08-10 13:03:41.352129959 +0200
@@ -0,0 +1,21 @@
+/* Test C23 Checked Integer Arithmetic macros in <stdckdint.h>.  */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-std=c2x" } */
+
+#include <stdckdint.h>
+
+int
+main ()
+{
+  _BitInt(32) a;
+  int b;
+  ckd_add (&a, 1, 1);		/* { dg-error "types used in ckd_add should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+  ckd_sub (&a, 1, 1);		/* { dg-error "types used in ckd_sub should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+  ckd_mul (&a, 1, 1);		/* { dg-error "types used in ckd_mul should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+  ckd_add (&b, 1wb, 1);		/* { dg-error "types used in ckd_add should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+  ckd_sub (&b, 1wb, 1);		/* { dg-error "types used in ckd_sub should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+  ckd_mul (&b, 1wb, 1);		/* { dg-error "types used in ckd_mul should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+  ckd_add (&b, 1, 1wb);		/* { dg-error "types used in ckd_add should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+  ckd_sub (&b, 1, 1wb);		/* { dg-error "types used in ckd_sub should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+  ckd_mul (&b, 1, 1wb);		/* { dg-error "types used in ckd_mul should be integral other than plain char, bool, bit-precise integer or enumerated type" } */
+}

	Jakub


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

end of thread, other threads:[~2023-08-11 21:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-10 15:39 [PATCH] stdckdint.h _BitInt test Jakub Jelinek
2023-08-10 22:31 ` Joseph Myers
2023-08-11  8:09   ` [PATCH] c, v3: Add stdckdint.h header for C23 Jakub Jelinek
2023-08-11 13:25     ` Joseph Myers
2023-08-11 17:31       ` [PATCH] c, v4: " Jakub Jelinek
2023-08-11 21:50         ` Joseph Myers

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 read-only IMAP folder(s) and NNTP newsgroup(s).