From 0f6b030b767deeff8833998f629202b690efe4af Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.maroneze@cea.fr>
Date: Mon, 4 Nov 2024 17:43:48 +0100
Subject: [PATCH] [tests] add test case for empty union with initializer

---
 tests/syntax/empty_union.i                   |  8 ++++++++
 tests/syntax/oracle/empty_union.0.res.oracle |  7 +++++++
 tests/syntax/oracle/empty_union.1.res.oracle | 10 ++++++++++
 3 files changed, 25 insertions(+)
 create mode 100644 tests/syntax/empty_union.i
 create mode 100644 tests/syntax/oracle/empty_union.0.res.oracle
 create mode 100644 tests/syntax/oracle/empty_union.1.res.oracle

diff --git a/tests/syntax/empty_union.i b/tests/syntax/empty_union.i
new file mode 100644
index 0000000000..e941af4a43
--- /dev/null
+++ b/tests/syntax/empty_union.i
@@ -0,0 +1,8 @@
+/* run.config*
+   STDOPT: +"-machdep gcc_x86_32"
+ EXIT: 1
+   STDOPT:
+ */
+
+// based on GCC's 'torture' test suite
+union empty {} eu = {};
diff --git a/tests/syntax/oracle/empty_union.0.res.oracle b/tests/syntax/oracle/empty_union.0.res.oracle
new file mode 100644
index 0000000000..d977ab5bcc
--- /dev/null
+++ b/tests/syntax/oracle/empty_union.0.res.oracle
@@ -0,0 +1,7 @@
+[kernel] Parsing empty_union.i (no preprocessing)
+/* Generated by Frama-C */
+union empty {
+   
+};
+union empty eu = ;
+
diff --git a/tests/syntax/oracle/empty_union.1.res.oracle b/tests/syntax/oracle/empty_union.1.res.oracle
new file mode 100644
index 0000000000..09d71d5930
--- /dev/null
+++ b/tests/syntax/oracle/empty_union.1.res.oracle
@@ -0,0 +1,10 @@
+[kernel] Parsing empty_union.i (no preprocessing)
+[kernel] empty_union.i:8: User Error: 
+  empty unions only allowed for GCC/MSVC machdeps; see option -machdep or run 'frama-c -machdep help' for the list of available machdeps
+[kernel] empty_union.i:8: User Error: 
+  empty initializers only allowed for GCC/MSVC machdeps; see option -machdep or run 'frama-c -machdep help' for the list of available machdeps
+  6     
+  7     // based on GCC's 'torture' test suite
+  8     union empty {} eu = {};
+                       ^^
+[kernel] Frama-C aborted: invalid user input.
-- 
GitLab