blob: 053323a9f11b0121ff7b46f68cc0a5bbca8f6cbe [file] [log] [blame]
Nuno Lopes587de5b2012-05-24 00:22:00 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3void* my_malloc(unsigned char) __attribute__((alloc_size(1)));
4void* my_calloc(unsigned char, short) __attribute__((alloc_size(1,2)));
5void* my_realloc(void*, unsigned) __attribute__((alloc_size(2)));
6
7
Aaron Ballmanb3d7efe2013-07-30 00:48:57 +00008void* fn1(int) __attribute__((alloc_size("xpto"))); // expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}}
Nuno Lopes587de5b2012-05-24 00:22:00 +00009
Aaron Ballman9f939f72013-07-30 14:10:17 +000010void* fn2(void*) __attribute__((alloc_size(1))); // expected-error{{'alloc_size' attribute requires an integer constant}}
Nuno Lopes587de5b2012-05-24 00:22:00 +000011
12void* fn3(unsigned) __attribute__((alloc_size(0))); // expected-error{{attribute parameter 1 is out of bounds}}
13void* fn4(unsigned) __attribute__((alloc_size(2))); // expected-error{{attribute parameter 1 is out of bounds}}
14
15void fn5(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only applies to functions that return a pointer}}
16char fn6(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only applies to functions that return a pointer}}
17
18void* fn7(unsigned) __attribute__((alloc_size)); // expected-error {{attribute takes at least 1 argument}}
19
Nuno Lopes96c67d12012-06-18 16:27:56 +000020void *fn8(int, int) __attribute__((alloc_size(1, 1))); // OK
Nuno Lopes587de5b2012-05-24 00:22:00 +000021
Eli Friedmanb3da6132013-07-23 00:25:18 +000022void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-error {{integer constant is larger than the largest unsigned integer type}} // expected-error {{attribute parameter 1 is out of bounds}}
Nuno Lopes174930d2012-06-18 16:39:04 +000023
24void* fn10(size_t, size_t) __attribute__((alloc_size(1,2))); // expected-error{{redefinition of parameter}} \
25 // expected-error{{a parameter list without types is only allowed in a function definition}} \
Argyrios Kyrtzidisd5668a22013-02-22 06:58:32 +000026 // expected-error{{attribute parameter 1 is out of bounds}}
Argyrios Kyrtzidis28965bf2013-02-22 06:58:28 +000027void* fn11() __attribute__((alloc_size(1))); // expected-error{{attribute parameter 1 is out of bounds}}