// Use the more strict checking mode on the pass_object_size attribute:
// expected-warning@-3 {{memcpy' will always overflow; destination buffer has size 4, but size argument is 20}}
#else
// Or just fallback to type 0:
// expected-warning@-6 {{memcpy' will always overflow; destination buffer has size 8, but size argument is 20}}
#endif
}
voidcall_strncat(){
chars1[10],s2[20];
__builtin_strncat(s2,s1,20);
__builtin_strncat(s1,s2,20);// expected-warning {{'strncat' size argument is too large; destination buffer has size 10, but size argument is 20}}
}
voidcall_strncpy(){
chars1[10],s2[20];
__builtin_strncpy(s2,s1,20);
__builtin_strncpy(s1,s2,20);// expected-warning {{'strncpy' size argument is too large; destination buffer has size 10, but size argument is 20}}
}
voidcall_stpncpy(){
chars1[10],s2[20];
__builtin_stpncpy(s2,s1,20);
__builtin_stpncpy(s1,s2,20);// expected-warning {{'stpncpy' size argument is too large; destination buffer has size 10, but size argument is 20}}
}
voidcall_memmove(){
chars1[10],s2[20];
__builtin_memmove(s2,s1,20);
__builtin_memmove(s1,s2,20);// expected-warning {{'memmove' will always overflow; destination buffer has size 10, but size argument is 20}}
}
voidcall_memset(){
charbuf[10];
__builtin_memset(buf,0xff,10);
__builtin_memset(buf,0xff,11);// expected-warning {{'memset' will always overflow; destination buffer has size 10, but size argument is 11}}
}
voidcall_snprintf(){
charbuf[10];
__builtin_snprintf(buf,10,"merp");
__builtin_snprintf(buf,11,"merp");// expected-warning {{'snprintf' size argument is too large; destination buffer has size 10, but size argument is 11}}
}
voidcall_vsnprintf(){
charbuf[10];
__builtin_va_listlist;
__builtin_vsnprintf(buf,10,"merp",list);
__builtin_vsnprintf(buf,11,"merp",list);// expected-warning {{'vsnprintf' size argument is too large; destination buffer has size 10, but size argument is 11}}