bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bool and C23


From: Bruno Haible
Subject: Re: bool and C23
Date: Sat, 10 Sep 2022 20:06:09 +0200

Paul Eggert wrote:
> Thanks for catching that doc bug. I installed into Gnulib the stdbool 
> patches with a fix for that

The C++ tests are strangely organized now. I'm committing this patch, so
that both 'stdbool' and 'stdbool-c99' have their respective C++ tests.


2022-09-10  Bruno Haible  <bruno@clisp.org>

        Reorganize C++ tests for stdbool and stdbool-c99.
        * tests/test-stdbool-c++.cc: Don't include <stdbool.h> if TEST_STDBOOL_H
        is not defined. Add a couple of simple tests, from test-stdbool.c.
        * tests/test-stdbool-c99-c++.cc: New file.
        * modules/stdbool-c99-c++-tests: New file, based on
        modules/stdbool-c++-tests.
        * modules/stdbool-c99-tests (Depends-on): Add stdbool-c99-c++-tests.
        Remove stdbool-c++-tests.
        * modules/stdbool-tests (Depends-on): Add stdbool-c++-tests.

diff --git a/modules/stdbool-c99-c++-tests b/modules/stdbool-c99-c++-tests
new file mode 100644
index 0000000000..073ef893c4
--- /dev/null
+++ b/modules/stdbool-c99-c++-tests
@@ -0,0 +1,19 @@
+Files:
+tests/test-stdbool-c99-c++.cc
+tests/test-stdbool-c++.cc
+tests/test-stdbool-c++2.cc
+
+Status:
+c++-test
+
+Depends-on:
+ansi-c++-opt
+
+configure.ac:
+
+Makefile.am:
+if ANSICXX
+TESTS += test-stdbool-c99-c++
+check_PROGRAMS += test-stdbool-c99-c++
+test_stdbool_c99_c___SOURCES = test-stdbool-c99-c++.cc test-stdbool-c++2.cc
+endif
diff --git a/modules/stdbool-c99-tests b/modules/stdbool-c99-tests
index 3ca0ddb217..e507f9493a 100644
--- a/modules/stdbool-c99-tests
+++ b/modules/stdbool-c99-tests
@@ -1,9 +1,9 @@
 Files:
-tests/test-stdbool.c
 tests/test-stdbool-c99.c
+tests/test-stdbool.c
 
 Depends-on:
-stdbool-c++-tests
+stdbool-c99-c++-tests
 
 configure.ac:
 
diff --git a/modules/stdbool-tests b/modules/stdbool-tests
index 6905dfbedc..0f875fbeed 100644
--- a/modules/stdbool-tests
+++ b/modules/stdbool-tests
@@ -2,6 +2,7 @@ Files:
 tests/test-stdbool.c
 
 Depends-on:
+stdbool-c++-tests
 
 configure.ac:
 
diff --git a/tests/test-stdbool-c++.cc b/tests/test-stdbool-c++.cc
index ae4f80b00f..8e208dfe23 100644
--- a/tests/test-stdbool-c++.cc
+++ b/tests/test-stdbool-c++.cc
@@ -19,7 +19,26 @@
 #define GNULIB_NAMESPACE gnulib
 #include <config.h>
 
-#include <stdbool.h>
+#ifdef TEST_STDBOOL_H
+# include <stdbool.h>
+#endif
+
+
+/* These tests are a subset of the C language tests in test-stdbool.c.  */
+
+#if false
+ "error: false is not 0"
+#endif
+#if true != 1
+ "error: true is not 1"
+#endif
+
+struct s { bool s: 1; bool t; } s;
+
+char a[true == 1 ? 1 : -1];
+char b[false == 0 ? 1 : -1];
+char c[(unsigned char) true == 1 ? 1 : -1];
+char d[(unsigned char) false == 0 ? 1 : -1];
 
 
 int
diff --git a/tests/test-stdbool-c99-c++.cc b/tests/test-stdbool-c99-c++.cc
new file mode 100644
index 0000000000..eec9e3b980
--- /dev/null
+++ b/tests/test-stdbool-c99-c++.cc
@@ -0,0 +1,2 @@
+#define TEST_STDBOOL_H
+#include "test-stdbool-c++.cc"






reply via email to

[Prev in Thread] Current Thread [Next in Thread]