Message ID | 1475571285-18180-1-git-send-email-johannes@sipsolutions.net (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
On Tue, 2016-10-04 at 10:54 +0200, Johannes Berg wrote: > gcc clearly allows that, and this makes no difference since we > can still pass a non-const pointer without warnings. > > Add a test for it, while at it. Oh, now I see Lance already sent this patch, sorry. I have a test, if you like that better, but whatever. Would be nice if you could apply either one though :) Thanks, johannes -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/lib.c b/lib.c index 8dc5bcf9dc18..cade28c95a48 100644 --- a/lib.c +++ b/lib.c @@ -877,7 +877,7 @@ void declare_builtin_functions(void) add_pre_buffer("extern int __builtin_isunordered(float, float);\n"); /* And some __FORTIFY_SOURCE ones.. */ - add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(void *, int);\n"); + add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(const void *, int);\n"); add_pre_buffer ("extern void * __builtin___memcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n"); add_pre_buffer ("extern void * __builtin___memmove_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n"); add_pre_buffer ("extern void * __builtin___mempcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n"); diff --git a/validation/builtin_object_size.c b/validation/builtin_object_size.c new file mode 100644 index 000000000000..a7013a80e7fd --- /dev/null +++ b/validation/builtin_object_size.c @@ -0,0 +1,13 @@ +static void fn(void) +{ + static int i; + const void *ptr = (void *)0; + + i = __builtin_object_size(ptr, 0); +} + +/* + * check-name: __builtin_object_size + * check-error-start + * check-error-end + */
gcc clearly allows that, and this makes no difference since we can still pass a non-const pointer without warnings. Add a test for it, while at it. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> --- lib.c | 2 +- validation/builtin_object_size.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 validation/builtin_object_size.c