Skip to content

Commit cbd48b1

Browse files
committed
[C99] Claim conformance to "conversion of array to pointer not limited to lvalues"
We don't have a document number for this, but the change was called out explicitly in the editor's comments in the C99 foreword.
1 parent f3ec73f commit cbd48b1

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

clang/test/C/C99/array-lvalue.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* RUN: %clang_cc1 -verify -pedantic -std=c99 %s
2+
RUN: %clang_cc1 -verify=c89 -pedantic -std=c89 %s
3+
expected-no-diagnostics
4+
*/
5+
6+
/* WG14 ???: Yes
7+
* Conversion of array to pointer not limited to lvalues
8+
*
9+
* NB: the original paper number is unknown, this was gleaned from the editor's report
10+
* in the C99 foreword. The C99 rationale document did not shed much light on
11+
* the situation either, mostly talking about user confusion between lvalue and
12+
* modifiable lvalue. However, the crux of the change was C89 changing:
13+
*
14+
* C89 3.2.2.1: Except when it is the operand of ..., an lvalue that has type
15+
* 'array of type' is converted to an expression that has type 'pointer to
16+
* type' that points to the initial element of the array object and is not an
17+
* lvalue.
18+
*
19+
* C99 6.3.2.1p3: Except when it is the operand of ..., an expression that has
20+
* type 'array of type' is converted to an expression with type 'pointer to
21+
* type' that points to the initial element of the array object and is not an
22+
* lvalue.
23+
*/
24+
25+
struct S {
26+
char arr[100];
27+
};
28+
29+
struct S f(void);
30+
31+
void func(void) {
32+
char c;
33+
/* The return from f() is an rvalue, so this code is not valid in C89, but is
34+
* valid in C99.
35+
*/
36+
c = f().arr[10]; /* c89-warning {{ISO C90 does not allow subscripting non-lvalue array}} */
37+
}
38+

clang/www/c_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ <h2 id="c99">C99 implementation status</h2>
360360
<tr>
361361
<td>conversion of array to pointer not limited to lvalues</td>
362362
<td>Unknown</td>
363-
<td class="unknown" align="center">Unknown</td>
363+
<td class="full" align="center">Yes</td>
364364
</tr>
365365
<tr>
366366
<td>relaxed constraints on aggregate and union initialization</td>

0 commit comments

Comments
 (0)