annotate clang/test/Sema/alloc-align-attr.c @ 173:0572611fdcc8 llvm10 llvm12

reorgnization done
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 11:55:54 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // return values
anatofuz
parents:
diff changeset
4 void test_void_alloc_align(void) __attribute__((alloc_align(1))); // expected-warning {{'alloc_align' attribute only applies to return values that are pointers}}
anatofuz
parents:
diff changeset
5 void *test_ptr_alloc_align(int a) __attribute__((alloc_align(1))); // no-warning
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 int j __attribute__((alloc_align(1))); // expected-warning {{'alloc_align' attribute only applies to non-K&R-style functions}}
anatofuz
parents:
diff changeset
8 void *test_no_params_zero(void) __attribute__((alloc_align(0))); // expected-error {{'alloc_align' attribute parameter 1 is out of bounds}}
anatofuz
parents:
diff changeset
9 void *test_no_params(void) __attribute__((alloc_align(1))); // expected-error {{'alloc_align' attribute parameter 1 is out of bounds}}
anatofuz
parents:
diff changeset
10 void *test_incorrect_param_type(float a) __attribute__((alloc_align(1))); // expected-error {{'alloc_align' attribute argument may only refer to a function parameter of integer type}}
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 // argument type
anatofuz
parents:
diff changeset
13 void *test_bad_param_type(void) __attribute((alloc_align(1.1))); // expected-error {{'alloc_align' attribute requires parameter 1 to be an integer constant}}
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 // argument count
anatofuz
parents:
diff changeset
16 void *test_no_fn_proto(int x, int y) __attribute__((alloc_align)); // expected-error {{'alloc_align' attribute takes one argument}}
anatofuz
parents:
diff changeset
17 void *test_no_fn_proto(int x, int y) __attribute__((alloc_align())); // expected-error {{'alloc_align' attribute takes one argument}}
anatofuz
parents:
diff changeset
18 void *test_no_fn_proto(int x, int y) __attribute__((alloc_align(32, 45, 37))); // expected-error {{'alloc_align' attribute takes one argument}}
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 void *passthrought(int a) {
anatofuz
parents:
diff changeset
21 return test_ptr_alloc_align(a);
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23 void *align16() {
anatofuz
parents:
diff changeset
24 return test_ptr_alloc_align(16);
anatofuz
parents:
diff changeset
25 }
anatofuz
parents:
diff changeset
26 void *align15() {
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
27 return test_ptr_alloc_align(15); // expected-warning {{requested alignment is not a power of 2}}
150
anatofuz
parents:
diff changeset
28 }
anatofuz
parents:
diff changeset
29 void *align536870912() {
anatofuz
parents:
diff changeset
30 return test_ptr_alloc_align(1073741824); // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
anatofuz
parents:
diff changeset
31 }