From 313f9cd81d01a3a63d3cdc94ee13b21117b2b3bd Mon Sep 17 00:00:00 2001
From: Aaron Ballman
Date: Tue, 28 Jun 2022 10:27:26 -0400
Subject: [PATCH] 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.
---
clang/test/C/drs/dr0xx.c | 12 ++++----
clang/test/C/drs/dr157.c | 45 ++++++++++++++++++++++++++++
clang/test/C/drs/dr158.c | 22 ++++++++++++++
clang/test/C/drs/dr1xx.c | 60 ++++++++++++++++++++++++++++++++++----
clang/www/c_dr_status.html | 40 ++++++++++++-------------
5 files changed, 148 insertions(+), 31 deletions(-)
create mode 100644 clang/test/C/drs/dr157.c
create mode 100644 clang/test/C/drs/dr158.c
diff --git a/clang/test/C/drs/dr0xx.c b/clang/test/C/drs/dr0xx.c
index 522f36c7141f..3502efefa081 100644
--- a/clang/test/C/drs/dr0xx.c
+++ b/clang/test/C/drs/dr0xx.c
@@ -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
diff --git a/clang/test/C/drs/dr157.c b/clang/test/C/drs/dr157.c
new file mode 100644
index 000000000000..64feed5402e6
--- /dev/null
+++ b/clang/test/C/drs/dr157.c
@@ -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.
+ */
diff --git a/clang/test/C/drs/dr158.c b/clang/test/C/drs/dr158.c
new file mode 100644
index 000000000000..45778bda8839
--- /dev/null
+++ b/clang/test/C/drs/dr158.c
@@ -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 */
+}
+
diff --git a/clang/test/C/drs/dr1xx.c b/clang/test/C/drs/dr1xx.c
index cbcc0524105f..70435b523765 100644
--- a/clang/test/C/drs/dr1xx.c
+++ b/clang/test/C/drs/dr1xx.c
@@ -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}} */
+}
diff --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index c00fd511ef41..e6e339d5f18c 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -937,25 +937,25 @@ conformance.
147 |
C89 |
Sequence points in library functions |
- Unknown |
+ Yes |
148 |
NAD |
Defining library functions |
- Unknown |
+ Yes |
149 |
C89 |
The term "variable" |
- Unknown |
+ Yes |
150 |
C89 |
Initialization of a char array from a string literal |
- Unknown |
+ Yes |
151 |
@@ -979,7 +979,7 @@ conformance.
154 |
NAD |
Consistency of implementation-defined values |
- Unknown |
+ Yes |
155 |
@@ -997,31 +997,31 @@ conformance.
157 |
C89 |
Legitimacy of type synonyms |
- Unknown |
+ Yes |
158 |
C89 |
Null pointer conversions |
- Unknown |
+ Yes |
159 |
C89 |
Consistency of the C Standard Defects exist in the way the Standard refers to itself |
- Unknown |
+ Yes |
-
+
160 |
- C89 |
+ Open |
Reservation of identifiers |
- Unknown |
+ Not resolved |
161 |
NAD |
Details of reserved symbols |
- Unknown |
+ Yes |
162 |
@@ -1033,19 +1033,19 @@ conformance.
163 |
C89 |
Undeclared identifiers |
- Unknown |
+ Yes |
164 |
NAD |
Bad declarations |
- Unknown |
+ Yes |
-
+
165 |
C89 |
Tags and incomplete types |
- Unknown |
+ Not resolved |
166 |
@@ -1067,15 +1067,15 @@ conformance.
169 |
- C89 |
+ NAD |
Trigraphs |
- Unknown |
+ Yes |
-
+
170 |
C89 |
Operators and punctuators |
- Unknown |
+ Not resolved |
171 |