return ExprError(Diag(Idx->getLocStart(),
diag::err_typecheck_subscript_not_integer)
<< Idx->getSourceRange());
+
+ ExprResult IdxRvalue = DefaultLvalueConversion(Idx);
+ if (IdxRvalue.isInvalid())
+ return ExprError();
// Record this array index.
Comps.push_back(OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
- Exprs.push_back(Idx);
+ Exprs.push_back(IdxRvalue.take());
continue;
}
typedef struct Array { int array[1]; } Array;
int test4 = __builtin_offsetof(Array, array);
+
+int test5() {
+ return __builtin_offsetof(Array, array[*(int*)0]); // expected-warning{{indirection of non-volatile null pointer}} expected-note{{__builtin_trap}}
+}