diff mbox series

Prevent redefinition of WCHAR_MAX from testsuite/gcc.dg/cpp/ucs.c

Message ID 03A7A414-9168-4FDA-A31B-C6927D5E82D8@adacore.com
State New
Headers show
Series Prevent redefinition of WCHAR_MAX from testsuite/gcc.dg/cpp/ucs.c | expand

Commit Message

Olivier Hainque Dec. 20, 2019, 5:27 p.m. UTC
Hello,

gcc/testsuite/gcc.dg/cpp/ucs.c #include <limits.h>
and then crafts a definition of WCHAR_MAX depending
on __WCHAR_TYPE__.

The test fails in VxWorks configurations because WCHAR_MAX
is already exposed by the system limits.h.

The attached patch simply guards the tentative definition
by a check verifying if the macro is defined already, so
we're using the value exposed by limits.h in this case.

This allows the test to pass on the configurations where
we saw it failing, and bootstrap+regtest fine on x86_64-linux.

Ok to commit ?

Thanks in advance,

With Kind Regards,

Olivier


2019-12-20  Olivier Hainque  <hainque@adacore.com>

	* testsuite/gcc.dg/cpp/ucs.c: Prevent redefinition
	of WCHAR_MAX if already exposed by limits.h.
gcc/testsuite/gcc.dg/cpp/ucs.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Mike Stump Dec. 21, 2019, 1:41 a.m. UTC | #1
On Dec 20, 2019, at 9:27 AM, Olivier Hainque <hainque@adacore.com> wrote:
> gcc/testsuite/gcc.dg/cpp/ucs.c #include <limits.h>
> and then crafts a definition of WCHAR_MAX depending
> on __WCHAR_TYPE__.

> Ok to commit ?

Ok.
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/cpp/ucs.c b/gcc/testsuite/gcc.dg/cpp/ucs.c
index cac83f3cf14..f52cd571258 100644
--- a/gcc/testsuite/gcc.dg/cpp/ucs.c
+++ b/gcc/testsuite/gcc.dg/cpp/ucs.c
@@ -16,6 +16,8 @@ 
 #define short           +2 
 #define long            +3
 
+#if !defined(WCHAR_MAX)
+
 #if __WCHAR_TYPE__ == 0
 # define WCHAR_MAX      INT_MAX
 #elif __WCHAR_TYPE__ == 1
@@ -28,6 +30,8 @@ 
 # error wacky wchar_t
 #endif
 
+#endif
+
 #undef unsigned
 #undef int
 #undef char