Update statuses and add tests for C89 DRs

This mostly finishes the DRs for C89, though there are still a few
outliers which remain. It also corrects some of the statuses of DRs
where it's not clear if it was fully resolved by the committee or not.

As a drive-by, it also adds -fsyntax-only to the tests which are
verifying diagnostic results. This was previously missed by accident.
This commit is contained in:
Aaron Ballman 2022-06-28 10:27:26 -04:00
parent a1df636a8b
commit 313f9cd81d
5 changed files with 148 additions and 31 deletions

View File

@ -1,9 +1,9 @@
/* RUN: %clang_cc1 -std=c89 -verify=expected,c89only -pedantic -Wno-declaration-after-statement -Wno-c11-extensions %s
RUN: %clang_cc1 -std=c89 -verify=expected,c89only -pedantic -Wno-declaration-after-statement -Wno-c11-extensions -fno-signed-char %s
RUN: %clang_cc1 -std=c99 -verify=expected,c99untilc2x -pedantic -Wno-c11-extensions %s
RUN: %clang_cc1 -std=c11 -verify=expected,c99untilc2x -pedantic %s
RUN: %clang_cc1 -std=c17 -verify=expected,c99untilc2x -pedantic %s
RUN: %clang_cc1 -std=c2x -verify=expected,c2xandup -pedantic %s
/* RUN: %clang_cc1 -std=c89 -fsyntax-only -verify=expected,c89only -pedantic -Wno-declaration-after-statement -Wno-c11-extensions %s
RUN: %clang_cc1 -std=c89 -fsyntax-only -verify=expected,c89only -pedantic -Wno-declaration-after-statement -Wno-c11-extensions -fno-signed-char %s
RUN: %clang_cc1 -std=c99 -fsyntax-only -verify=expected,c99untilc2x -pedantic -Wno-c11-extensions %s
RUN: %clang_cc1 -std=c11 -fsyntax-only -verify=expected,c99untilc2x -pedantic %s
RUN: %clang_cc1 -std=c17 -fsyntax-only -verify=expected,c99untilc2x -pedantic %s
RUN: %clang_cc1 -std=c2x -fsyntax-only -verify=expected,c2xandup -pedantic %s
*/
/* The following are DRs which do not require tests to demonstrate

45
clang/test/C/drs/dr157.c Normal file
View File

@ -0,0 +1,45 @@
/* 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 DR157: yes
* Legitimacy of type synonyms
*
* Part 1 is about whether you can use a typedef to void in place of void in
* a function parameter list and still get a function with a prototype that
* accepts no arguments. You can.
*
* Part 2 is about whether you can use a typedef to int in place of int in
* the declaration of main(). You can.
*
* Part 3 is about whether there are situations where a typedef cannot be used
* in place of a type name.
*/
typedef void dr157_1_t;
extern int dr157(dr157_1_t); /* ok */
int dr157(dr157_1_t) { /* ok */
/* You cannot combine a typedef with another type specifier. */
typedef int Int; /* expected-note {{previous definition is here}} */
long Int val; /* expected-error {{redefinition of 'Int' as different kind of symbol}}
expected-error {{expected ';' at end of declaration}}
*/
return 0;
}
typedef int dr157_2_t;
dr157_2_t main(void) { /* Still a valid declaration of main() */
}
/* A function definition cannot use a typedef for the type. */
typedef void dr157_3_t(void);
extern dr157_3_t dr157_2 { /* expected-error {{expected ';' after top level declarator}} */
}
/* FIXME: all diagnostics that happen after the previous one about expecting a
* a ';' are silenced, so this test needs to be in its own file to prevent
* accidentally incorrect testing.
*/

22
clang/test/C/drs/dr158.c Normal file
View File

@ -0,0 +1,22 @@
/* RUN: %clang_cc1 -std=c89 -pedantic -Wno-c11-extensions -verify -emit-llvm -o - %s | FileCheck %s
RUN: %clang_cc1 -std=c99 -pedantic -Wno-c11-extensions -verify -emit-llvm -o - %s | FileCheck %s
RUN: %clang_cc1 -std=c11 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
RUN: %clang_cc1 -std=c17 -pedantic -verify -emit-llvm -o - %s | FileCheck %s
RUN: %clang_cc1 -std=c2x -pedantic -verify -emit-llvm -o - %s | FileCheck %s
*/
/* expected-no-diagnostics */
/* WG14 DR158: yes
* Null pointer conversions
*/
void dr158(void) {
int Val = (void *)0 == (int *)0;
/* CHECK: %[[VAL:.+]] = alloca i32
CHECK: store i32 1, ptr %[[VAL]]
*/
(void)_Generic((int *)0, int * : 1); /* picks correct association */
(void)_Generic((1 ? 0 : (int *)0), int * : 1); /* picks correct association */
}

View File

