Fix duplicate messages for illegal void pointer arithmetic. #563
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The compiler was emitting duplicate error messages for void pointer arithmetic using checked pointers in bounds expressions. The problem was that the logic for marking the expression as invalid is separate from actually emitting the diagnostic. The logic only looked for the language being C++. The fix is to look for the conditions related to Checked C also. This fixes issue #543.
This caused a duplicate error messages because the expression wasn't turned into an invalid expression. When a subsequent TreeTransform pass for bounds declaration checking ran, it emitted the diagnostic a second time when it encountered the expression again.
I noticed that we had some logic for handling pointer arithmetic involving function pointers. This is allowed by a GCC extension. For checked pointers, we never allow _Array_ptrs to function pointers. We only allow _Ptrs to function pointers. Pointer arithmetic is never allowed for _Ptrs, so we never reach this logic. I converted the logic to an assert and added some comments.
Testing: