File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -72,3 +72,31 @@ void TestGoodBadSpan() {
7272 // expected-note@+1 {{in instantiation of function template specialization 'produce_span<BadSpan>' requested here}}
7373 produce_span<BadSpan>();
7474}
75+
76+ // Ensure that trailing return types are also supported.
77+ __attribute__ ((malloc_span)) auto trailling_return_type(int size) -> GoodSpan { // no-warning
78+ return GoodSpan{};
79+ }
80+
81+ template <typename T>
82+ // expected-warning@+2 {{'malloc_span' attribute only applies to functions that return span-like structures}}
83+ // expected-note@+1 {{returned struct/class has 1 fields, expected 2}}
84+ __attribute__ ((malloc_span)) auto templated_trailling_return_type() -> T { // no-warning
85+ return T{};
86+ }
87+
88+ void TestGoodBadTrailingReturnType () {
89+ templated_trailling_return_type<GoodSpan>(); // no-warnings
90+ // expected-note@+1 {{in instantiation of function template specialization 'templated_trailling_return_type<BadSpan>' requested here}}
91+ templated_trailling_return_type<BadSpan>();
92+ }
93+
94+ __attribute ((malloc_span)) auto trailling_return_temmplate_good(void ) -> Pair<int*, int> { // no-warning
95+ return Pair<int *, int >{};
96+ }
97+
98+ // expected-warning@+2 {{attribute only applies to functions that return span-like structures}}
99+ // expected-note@+1 {{returned struct/class fields are not a supported combination for a span-like type}}
100+ __attribute ((malloc_span)) auto trailling_return_temmplate_bad(void ) -> Pair<int, int> {
101+ return Pair<int , int >{};
102+ }
You can’t perform that action at this time.
0 commit comments