mirror of
https://github.com/intel/llvm.git
synced 2026-02-01 17:07:36 +08:00
[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:
38
clang/test/C/C99/array-lvalue.c
Normal file
38
clang/test/C/C99/array-lvalue.c
Normal 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}} */
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user