Using arrow operator with array generates incorrect diagnostic

Code like this:

struct simple { int i; };

void f(void) {
    struct simple s[1];
    s->i = 1;

produces the error:

$ clang -fsyntax-only test.c
test.c:8:6: error: member reference is not a pointer
    s->i = 1;
     ^ ~
1 diagnostic generated.

My understanding is that this is legal as per C99 p3:

Except when it is the operand of the sizeof operator or the unary &
operator, or is a
string literal used to initialize an array, 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.

My attempt at a patch is attached.


array-with-arrow-operator.diff (629 Bytes)


I just submitted another fix to this bug.

Let me know if you have any questions (and thanks for the report!),