DeLesley Hutchins | df7bef0 | 2013-08-12 21:20:55 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wconsumed -std=c++11 %s |
| 2 | |
DeLesley Hutchins | c55bee6 | 2013-08-30 22:56:34 +0000 | [diff] [blame] | 3 | #define CONSUMABLE __attribute__ ((consumable)) |
DeLesley Hutchins | df7bef0 | 2013-08-12 21:20:55 +0000 | [diff] [blame] | 4 | #define CONSUMES __attribute__ ((consumes)) |
| 5 | #define TESTS_UNCONSUMED __attribute__ ((tests_unconsumed)) |
| 6 | #define CALLABLE_WHEN_UNCONSUMED __attribute__ ((callable_when_unconsumed)) |
| 7 | |
| 8 | class AttrTester0 { |
DeLesley Hutchins | c55bee6 | 2013-08-30 22:56:34 +0000 | [diff] [blame] | 9 | void Consumes() __attribute__ ((consumes(42))); // expected-error {{attribute takes no arguments}} |
| 10 | bool TestsUnconsumed() __attribute__ ((tests_unconsumed(42))); // expected-error {{attribute takes no arguments}} |
| 11 | void CallableWhenUnconsumed() |
DeLesley Hutchins | df7bef0 | 2013-08-12 21:20:55 +0000 | [diff] [blame] | 12 | __attribute__ ((callable_when_unconsumed(42))); // expected-error {{attribute takes no arguments}} |
| 13 | }; |
| 14 | |
| 15 | int var0 CONSUMES; // expected-warning {{'consumes' attribute only applies to methods}} |
| 16 | int var1 TESTS_UNCONSUMED; // expected-warning {{'tests_unconsumed' attribute only applies to methods}} |
| 17 | int var2 CALLABLE_WHEN_UNCONSUMED; // expected-warning {{'callable_when_unconsumed' attribute only applies to methods}} |
DeLesley Hutchins | c55bee6 | 2013-08-30 22:56:34 +0000 | [diff] [blame] | 18 | int var3 CONSUMABLE; // expected-warning {{'consumable' attribute only applies to classes}} |
DeLesley Hutchins | df7bef0 | 2013-08-12 21:20:55 +0000 | [diff] [blame] | 19 | |
DeLesley Hutchins | c55bee6 | 2013-08-30 22:56:34 +0000 | [diff] [blame] | 20 | void function0() CONSUMES; // expected-warning {{'consumes' attribute only applies to methods}} |
| 21 | void function1() TESTS_UNCONSUMED; // expected-warning {{'tests_unconsumed' attribute only applies to methods}} |
| 22 | void function2() CALLABLE_WHEN_UNCONSUMED; // expected-warning {{'callable_when_unconsumed' attribute only applies to methods}} |
| 23 | void function3() CONSUMABLE; // expected-warning {{'consumable' attribute only applies to classes}} |
DeLesley Hutchins | df7bef0 | 2013-08-12 21:20:55 +0000 | [diff] [blame] | 24 | |
DeLesley Hutchins | c55bee6 | 2013-08-30 22:56:34 +0000 | [diff] [blame] | 25 | class CONSUMABLE AttrTester1 { |
| 26 | void callableWhenUnconsumed() CALLABLE_WHEN_UNCONSUMED; |
| 27 | void consumes() CONSUMES; |
| 28 | bool testsUnconsumed() TESTS_UNCONSUMED; |
DeLesley Hutchins | df7bef0 | 2013-08-12 21:20:55 +0000 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | class AttrTester2 { |
DeLesley Hutchins | c55bee6 | 2013-08-30 22:56:34 +0000 | [diff] [blame] | 32 | void callableWhenUnconsumed() CALLABLE_WHEN_UNCONSUMED; // expected-warning {{consumed analysis attribute is attached to class 'AttrTester2' which isn't marked as consumable}} |
| 33 | void consumes() CONSUMES; // expected-warning {{consumed analysis attribute is attached to class 'AttrTester2' which isn't marked as consumable}} |
| 34 | bool testsUnconsumed() TESTS_UNCONSUMED; // expected-warning {{consumed analysis attribute is attached to class 'AttrTester2' which isn't marked as consumable}} |
DeLesley Hutchins | df7bef0 | 2013-08-12 21:20:55 +0000 | [diff] [blame] | 35 | }; |