@ -1,8 +1,8 @@
/* RUN: %clang_cc1 -std=c89 -verify=expected,c89only -pedantic -Wno-c11-extensions %s
RUN: %clang_cc1 -std=c99 -verify=expected,c99untilc2x -pedantic -Wno-c11-extensions %s
RUN: %clang_cc1 -std=c11 -verify=expected,c99untilc2x -pedantic %s
RUN: %clang_cc1 -std=c17 -verify=expected,c99untilc2x -pedantic %s
RUN: %clang_cc1 -std=c2x -verify=expected,c2xandup -pedantic %s
/* RUN: %clang_cc1 -std=c89 -fsyntax-only -verify=expected,c89only -pedantic -Wno-c11-extensions %s
RUN: %clang_cc1 -std=c99 -fsyntax-only -verify=expected,c99untilc2x -pedantic -Wno-c11-extensions %s
RUN: %clang_cc1 -std=c11 -fsyntax-only -verify=expected,c99untilc2x -pedantic %s
RUN: %clang_cc1 -std=c17 -fsyntax-only -verify=expected,c99untilc2x -pedantic %s
RUN: %clang_cc1 -std=c2x -fsyntax-only -verify=expected,c2xandup -pedantic %s
*/
/* The following are DRs which do not require tests to demonstrate
@ -49,6 +49,28 @@
*
* WG14 DR146: yes
* Nugatory constraint
*
* WG14 DR147: yes
* Sequence points in library functions
*
* WG14 DR148: yes
* Defining library functions
*
* WG14 DR149: yes
* The term "variable"
*
* WG14 DR154: yes
* Consistency of implementation-defined values
*
* WG14 DR159: yes
* Consistency of the C Standard Defects exist in the way the Standard refers
* to itself
*
* WG14 DR161: yes
* Details of reserved symbols
*
* WG14 DR169: yes
* Trigraphs
*/
@ -331,3 +353,31 @@ void dr145(void) {
* static int i = array[0] + array[1]; broken-expected-error {{initializer element is not a compile-time constant}}
*/
}
/* WG14 DR150: yes
* Initialization of a char array from a string literal
*/
void dr150(void) {
/* Accept even though a string literal is not a constant expression. */
static char array[] = "Hello, World";
}
/* WG14 DR163: yes
* Undeclared identifiers
*/
void dr163(void) {
int i;
i = undeclared; /* expected-error {{use of undeclared identifier 'undeclared'}} */
sdfsdfsf = 1; /* expected-error {{use of undeclared identifier 'sdfsdfsf'}} */
i = also_undeclared(); /* c99untilc2x-error {{call to undeclared function 'also_undeclared'; ISO C99 and later do not support implicit function declarations}}
c2xandup-error {{use of undeclared identifier 'also_undeclared'}}
*/
}
/* WG14 DR164: yes
* Bad declarations
*/
void dr164(void) {
int a [][5]; /* expected-error {{definition of variable with array type needs an explicit size or an initializer}} */
int x, b [][5]; /* expected-error {{definition of variable with array type needs an explicit size or an initializer}} */
}

View File

@ -937,25 +937,25 @@ conformance.</p>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_147.html">147</a></td>
<td>C89</td>
<td>Sequence points in library functions</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="148">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_148.html">148</a></td>
<td>NAD</td>
<td>Defining library functions</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="149">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_149.html">149</a></td>
<td>C89</td>
<td>The term "variable"</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="150">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_150.html">150</a></td>
<td>C89</td>
<td>Initialization of a char array from a string literal</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="151">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_151.html">151</a></td>
@ -979,7 +979,7 @@ conformance.</p>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_154.html">154</a></td>
<td>NAD</td>
<td>Consistency of implementation-defined values</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="155">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_155.html">155</a></td>
@ -997,31 +997,31 @@ conformance.</p>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_157.html">157</a></td>
<td>C89</td>
<td>Legitimacy of type synonyms</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="158">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_158.html">158</a></td>
<td>C89</td>
<td>Null pointer conversions</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="159">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_159.html">159</a></td>
<td>C89</td>
<td>Consistency of the C Standard Defects exist in the way the Standard refers to itself</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="160">
<tr class="open" id="160">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_160.html">160</a></td>
<td>C89</td>
<td>Open</td>
<td>Reservation of identifiers</td>
<td class="unknown" align="center">Unknown</td>
<td align="center">Not resolved</td>
</tr>
<tr id="161">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_161.html">161</a></td>
<td>NAD</td>
<td>Details of reserved symbols</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="162">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_162.html">162</a></td>
@ -1033,19 +1033,19 @@ conformance.</p>
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_163.html">163</a></td>
<td>C89</td>
<td>Undeclared identifiers</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="164">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_164.html">164</a></td>
<td>NAD</td>
<td>Bad declarations</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="165">
<tr class="open" id="165">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_165.html">165</a></td>
<td>C89</td>
<td>Tags and incomplete types</td>
<td class="unknown" align="center">Unknown</td>
<td align="center">Not resolved</td>
</tr>
<tr class="open" id="166">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_166.html">166</a></td>
@ -1067,15 +1067,15 @@ conformance.</p>
</tr>
<tr id="169">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_169.html">169</a></td>
<td>C89</td>
<td>NAD</td>
<td>Trigraphs</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr id="170">
<tr class="open" id="170">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_170.html">170</a></td>
<td>C89</td>
<td>Operators and punctuators</td>
<td class="unknown" align="center">Unknown</td>
<td align="center">Not resolved</td>
</tr>
<tr class="open" id="171">
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_171.html">171</a></td>