aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/preprocessor
diff options
Diffstat (limited to 'validation/preprocessor')
-rw-r--r--validation/preprocessor/predef-sizeof.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/validation/preprocessor/predef-sizeof.c b/validation/preprocessor/predef-sizeof.c
new file mode 100644
index 00000000..12be2dd1
--- /dev/null
+++ b/validation/preprocessor/predef-sizeof.c
@@ -0,0 +1,25 @@
+#define TEST(X, T) if (__SIZEOF_ ## X ## __ != sizeof(T)) return 1
+
+int test_sizeof(void)
+{
+ TEST(SHORT, short);
+ TEST(INT, int);
+ TEST(LONG, long);
+ TEST(LONG_LONG, long long);
+ TEST(INT128, __int128);
+ TEST(SIZE_T, __SIZE_TYPE__);
+ TEST(POINTER, void*);
+ TEST(FLOAT, float);
+ TEST(DOUBLE, double);
+ TEST(LONG_DOUBLE, long double);
+
+ return 0;
+}
+
+/*
+ * check-name: predefined __SIZEOF_<type>__
+ * check-command: test-linearize -Wno-decl $file
+ * check-output-ignore
+ *
+ * check-output-contains: ret\\..*\\$0
+ */