This was a fork of Checked C clang used from 2021-2024. The changes have been merged into the original Checked C clang repo, which is now at https://github.com/checkedc/checkedc-clang.
This PR modifies the type checker so that, if an expression e has type T, then &e[idx] and &idx[e] also have type T. This is similar to the current behavior where, if e has type T, then &*e also has type T.
From the C spec section 6.5.3.2:
Similarly, if the operand is the result of a [] operator, neither the & operator nor the unary * that is implied by the [] is evaluated and the result is as if the & operator were removed and the [] operator were changed to a + operator.
This is similar to the rules for &*e:
If the operand is the result of a unary * operator, neither that operator nor the & operator is evaluated and the result is as if both were omitted, except that the constraints on the operators still apply and the result is not an lvalue.
This issue was copied from https://github.com/microsoft/checkedc-clang/issues/1163
Fixes #1148
This PR modifies the type checker so that, if an expression
e
has typeT
, then&e[idx]
and&idx[e]
also have typeT
. This is similar to the current behavior where, ife
has typeT
, then&*e
also has typeT
.From the C spec section 6.5.3.2:
This is similar to the rules for
&*e
: