[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.
This commit is contained in:
Aaron Ballman
2024-04-01 14:49:56 -04:00
parent f3ec73fca4
commit cbd48b184e
2 changed files with 39 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
/* RUN: %clang_cc1 -verify -pedantic -std=c99 %s
RUN: %clang_cc1 -verify=c89 -pedantic -std=c89 %s
expected-no-diagnostics
*/
/* WG14 ???: Yes
* Conversion of array to pointer not limited to lvalues
*
* NB: the original paper number is unknown, this was gleaned from the editor's report
* in the C99 foreword. The C99 rationale document did not shed much light on
* the situation either, mostly talking about user confusion between lvalue and
* modifiable lvalue. However, the crux of the change was C89 changing:
*
* C89 3.2.2.1: Except when it is the operand of ..., an lvalue that has type
* 'array of type' is converted to an expression that has type 'pointer to
* type' that points to the initial element of the array object and is not an
* lvalue.
*
* C99 6.3.2.1p3: Except when it is the operand of ..., an expression that has
* type 'array of type' is converted to an expression with type 'pointer to
* type' that points to the initial element of the array object and is not an
* lvalue.
*/
struct S {
char arr[100];
};
struct S f(void);
void func(void) {
char c;
/* The return from f() is an rvalue, so this code is not valid in C89, but is
* valid in C99.
*/
c = f().arr[10]; /* c89-warning {{ISO C90 does not allow subscripting non-lvalue array}} */
}

View File

@@ -360,7 +360,7 @@ conformance.</p>
<tr>
<td>conversion of array to pointer not limited to lvalues</td>
<td>Unknown</td>
<td class="unknown" align="center">Unknown</td>
<td class="full" align="center">Yes</td>
</tr>
<tr>
<td>relaxed constraints on aggregate and union initialization</td>