This patch fixes the checkArgCount function in Sema that is used to check the number of arguments of a call when doing custom type-checking.
The patch fixes that function in two ways:
- It now displays the right range in case the number of actual arguments is greater than the number of expected arguments. Example:
Without patch:
main.c:5:36: error: too many arguments to function call, expected 3, have 7 __builtin_add_overflow(1, 2, &r, 3, 4, 5, 6); ~ ^
With patch:
main.c:5:36: error: too many arguments to function call, expected 3, have 7 __builtin_add_overflow(1, 2, &r, 3, 4, 5, 6); ^~~~~~~~~~
- A side effect is that the patch also allows the function to properly handle the case in which the desired argument count is 0 and the number of actual arguments is 1. No test case is provided for that because currently no builtin with 0 expected argument is checked with that function.