diff --git a/test/test.c b/test/test.c index 7bd1565..fbf91eb 100644 --- a/test/test.c +++ b/test/test.c @@ -259,3 +259,14 @@ UTEST(c, Near) { } UTEST(c, Todo) { UTEST_SKIP("Not yet implemented!"); } + +// TODO: TCC cannot handle comparing null opaque structs at all. +#if !defined(__TINYC__) +struct Opaque; + +UTEST(c, Opaque) { + struct Opaque *opaque = NULL; + EXPECT_EQ(NULL, opaque); + ASSERT_EQ(NULL, opaque); +} +#endif diff --git a/test/test11.c b/test/test11.c index c27c0cc..17f844b 100644 --- a/test/test11.c +++ b/test/test11.c @@ -251,3 +251,14 @@ UTEST(c11, Near) { } UTEST(c11, Todo) { UTEST_SKIP("Not yet implemented!"); } + +// TODO: TCC cannot handle comparing null opaque structs at all. +#if !defined(__TINYC__) +struct Opaque; + +UTEST(c11, Opaque) { + struct Opaque *opaque = NULL; + EXPECT_EQ(NULL, opaque); + ASSERT_EQ(NULL, opaque); +} +#endif diff --git a/test/test11.cpp b/test/test11.cpp index 67e8bcd..130eeed 100644 --- a/test/test11.cpp +++ b/test/test11.cpp @@ -343,3 +343,20 @@ UTEST(cpp11, Null) { } #endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +struct Opaque; + +UTEST(cpp11, Opaque) { + struct Opaque *opaque = nullptr; + EXPECT_EQ(nullptr, opaque); + ASSERT_EQ(nullptr, opaque); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/test/test14.cpp b/test/test14.cpp index 7e16797..a11f834 100644 --- a/test/test14.cpp +++ b/test/test14.cpp @@ -343,3 +343,20 @@ UTEST(cpp14, Null) { } #endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +struct Opaque; + +UTEST(cpp14, Opaque) { + struct Opaque *opaque = nullptr; + EXPECT_EQ(nullptr, opaque); + ASSERT_EQ(nullptr, opaque); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/test/test17.cpp b/test/test17.cpp index 3c09afa..84b58c1 100644 --- a/test/test17.cpp +++ b/test/test17.cpp @@ -343,3 +343,20 @@ UTEST(cpp17, Null) { } #endif + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +struct Opaque; + +UTEST(cpp17, Opaque) { + struct Opaque *opaque = nullptr; + EXPECT_EQ(nullptr, opaque); + ASSERT_EQ(nullptr, opaque); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/test/test99.c b/test/test99.c index 6f1d75a..30a9279 100644 --- a/test/test99.c +++ b/test/test99.c @@ -251,3 +251,14 @@ UTEST(c99, Near) { } UTEST(c99, Todo) { UTEST_SKIP("Not yet implemented!"); } + +// TODO: TCC cannot handle comparing null opaque structs at all. +#if !defined(__TINYC__) +struct Opaque; + +UTEST(c99, Opaque) { + struct Opaque *opaque = NULL; + EXPECT_EQ(NULL, opaque); + ASSERT_EQ(NULL, opaque); +} +#endif diff --git a/utest.h b/utest.h index 5dc25b1..88c119d 100644 --- a/utest.h +++ b/utest.h @@ -674,9 +674,7 @@ utest_type_printer(long long unsigned int i) { #if defined(__cplusplus) && (__cplusplus >= 201103L) #define UTEST_AUTO(x) auto -#elif !defined(__cplusplus) - -#if defined(__clang__) +#elif defined(__clang__) /* clang-format off */ /* had to disable clang-format here because it malforms the pragmas */ #define UTEST_AUTO(x) \ @@ -684,14 +682,12 @@ utest_type_printer(long long unsigned int i) { _Pragma("clang diagnostic ignored \"-Wgnu-auto-type\"") __auto_type \ _Pragma("clang diagnostic pop") /* clang-format on */ +#elif !defined(__clang__) && defined(__GNUC__) && !defined(__cplusplus) +#define UTEST_AUTO(x) __auto_type #else #define UTEST_AUTO(x) __typeof__(x + 0) #endif -#else -#define UTEST_AUTO(x) typeof(x + 0) -#endif - #if defined(__clang__) #define UTEST_STRNCMP(x, y, size) \ _Pragma("clang diagnostic push") \