[clang] cb088e8 - Add more C99 DR test cases and update the status page

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 25 08:14:59 PDT 2022


Author: Aaron Ballman
Date: 2022-10-25T11:14:52-04:00
New Revision: cb088e8c3abf30456e2891f90b5194d0070c387a

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

LOG: Add more C99 DR test cases and update the status page

This mostly completes the C99 set of DRs, though there are a few still
marked as "unknown".

Added: 
    clang/test/C/drs/dr324.c

Modified: 
    clang/test/C/drs/dr3xx.c
    clang/www/c_dr_status.html

Removed: 
    


################################################################################
diff  --git a/clang/test/C/drs/dr324.c b/clang/test/C/drs/dr324.c
new file mode 100644
index 0000000000000..a76e185c53020
--- /dev/null
+++ b/clang/test/C/drs/dr324.c
@@ -0,0 +1,36 @@
+/* RUN: %clang_cc1 -std=c89 -fsyntax-only -pedantic -verify %s
+   RUN: %clang_cc1 -std=c99 -fsyntax-only -pedantic -verify %s
+   RUN: %clang_cc1 -std=c11 -fsyntax-only -pedantic -verify %s
+   RUN: %clang_cc1 -std=c17 -fsyntax-only -pedantic -verify %s
+   RUN: %clang_cc1 -std=c2x -fsyntax-only -pedantic -verify %s
+ */
+
+/* WG14 DR324: yes
+ * Tokenization obscurities
+ */
+
+/* We need to diagnose an unknown escape sequence in a string or character
+ * literal, but not within a header-name terminal.
+ */
+const char *lit_str = "\y"; /* expected-warning {{unknown escape sequence '\y'}} */
+char lit_char = '\y';       /* expected-warning {{unknown escape sequence '\y'}} */
+
+/* This gets trickier in a pragma where there are implementation-defined
+ * locations that may use a header-name production. The first pragma below
+ * is using \d but it's in a header-name use rather than a string-literal use.
+ * The second pragma is a string-literal and so the \d is invalid there.
+ */
+#pragma GCC dependency "oops\..\dr0xx.c"
+#pragma message("this has a \t tab escape and an invalid \d escape") /* expected-warning {{this has a 	 tab escape and an invalid d escape}}
+                                                                        expected-warning {{unknown escape sequence '\d'}}
+                                                                      */
+
+/*
+ * Note, this tests the behavior of a non-empty source file that ends with a
+ * partial preprocessing token such as an unterminated string or character
+ * literal. Thus, it is important that no code be added after this test case.
+ */
+/* expected-error at +3 {{expected identifier or '('}}
+   expected-warning at +3 {{missing terminating ' character}}
+ */
+'t

diff  --git a/clang/test/C/drs/dr3xx.c b/clang/test/C/drs/dr3xx.c
index 61b8a163f0c0b..34ed95d9418d5 100644
--- a/clang/test/C/drs/dr3xx.c
+++ b/clang/test/C/drs/dr3xx.c
@@ -31,6 +31,9 @@
  *
  * WG14 DR333: yes
  * Missing Predefined Macro Name
+ *
+ * WG14 DR342: dup 340
+ * 	VLAs and conditional expressions
  */
 
 
@@ -217,7 +220,7 @@ void dr335(void) {
   };
 }
 
-/* WG14 DR339: partial
+/* WG14 DR339: dup 328
  * Variably modified compound literals
  *
  * This DR is marked as a duplicate of DR328, see that DR for further
@@ -231,3 +234,61 @@ void *dr339 = &(int (*)[dr339_v]){ 0 }; /* c89only-warning {{variable length arr
                                            c99andup-warning {{variable length array used}}
                                            c89only-warning {{compound literals are a C99-specific feature}}
                                          */
+
+/* WG14 DR340: yes
+ * Composite types for variable-length arrays
+ *
+ * The DR made this behavior undefined because implementations disagreed on the
+ * behavior. For this DR, Clang accepts the code and GCC rejects it. It's
+ * unclear whether the Clang behavior is intentional, but because the code is
+ * UB, any behavior is acceptable.
+ */
+#if __STDC_VERSION__ < 202000L
+void dr340(int x, int y) {
+  typedef void (*T1)(int);
+  typedef void (*T2)(); /* expected-warning {{a function declaration without a prototype is deprecated in all versions of C}} */
+
+  T1 (*a)[] = 0;
+  T2 (*b)[x] = 0;       /* c89only-warning {{variable length arrays are a C99 feature}}
+                           c99andup-warning {{variable length array used}}
+                         */
+  (y ? a : b)[0][0]();
+}
+#endif /* __STDC_VERSION__ < 202000L */
+
+/* WG14 DR341: yes
+ * [*] in abstract declarators
+ */
+void dr341_1(int (*)[*]);                  /* c89only-warning {{variable length arrays are a C99 feature}}
+                                              c99andup-warning {{variable length array used}}
+                                            */
+void dr341_2(int (*)[sizeof(int (*)[*])]); /* expected-error {{star modifier used outside of function prototype}} */
+
+/* WG14 DR343: yes
+ * Initializing qualified wchar_t arrays
+ */
+void dr343(void) {
+  const __WCHAR_TYPE__ x[] = L"foo";
+}
+
+/* WG14 DR344: yes
+ * Casts in preprocessor conditional expressions
+ *
+ * Note: this DR removed a constraint about not containing casts because there
+ * are no keywords, therefore no types to cast to, so casts simply don't exist
+ * as a construct during preprocessing.
+ */
+#if (int)+0
+#error "this should not be an error, we shouldn't get here"
+#else
+/* expected-error at +1 {{"reached"}} */
+#error "reached"
+#endif
+
+/* WG14 DR345: yes
+ * Where does parameter scope start?
+ */
+void f(long double f,
+       char (**a)[10 * sizeof f]) {
+  _Static_assert(sizeof **a == sizeof(long double) * 10, "");
+}

diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index a889e30f5bf45..667e0f668f57d 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -1897,7 +1897,7 @@ <h2 id="cdr">C defect report implementation status</h2>
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_324.htm">324</a></td>
     <td>C99</td>
     <td>Tokenization obscurities</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr id="325">
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_325.htm">325</a></td>
@@ -2000,37 +2000,37 @@ <h2 id="cdr">C defect report implementation status</h2>
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_340.htm">340</a></td>
     <td>C99</td>
     <td>Composite types for variable-length arrays</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr id="341">
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_341.htm">341</a></td>
     <td>C99</td>
     <td>[*] in abstract declarators</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr id="342">
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_342.htm">342</a></td>
     <td>Dup</td>
     <td>VLAs and conditional expressions</td>
-    <td class="unknown" align="center">Duplicate of <a href="#340">340</a></td>
+    <td class="full" align="center">Duplicate of <a href="#340">340</a></td>
   </tr>
   <tr id="343">
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_343.htm">343</a></td>
     <td>C99</td>
     <td>Initializing qualified wchar_t arrays</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr id="344">
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_344.htm">344</a></td>
     <td>C99</td>
     <td>Casts in preprocessor conditional expressions</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr id="345">
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_345.htm">345</a></td>
-    <td>C11</td>
+    <td>C99</td>
     <td>Where does parameter scope start?</td>
-    <td class="unknown" align="center">Unknown</td>
+    <td class="full" align="center">Yes</td>
   </tr>
   <tr id="400">
     <td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_400">400</a></td>


        


More information about the cfe-commits mailing list