When checking that the array access is not out-of-bounds in CheckArrayAccess,
it is possible that the type of the base expression after IgnoreParenCasts is incomplete,
even though the type of the base expression before IgnoreParenCasts is complete
In this case we have no information about whether the array access is out-of-bounds,
and we should just bail-out instead. This fixes PR39746 which was caused by trying
to obtain the size of an incomplete type.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Sema/SemaChecking.cpp | ||
---|---|---|
12381 ↗ | (On Diff #178807) | This comment is really confusing; the meaning of "base type" and "effective type" in this context isn't clear. Also, "effective type" is a term defined in the C standard to mean something else. Better to explicitly say you're talking about the type of the base expression before/after the call to IgnoreParenCasts. |
12383 ↗ | (On Diff #178807) | You don't need to explicitly pass nullptr here; there's a default argument. |
test/SemaCXX/array-bounds.cpp | ||
294 ↗ | (On Diff #178807) | Not sure it actually makes sense to print a diagnostic here... at least, not this diagnostic. We don't know whether the result here is actually out of bounds. |
test/SemaCXX/array-bounds.cpp | ||
---|---|---|
294 ↗ | (On Diff #178807) | Right. I think that the right thing to do then is to not print anything |
lib/Sema/SemaChecking.cpp | ||
---|---|---|
12357 ↗ | (On Diff #178848) | Using getPointeeOrArrayElementType here is kind of confusing; instead, we can just call ArrayTy->getElementType(). |