[clang] 3cf9f2c - [C99] Claim conformance to WG14 N782

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 2 10:36:55 PDT 2024


Author: Aaron Ballman
Date: 2024-04-02T13:36:45-04:00
New Revision: 3cf9f2c3a4b3aaffa9c1dbbe34624bcaabefd390

URL: https://github.com/llvm/llvm-project/commit/3cf9f2c3a4b3aaffa9c1dbbe34624bcaabefd390
DIFF: https://github.com/llvm/llvm-project/commit/3cf9f2c3a4b3aaffa9c1dbbe34624bcaabefd390.diff

LOG: [C99] Claim conformance to WG14 N782

C89 has more restrictions on aggregate initialization that were relaxed
in C99. We started diagnosing the C89 extension in Clang 3.4.

Added: 
    clang/test/C/C99/n782.c

Modified: 
    clang/www/c_status.html

Removed: 
    


################################################################################
diff  --git a/clang/test/C/C99/n782.c b/clang/test/C/C99/n782.c
new file mode 100644
index 00000000000000..d147fd6fb1a1a2
--- /dev/null
+++ b/clang/test/C/C99/n782.c
@@ -0,0 +1,23 @@
+/* RUN: %clang_cc1 -verify -std=c99 -pedantic %s
+   RUN: %clang_cc1 -verify=c89 -std=c89 -pedantic %s
+   expected-no-diagnostics
+ */
+
+/* WG14 N782: Clang 3.4
+ * Relaxed constraints on aggregate and union initialization
+ */
+
+void test(void) {
+  struct S {
+    int x, y;
+  };
+  int a = 1, b = 2;
+  struct S s = { a, b }; /* c89-warning {{initializer for aggregate is not a compile-time constant}} */
+
+  union U {
+    int x;
+    float f;
+  };
+  union U u = { a }; /* c89-warning {{initializer for aggregate is not a compile-time constant}} */
+}
+

diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index a96232965a1e9d..62100611219e58 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -359,8 +359,8 @@ <h2 id="c99">C99 implementation status</h2>
     </tr>
     <tr>
       <td>relaxed constraints on aggregate and union initialization</td>
-      <td>Unknown</td>
-      <td class="unknown" align="center">Unknown</td>
+      <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n782.htm">N782</a></td>
+      <td class="full" align="center">Clang 3.4</td>
     </tr>
     <tr>
       <td>relaxed restrictions on portable header names</td>


        


More information about the cfe-commits mailing list