typedef unsigned long size_t;
__attribute__((diagnose_as_builtin(__builtin_memcpy, 3, 1, 2))) int x;
void *test_memcpy(const void *src, size_t c, void *dst) __attribute__((diagnose_as_builtin(__builtin_memcpy, 3, 1, 2))) {
return __builtin_memcpy(dst, src, c);
}
void call_test_memcpy(void) {
char bufferA[10];
char bufferB[11];
test_memcpy(bufferB, 10, bufferA);
test_memcpy(bufferB, 11, bufferA); }
void failure_function_doesnt_exist(void) __attribute__((diagnose_as_builtin(__function_that_doesnt_exist))) {}
void not_a_builtin(void) {}
void failure_not_a_builtin(void) __attribute__((diagnose_as_builtin(not_a_builtin))) {}
void failure_too_many_parameters(void *dst, const void *src, size_t count, size_t nothing) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3, 4))) {}
void failure_too_few_parameters(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2))) {}
void failure_not_an_integer(void *dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, "abc", 2, 3))) {}
void failure_not_a_builtin2(void) __attribute__((diagnose_as_builtin("abc"))) {}
void failure_parameter_index_bounds(void *dst, const void *src) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {}
void failure_parameter_types(double dst, const void *src, size_t count) __attribute__((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3))) {}
void to_redeclare(void *dst, const void *src, size_t count);
void use_to_redeclare(void) {
char src[10];
char dst[9];
to_redeclare(dst, src, 10);
}
void to_redeclare(void *dst, const void *src, size_t count) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
void error_to_redeclare(void) {
char src[10];
char dst[9];
to_redeclare(dst, src, 10); }
void *memcpy2(void *const dst __attribute__((pass_object_size(0))), const void *src, size_t copy_amount) __attribute((diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)));
void call_memcpy2(void) {
char buf1[10];
char buf2[11];
memcpy2(buf1, buf2, 11); }
void failure_type(void *dest, char val, size_t n) __attribute__((diagnose_as_builtin(__builtin_memset, 1, 2, 3))) {}
#ifdef __cplusplus
extern "C" {
#endif
extern int sscanf(const char *input, const char *format, ...);
#ifdef __cplusplus
}
#endif
int mysscanf(const char *str, const char *format, ...) __attribute__((diagnose_as_builtin(sscanf, 1, 2)));
void warn_mysccanf(void) {
char buf[10];
mysscanf("", "%10s", buf); }
#ifdef __cplusplus
template <class T>
void some_templated_function(int x) {
return;
}
void failure_template(int x) __attribute__((diagnose_as_builtin(some_templated_function, 1))) {}
void failure_template_instantiation(int x) __attribute__((diagnose_as_builtin(some_templated_function<int>, 1))) {}
void overloaded_function(unsigned);
void overloaded_function(int);
void failure_overloaded_function(int) __attribute__((diagnose_as_builtin(overloaded_function, 1))) {}
struct S {
__attribute__((diagnose_as_builtin(__builtin_memset))) void f();
__attribute__((diagnose_as_builtin(__builtin_memcpy, 3, 1, 2))) static void *test_memcpy(const void *src, size_t c, void *dst) {
return __builtin_memcpy(dst, src, c);
}
};
void call_static_test_memcpy(void) {
char bufferA[10];
char bufferB[11];
S::test_memcpy(bufferB, 10, bufferA);
S::test_memcpy(bufferB, 11, bufferA); }
#endif