Skip to content

Commit cb088e8

Browse files
committed
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".
1 parent 451b1ff commit cb088e8

File tree

3 files changed

+106
-9
lines changed

3 files changed

+106
-9
lines changed

clang/test/C/drs/dr324.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* RUN: %clang_cc1 -std=c89 -fsyntax-only -pedantic -verify %s
2+
RUN: %clang_cc1 -std=c99 -fsyntax-only -pedantic -verify %s
3+
RUN: %clang_cc1 -std=c11 -fsyntax-only -pedantic -verify %s
4+
RUN: %clang_cc1 -std=c17 -fsyntax-only -pedantic -verify %s
5+
RUN: %clang_cc1 -std=c2x -fsyntax-only -pedantic -verify %s
6+
*/
7+
8+
/* WG14 DR324: yes
9+
* Tokenization obscurities
10+
*/
11+
12+
/* We need to diagnose an unknown escape sequence in a string or character
13+
* literal, but not within a header-name terminal.
14+
*/
15+
const char *lit_str = "\y"; /* expected-warning {{unknown escape sequence '\y'}} */
16+
char lit_char = '\y'; /* expected-warning {{unknown escape sequence '\y'}} */
17+
18+
/* This gets trickier in a pragma where there are implementation-defined
19+
* locations that may use a header-name production. The first pragma below
20+
* is using \d but it's in a header-name use rather than a string-literal use.
21+
* The second pragma is a string-literal and so the \d is invalid there.
22+
*/
23+
#pragma GCC dependency "oops\..\dr0xx.c"
24+
#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}}
25+
expected-warning {{unknown escape sequence '\d'}}
26+
*/
27+
28+
/*
29+
* Note, this tests the behavior of a non-empty source file that ends with a
30+
* partial preprocessing token such as an unterminated string or character
31+
* literal. Thus, it is important that no code be added after this test case.
32+
*/
33+
/* expected-error@+3 {{expected identifier or '('}}
34+
expected-warning@+3 {{missing terminating ' character}}
35+
*/
36+
't

clang/test/C/drs/dr3xx.c

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
*
3232
* WG14 DR333: yes
3333
* Missing Predefined Macro Name
34+
*
35+
* WG14 DR342: dup 340
36+
* VLAs and conditional expressions
3437
*/
3538

3639

@@ -217,7 +220,7 @@ void dr335(void) {
217220
};
218221
}
219222

220-
/* WG14 DR339: partial
223+
/* WG14 DR339: dup 328
221224
* Variably modified compound literals
222225
*
223226
* 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
231234
c99andup-warning {{variable length array used}}
232235
c89only-warning {{compound literals are a C99-specific feature}}
233236
*/
237+
238+
/* WG14 DR340: yes
239+
* Composite types for variable-length arrays
240+
*
241+
* The DR made this behavior undefined because implementations disagreed on the
242+
* behavior. For this DR, Clang accepts the code and GCC rejects it. It's
243+
* unclear whether the Clang behavior is intentional, but because the code is
244+
* UB, any behavior is acceptable.
245+
*/
246+
#if __STDC_VERSION__ < 202000L
247+
void dr340(int x, int y) {
248+
typedef void (*T1)(int);
249+
typedef void (*T2)(); /* expected-warning {{a function declaration without a prototype is deprecated in all versions of C}} */
250+
251+
T1 (*a)[] = 0;
252+
T2 (*b)[x] = 0; /* c89only-warning {{variable length arrays are a C99 feature}}
253+
c99andup-warning {{variable length array used}}
254+
*/
255+
(y ? a : b)[0][0]();
256+
}
257+
#endif /* __STDC_VERSION__ < 202000L */
258+
259+
/* WG14 DR341: yes
260+
* [*] in abstract declarators
261+
*/
262+
void dr341_1(int (*)[*]); /* c89only-warning {{variable length arrays are a C99 feature}}
263+
c99andup-warning {{variable length array used}}
264+
*/
265+
void dr341_2(int (*)[sizeof(int (*)[*])]); /* expected-error {{star modifier used outside of function prototype}} */
266+
267+
/* WG14 DR343: yes
268+
* Initializing qualified wchar_t arrays
269+
*/
270+
void dr343(void) {
271+
const __WCHAR_TYPE__ x[] = L"foo";
272+
}
273+
274+
/* WG14 DR344: yes
275+
* Casts in preprocessor conditional expressions
276+
*
277+
* Note: this DR removed a constraint about not containing casts because there
278+
* are no keywords, therefore no types to cast to, so casts simply don't exist
279+
* as a construct during preprocessing.
280+
*/
281+
#if (int)+0
282+
#error "this should not be an error, we shouldn't get here"
283+
#else
284+
/* expected-error@+1 {{"reached"}} */
285+
#error "reached"
286+
#endif
287+
288+
/* WG14 DR345: yes
289+
* Where does parameter scope start?
290+
*/
291+
void f(long double f,
292+
char (**a)[10 * sizeof f]) {
293+
_Static_assert(sizeof **a == sizeof(long double) * 10, "");
294+
}

clang/www/c_dr_status.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ <h2 id="cdr">C defect report implementation status</h2>
18971897
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_324.htm">324</a></td>
18981898
<td>C99</td>
18991899
<td>Tokenization obscurities</td>
1900-
<td class="unknown" align="center">Unknown</td>
1900+
<td class="full" align="center">Yes</td>
19011901
</tr>
19021902
<tr id="325">
19031903
<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>
20002000
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_340.htm">340</a></td>
20012001
<td>C99</td>
20022002
<td>Composite types for variable-length arrays</td>
2003-
<td class="unknown" align="center">Unknown</td>
2003+
<td class="full" align="center">Yes</td>
20042004
</tr>
20052005
<tr id="341">
20062006
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_341.htm">341</a></td>
20072007
<td>C99</td>
20082008
<td>[*] in abstract declarators</td>
2009-
<td class="unknown" align="center">Unknown</td>
2009+
<td class="full" align="center">Yes</td>
20102010
</tr>
20112011
<tr id="342">
20122012
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_342.htm">342</a></td>
20132013
<td>Dup</td>
20142014
<td>VLAs and conditional expressions</td>
2015-
<td class="unknown" align="center">Duplicate of <a href="#340">340</a></td>
2015+
<td class="full" align="center">Duplicate of <a href="#340">340</a></td>
20162016
</tr>
20172017
<tr id="343">
20182018
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_343.htm">343</a></td>
20192019
<td>C99</td>
20202020
<td>Initializing qualified wchar_t arrays</td>
2021-
<td class="unknown" align="center">Unknown</td>
2021+
<td class="full" align="center">Yes</td>
20222022
</tr>
20232023
<tr id="344">
20242024
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_344.htm">344</a></td>
20252025
<td>C99</td>
20262026
<td>Casts in preprocessor conditional expressions</td>
2027-
<td class="unknown" align="center">Unknown</td>
2027+
<td class="full" align="center">Yes</td>
20282028
</tr>
20292029
<tr id="345">
20302030
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_345.htm">345</a></td>
2031-
<td>C11</td>
2031+
<td>C99</td>
20322032
<td>Where does parameter scope start?</td>
2033-
<td class="unknown" align="center">Unknown</td>
2033+
<td class="full" align="center">Yes</td>
20342034
</tr>
20352035
<tr id="400">
20362036
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2148.htm#dr_400">400</a></td>

0 commit comments

Comments
 (0)