1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
2 | |
3 | #define INT_TAG 42 |
4 | |
5 | static const int test_in |
6 | __attribute__((type_tag_for_datatype(test, int))) = INT_TAG; |
7 | |
8 | // Argument index: 1, Type tag index: 2 |
9 | void test_bounds_index(...) |
10 | __attribute__((argument_with_type_tag(test, 1, 2))); |
11 | |
12 | // Argument index: 1, Type tag index: 2 |
13 | void test_bounds_index_ptr(void *, ...) |
14 | __attribute__((pointer_with_type_tag(test, 1, 2))); |
15 | |
16 | // Argument index: 3, Type tag index: 1 |
17 | void test_bounds_arg_index(...) |
18 | __attribute__((argument_with_type_tag(test, 3, 1))); |
19 | |
20 | class C { |
21 | public: |
22 | // Argument index: 2, Type tag index: 3 |
23 | void test_bounds_index(...) |
24 | __attribute__((argument_with_type_tag(test, 2, 3))); |
25 | |
26 | // Argument index: 2, Type tag index: 3 |
27 | void test_bounds_index_ptr(void *, ...) |
28 | __attribute__((pointer_with_type_tag(test, 2, 3))); |
29 | |
30 | // Argument index: 4, Type tag index: 2 |
31 | void test_bounds_arg_index(...) |
32 | __attribute__((argument_with_type_tag(test, 4, 2))); |
33 | }; |
34 | |
35 | void test_bounds() |
36 | { |
37 | C c; |
38 | |
39 | // Test the boundary edges (ensure no off-by-one) with argument indexing. |
40 | test_bounds_index(1, INT_TAG); |
41 | c.test_bounds_index(1, INT_TAG); |
42 | test_bounds_index_ptr(0, INT_TAG); |
43 | c.test_bounds_index_ptr(0, INT_TAG); |
44 | |
45 | test_bounds_index(1); // expected-error {{type tag index 2 is greater than the number of arguments specified}} |
46 | c.test_bounds_index(1); // expected-error {{type tag index 3 is greater than the number of arguments specified}} |
47 | test_bounds_index_ptr(0); // expected-error {{type tag index 2 is greater than the number of arguments specified}} |
48 | c.test_bounds_index_ptr(0); // expected-error {{type tag index 3 is greater than the number of arguments specified}} |
49 | |
50 | test_bounds_arg_index(INT_TAG, 1); // expected-error {{argument index 3 is greater than the number of arguments specified}} |
51 | c.test_bounds_arg_index(INT_TAG, 1); // expected-error {{argument index 4 is greater than the number of arguments specified}} |
52 | } |
53 | |