blob: bb59ab332dee9b7ee641842b6d6c5cf1992cda34 [file] [log] [blame]
Erich Keane623efd82017-03-30 21:48:55 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3struct param_num {
4 void* Foo(int a) __attribute__((alloc_align(1))); // expected-error {{'alloc_align' attribute is invalid for the implicit this argument}}
5};
6
7
8template <typename T>
9struct dependent_ret {
10 T* Foo(int a) __attribute__((alloc_align(2)));// no-warning, ends up being int**.
11 T Foo2(int a) __attribute__((alloc_align(2)));// expected-warning {{'alloc_align' attribute only applies to return values that are pointers or references}}
12};
13
14// Following 2 errors associated only with the 'float' versions below.
15template <typename T>
16struct dependent_param_struct {
17 void* Foo(T param) __attribute__((alloc_align(2))); // expected-error {{'alloc_align' attribute argument may only refer to a function parameter of integer type}}
18};
19
20template <typename T>
21void* dependent_param_func(T param) __attribute__((alloc_align(1)));// expected-error {{'alloc_align' attribute argument may only refer to a function parameter of integer type}}
22
23template <int T>
24void* illegal_align_param(int p) __attribute__((alloc_align(T))); // expected-error {{'alloc_align' attribute requires parameter 1 to be an integer constant}}
25
Roman Lebedevba545c82020-01-23 22:49:50 +030026void dependent_impl(int align) {
Erich Keane623efd82017-03-30 21:48:55 +000027 dependent_ret<int> a; // expected-note {{in instantiation of template class 'dependent_ret<int>' requested here}}
28 a.Foo(1);
29 a.Foo2(1);
Roman Lebedevba545c82020-01-23 22:49:50 +030030 dependent_ret<int *> b;
31 b.Foo(1);
32 b.Foo2(1);
Roman Lebedev9ea5d172020-02-20 16:39:26 +030033 b.Foo(3); // expected-warning {{requested alignment is not a power of 2}}
34 b.Foo2(3); // expected-warning {{requested alignment is not a power of 2}}
Roman Lebedevba545c82020-01-23 22:49:50 +030035 b.Foo(1073741824); // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
36 b.Foo2(1073741824); // expected-warning {{requested alignment must be 536870912 bytes or smaller; maximum alignment assumed}}
37 b.Foo(align);
38 b.Foo2(align);
Erich Keane623efd82017-03-30 21:48:55 +000039
Roman Lebedev9ea5d172020-02-20 16:39:26 +030040 dependent_param_struct<int> c;
Erich Keane623efd82017-03-30 21:48:55 +000041 c.Foo(1);
42 dependent_param_struct<float> d; // expected-note {{in instantiation of template class 'dependent_param_struct<float>' requested here}}
43 d.Foo(1.0);
44 dependent_param_func<int>(1);
45 dependent_param_func<float>(1); // expected-note {{in instantiation of function template specialization 'dependent_param_func<float>' requested here}}
46}