blob: ae71e29dc7943b0747aac3d28588990bb27e15c0 [file] [log] [blame]
DeLesley Hutchinsdf7bef02013-08-12 21:20:55 +00001// RUN: %clang_cc1 -fsyntax-only -verify -Wconsumed -std=c++11 %s
2
DeLesley Hutchinsc55bee62013-08-30 22:56:34 +00003#define CONSUMABLE __attribute__ ((consumable))
DeLesley Hutchinsdf7bef02013-08-12 21:20:55 +00004#define CONSUMES __attribute__ ((consumes))
5#define TESTS_UNCONSUMED __attribute__ ((tests_unconsumed))
6#define CALLABLE_WHEN_UNCONSUMED __attribute__ ((callable_when_unconsumed))
7
8class AttrTester0 {
DeLesley Hutchinsc55bee62013-08-30 22:56:34 +00009 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 Hutchinsdf7bef02013-08-12 21:20:55 +000012 __attribute__ ((callable_when_unconsumed(42))); // expected-error {{attribute takes no arguments}}
13};
14
15int var0 CONSUMES; // expected-warning {{'consumes' attribute only applies to methods}}
16int var1 TESTS_UNCONSUMED; // expected-warning {{'tests_unconsumed' attribute only applies to methods}}
17int var2 CALLABLE_WHEN_UNCONSUMED; // expected-warning {{'callable_when_unconsumed' attribute only applies to methods}}
DeLesley Hutchinsc55bee62013-08-30 22:56:34 +000018int var3 CONSUMABLE; // expected-warning {{'consumable' attribute only applies to classes}}
DeLesley Hutchinsdf7bef02013-08-12 21:20:55 +000019
DeLesley Hutchinsc55bee62013-08-30 22:56:34 +000020void function0() CONSUMES; // expected-warning {{'consumes' attribute only applies to methods}}
21void function1() TESTS_UNCONSUMED; // expected-warning {{'tests_unconsumed' attribute only applies to methods}}
22void function2() CALLABLE_WHEN_UNCONSUMED; // expected-warning {{'callable_when_unconsumed' attribute only applies to methods}}
23void function3() CONSUMABLE; // expected-warning {{'consumable' attribute only applies to classes}}
DeLesley Hutchinsdf7bef02013-08-12 21:20:55 +000024
DeLesley Hutchinsc55bee62013-08-30 22:56:34 +000025class CONSUMABLE AttrTester1 {
26 void callableWhenUnconsumed() CALLABLE_WHEN_UNCONSUMED;
27 void consumes() CONSUMES;
28 bool testsUnconsumed() TESTS_UNCONSUMED;
DeLesley Hutchinsdf7bef02013-08-12 21:20:55 +000029};
30
31class AttrTester2 {
DeLesley Hutchinsc55bee62013-08-30 22:56:34 +000032 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 Hutchinsdf7bef02013-08-12 21:20:55 +000035};