diff options
-rw-r--r-- | test/SemaCXX/warn-thread-safety-parsing.cpp | 746 |
1 files changed, 373 insertions, 373 deletions
diff --git a/test/SemaCXX/warn-thread-safety-parsing.cpp b/test/SemaCXX/warn-thread-safety-parsing.cpp index af02be1430..40837eab2e 100644 --- a/test/SemaCXX/warn-thread-safety-parsing.cpp +++ b/test/SemaCXX/warn-thread-safety-parsing.cpp @@ -22,7 +22,7 @@ #define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis)) -class __attribute__((lockable)) Mu { +class LOCKABLE Mutex { public: void Lock(); }; @@ -32,11 +32,11 @@ class UnlockableMu{ class MuWrapper { public: - Mu mu; - Mu getMu() { + Mutex mu; + Mutex getMu() { return mu; } - Mu * getMuPointer() { + Mutex * getMuPointer() { return μ } }; @@ -50,32 +50,32 @@ class MuDoubleWrapper { } }; -Mu mu1; +Mutex mu1; UnlockableMu umu; -Mu mu2; +Mutex mu2; MuWrapper muWrapper; MuDoubleWrapper muDoubleWrapper; -Mu* muPointer; -Mu ** muDoublePointer = & muPointer; -Mu& muRef = mu1; +Mutex* muPointer; +Mutex** muDoublePointer = & muPointer; +Mutex& muRef = mu1; //---------------------------------------// // Scoping tests //--------------------------------------// class Foo { - Mu foomu; - void needLock() __attribute__((exclusive_lock_function(foomu))); + Mutex foomu; + void needLock() EXCLUSIVE_LOCK_FUNCTION(foomu); }; class Foo2 { - void needLock() __attribute__((exclusive_lock_function(foomu))); - Mu foomu; + void needLock() EXCLUSIVE_LOCK_FUNCTION(foomu); + Mutex foomu; }; class Bar { - Mu barmu; - Mu barmu2 __attribute__((acquired_after(barmu))); + Mutex barmu; + Mutex barmu2 ACQUIRED_AFTER(barmu); }; @@ -90,34 +90,34 @@ class Bar { #error "Should support no_thread_safety_analysis attribute" #endif -void noanal_fun() __attribute__((no_thread_safety_analysis)); +void noanal_fun() NO_THREAD_SAFETY_ANALYSIS; void noanal_fun_args() __attribute__((no_thread_safety_analysis(1))); // \ // expected-error {{attribute takes no arguments}} -int noanal_testfn(int y) __attribute__((no_thread_safety_analysis)); +int noanal_testfn(int y) NO_THREAD_SAFETY_ANALYSIS; int noanal_testfn(int y) { - int x __attribute__((no_thread_safety_analysis)) = y; // \ + int x NO_THREAD_SAFETY_ANALYSIS = y; // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} return x; }; -int noanal_test_var __attribute__((no_thread_safety_analysis)); // \ +int noanal_test_var NO_THREAD_SAFETY_ANALYSIS; // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} class NoanalFoo { private: - int test_field __attribute__((no_thread_safety_analysis)); // \ + int test_field NO_THREAD_SAFETY_ANALYSIS; // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} - void test_method() __attribute__((no_thread_safety_analysis)); + void test_method() NO_THREAD_SAFETY_ANALYSIS; }; -class __attribute__((no_thread_safety_analysis)) NoanalTestClass { // \ +class NO_THREAD_SAFETY_ANALYSIS NoanalTestClass { // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} }; -void noanal_fun_params(int lvar __attribute__((no_thread_safety_analysis))); // \ +void noanal_fun_params(int lvar NO_THREAD_SAFETY_ANALYSIS); // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} @@ -129,30 +129,30 @@ void noanal_fun_params(int lvar __attribute__((no_thread_safety_analysis))); // #error "Should support guarded_var attribute" #endif -int gv_var_noargs __attribute__((guarded_var)); +int gv_var_noargs GUARDED_VAR; int gv_var_args __attribute__((guarded_var(1))); // \ // expected-error {{attribute takes no arguments}} class GVFoo { private: - int gv_field_noargs __attribute__((guarded_var)); + int gv_field_noargs GUARDED_VAR; int gv_field_args __attribute__((guarded_var(1))); // \ // expected-error {{attribute takes no arguments}} }; -class __attribute__((guarded_var)) GV { // \ +class GUARDED_VAR GV { // \ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}} }; -void gv_function() __attribute__((guarded_var)); // \ +void gv_function() GUARDED_VAR; // \ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}} -void gv_function_params(int gv_lvar __attribute__((guarded_var))); // \ +void gv_function_params(int gv_lvar GUARDED_VAR); // \ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}} int gv_testfn(int y){ - int x __attribute__((guarded_var)) = y; // \ + int x GUARDED_VAR = y; // \ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}} return x; } @@ -167,21 +167,21 @@ int gv_testfn(int y){ #error "Should support pt_guarded_var attribute" #endif -int *pgv_pt_var_noargs __attribute__((pt_guarded_var)); +int *pgv_pt_var_noargs PT_GUARDED_VAR; -int pgv_var_noargs __attribute__((pt_guarded_var)); // \ +int pgv_var_noargs PT_GUARDED_VAR; // \ // expected-warning {{'pt_guarded_var' only applies to pointer types; type here is 'int'}} class PGVFoo { private: - int *pt_field_noargs __attribute__((pt_guarded_var)); - int field_noargs __attribute__((pt_guarded_var)); // \ + int *pt_field_noargs PT_GUARDED_VAR; + int field_noargs PT_GUARDED_VAR; // \ // expected-warning {{'pt_guarded_var' only applies to pointer types; type here is 'int'}} int *gv_field_args __attribute__((pt_guarded_var(1))); // \ // expected-error {{attribute takes no arguments}} }; -class __attribute__((pt_guarded_var)) PGV { // \ +class PT_GUARDED_VAR PGV { // \ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}} }; @@ -189,14 +189,14 @@ int *pgv_var_args __attribute__((pt_guarded_var(1))); // \ // expected-error {{attribute takes no arguments}} -void pgv_function() __attribute__((pt_guarded_var)); // \ +void pgv_function() PT_GUARDED_VAR; // \ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}} -void pgv_function_params(int *gv_lvar __attribute__((pt_guarded_var))); // \ +void pgv_function_params(int *gv_lvar PT_GUARDED_VAR); // \ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}} void pgv_testfn(int y){ - int *x __attribute__((pt_guarded_var)) = new int(0); // \ + int *x PT_GUARDED_VAR = new int(0); // \ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}} delete x; } @@ -211,35 +211,35 @@ void pgv_testfn(int y){ #error "Should support lockable attribute" #endif -class __attribute__((lockable)) LTestClass { +class LOCKABLE LTestClass { }; class __attribute__((lockable (1))) LTestClass_args { // \ // expected-error {{attribute takes no arguments}} }; -void l_test_function() __attribute__((lockable)); // \ +void l_test_function() LOCKABLE; // \ // expected-warning {{'lockable' attribute only applies to classes}} int l_testfn(int y) { - int x __attribute__((lockable)) = y; // \ + int x LOCKABLE = y; // \ // expected-warning {{'lockable' attribute only applies to classes}} return x; } -int l_test_var __attribute__((lockable)); // \ +int l_test_var LOCKABLE; // \ // expected-warning {{'lockable' attribute only applies to classes}} class LFoo { private: - int test_field __attribute__((lockable)); // \ + int test_field LOCKABLE; // \ // expected-warning {{'lockable' attribute only applies to classes}} - void test_method() __attribute__((lockable)); // \ + void test_method() LOCKABLE; // \ // expected-warning {{'lockable' attribute only applies to classes}} }; -void l_function_params(int lvar __attribute__((lockable))); // \ +void l_function_params(int lvar LOCKABLE); // \ // expected-warning {{'lockable' attribute only applies to classes}} @@ -251,35 +251,35 @@ void l_function_params(int lvar __attribute__((lockable))); // \ #error "Should support scoped_lockable attribute" #endif -class __attribute__((scoped_lockable)) SLTestClass { +class SCOPED_LOCKABLE SLTestClass { }; class __attribute__((scoped_lockable (1))) SLTestClass_args { // \ // expected-error {{attribute takes no arguments}} }; -void sl_test_function() __attribute__((scoped_lockable)); // \ +void sl_test_function() SCOPED_LOCKABLE; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} int sl_testfn(int y) { - int x __attribute__((scoped_lockable)) = y; // \ + int x SCOPED_LOCKABLE = y; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} return x; } -int sl_test_var __attribute__((scoped_lockable)); // \ +int sl_test_var SCOPED_LOCKABLE; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} class SLFoo { private: - int test_field __attribute__((scoped_lockable)); // \ + int test_field SCOPED_LOCKABLE; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} - void test_method() __attribute__((scoped_lockable)); // \ + void test_method() SCOPED_LOCKABLE; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} }; -void sl_function_params(int lvar __attribute__((scoped_lockable))); // \ +void sl_function_params(int lvar SCOPED_LOCKABLE); // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} @@ -295,7 +295,7 @@ void sl_function_params(int lvar __attribute__((scoped_lockable))); // \ //1. Check applied to the right types & argument number -int gb_var_arg __attribute__((guarded_by(mu1))); +int gb_var_arg GUARDED_BY(mu1); int gb_var_args __attribute__((guarded_by(mu1, mu2))); // \ // expected-error {{attribute takes one argument}} @@ -307,21 +307,21 @@ class GBFoo { private: int gb_field_noargs __attribute__((guarded_by)); // \ // expected-error {{attribute takes one argument}} - int gb_field_args __attribute__((guarded_by(mu1))); + int gb_field_args GUARDED_BY(mu1); }; -class __attribute__((guarded_by(mu1))) GB { // \ +class GUARDED_BY(mu1) GB { // \ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}} }; -void gb_function() __attribute__((guarded_by(mu1))); // \ +void gb_function() GUARDED_BY(mu1); // \ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}} -void gb_function_params(int gv_lvar __attribute__((guarded_by(mu1)))); // \ +void gb_function_params(int gv_lvar GUARDED_BY(mu1)); // \ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}} int gb_testfn(int y){ - int x __attribute__((guarded_by(mu1))) = y; // \ + int x GUARDED_BY(mu1) = y; // \ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}} return x; } @@ -329,24 +329,24 @@ int gb_testfn(int y){ //2. Check argument parsing. // legal attribute arguments -int gb_var_arg_1 __attribute__((guarded_by(muWrapper.mu))); -int gb_var_arg_2 __attribute__((guarded_by(muDoubleWrapper.muWrapper->mu))); -int gb_var_arg_3 __attribute__((guarded_by(muWrapper.getMu()))); -int gb_var_arg_4 __attribute__((guarded_by(*muWrapper.getMuPointer()))); -int gb_var_arg_5 __attribute__((guarded_by(&mu1))); -int gb_var_arg_6 __attribute__((guarded_by(muRef))); -int gb_var_arg_7 __attribute__((guarded_by(muDoubleWrapper.getWrapper()->getMu()))); -int gb_var_arg_8 __attribute__((guarded_by(muPointer))); +int gb_var_arg_1 GUARDED_BY(muWrapper.mu); +int gb_var_arg_2 GUARDED_BY(muDoubleWrapper.muWrapper->mu); +int gb_var_arg_3 GUARDED_BY(muWrapper.getMu()); +int gb_var_arg_4 GUARDED_BY(*muWrapper.getMuPointer()); +int gb_var_arg_5 GUARDED_BY(&mu1); +int gb_var_arg_6 GUARDED_BY(muRef); +int gb_var_arg_7 GUARDED_BY(muDoubleWrapper.getWrapper()->getMu()); +int gb_var_arg_8 GUARDED_BY(muPointer); // illegal attribute arguments -int gb_var_arg_bad_1 __attribute__((guarded_by(1))); // \ +int gb_var_arg_bad_1 GUARDED_BY(1); // \ // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'int'}} -int gb_var_arg_bad_2 __attribute__((guarded_by("mu"))); // \ +int gb_var_arg_bad_2 GUARDED_BY("mu"); // \ // expected-warning {{ignoring 'guarded_by' attribute because its argument is invalid}} -int gb_var_arg_bad_3 __attribute__((guarded_by(muDoublePointer))); // \ - // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'class Mu **'}} -int gb_var_arg_bad_4 __attribute__((guarded_by(umu))); // \ +int gb_var_arg_bad_3 GUARDED_BY(muDoublePointer); // \ + // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'class Mutex **'}} +int gb_var_arg_bad_4 GUARDED_BY(umu); // \ // expected-warning {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute; type here is 'class UnlockableMu'}} //3. @@ -366,33 +366,33 @@ int gb_var_arg_bad_4 __attribute__((guarded_by(umu))); // \ int *pgb_var_noargs __attribute__((pt_guarded_by)); // \ // expected-error {{attribute takes one argument}} -int *pgb_ptr_var_arg __attribute__((pt_guarded_by(mu1))); +int *pgb_ptr_var_arg PT_GUARDED_BY(mu1); -int *pgb_ptr_var_args __attribute__((guarded_by(mu1, mu2))); // \ +int *pgb_ptr_var_args __attribute__((pt_guarded_by(mu1, mu2))); // \ // expected-error {{attribute takes one argument}} -int pgb_var_args __attribute__((pt_guarded_by(mu1))); // \ +int pgb_var_args PT_GUARDED_BY(mu1); // \ // expected-warning {{'pt_guarded_by' only applies to pointer types; type here is 'int'}} class PGBFoo { private: int *pgb_field_noargs __attribute__((pt_guarded_by)); // \ // expected-error {{attribute takes one argument}} - int *pgb_field_args __attribute__((pt_guarded_by(mu1))); + int *pgb_field_args PT_GUARDED_BY(mu1); }; -class __attribute__((pt_guarded_by(mu1))) PGB { // \ +class PT_GUARDED_BY(mu1) PGB { // \ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}} }; -void pgb_function() __attribute__((pt_guarded_by(mu1))); // \ +void pgb_function() PT_GUARDED_BY(mu1); // \ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}} -void pgb_function_params(int gv_lvar __attribute__((pt_guarded_by(mu1)))); // \ +void pgb_function_params(int gv_lvar PT_GUARDED_BY(mu1)); // \ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}} void pgb_testfn(int y){ - int *x __attribute__((pt_guarded_by(mu1))) = new int(0); // \ + int *x PT_GUARDED_BY(mu1) = new int(0); // \ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}} delete x; } @@ -400,24 +400,24 @@ void pgb_testfn(int y){ //2. Check argument parsing. // legal attribute arguments -int * pgb_var_arg_1 __attribute__((pt_guarded_by(muWrapper.mu))); -int * pgb_var_arg_2 __attribute__((pt_guarded_by(muDoubleWrapper.muWrapper->mu))); -int * pgb_var_arg_3 __attribute__((pt_guarded_by(muWrapper.getMu()))); -int * pgb_var_arg_4 __attribute__((pt_guarded_by(*muWrapper.getMuPointer()))); -int * pgb_var_arg_5 __attribute__((pt_guarded_by(&mu1))); -int * pgb_var_arg_6 __attribute__((pt_guarded_by(muRef))); -int * pgb_var_arg_7 __attribute__((pt_guarded_by(muDoubleWrapper.getWrapper()->getMu()))); -int * pgb_var_arg_8 __attribute__((pt_guarded_by(muPointer))); +int * pgb_var_arg_1 PT_GUARDED_BY(muWrapper.mu); +int * pgb_var_arg_2 PT_GUARDED_BY(muDoubleWrapper.muWrapper->mu); +int * pgb_var_arg_3 PT_GUARDED_BY(muWrapper.getMu()); +int * pgb_var_arg_4 PT_GUARDED_BY(*muWrapper.getMuPointer()); +int * pgb_var_arg_5 PT_GUARDED_BY(&mu1); +int * pgb_var_arg_6 PT_GUARDED_BY(muRef); +int * pgb_var_arg_7 PT_GUARDED_BY(muDoubleWrapper.getWrapper()->getMu()); +int * pgb_var_arg_8 PT_GUARDED_BY(muPointer); // illegal attribute arguments -int * pgb_var_arg_bad_1 __attribute__((pt_guarded_by(1))); // \ +int * pgb_var_arg_bad_1 PT_GUARDED_BY(1); // \ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}} -int * pgb_var_arg_bad_2 __attribute__((pt_guarded_by("mu"))); // \ +int * pgb_var_arg_bad_2 PT_GUARDED_BY("mu"); // \ // expected-warning {{ignoring 'pt_guarded_by' attribute because its argument is invalid}} -int * pgb_var_arg_bad_3 __attribute__((pt_guarded_by(muDoublePointer))); // \ +int * pgb_var_arg_bad_3 PT_GUARDED_BY(muDoublePointer); // \ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}} -int * pgb_var_arg_bad_4 __attribute__((pt_guarded_by(umu))); // \ +int * pgb_var_arg_bad_4 PT_GUARDED_BY(umu); // \ // expected-warning {{'pt_guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -431,56 +431,56 @@ int * pgb_var_arg_bad_4 __attribute__((pt_guarded_by(umu))); // \ #error "Should support acquired_after attribute" #endif -Mu mu_aa __attribute__((acquired_after(mu1))); +Mutex mu_aa ACQUIRED_AFTER(mu1); -Mu aa_var_noargs __attribute__((acquired_after)); // \ +Mutex aa_var_noargs __attribute__((acquired_after)); // \ // expected-error {{attribute takes at least 1 argument}} class AAFoo { private: - Mu aa_field_noargs __attribute__((acquired_after)); // \ + Mutex aa_field_noargs __attribute__((acquired_after)); // \ // expected-error {{attribute takes at least 1 argument}} - Mu aa_field_args __attribute__((acquired_after(mu1))); + Mutex aa_field_args ACQUIRED_AFTER(mu1); }; -class __attribute__((acquired_after(mu1))) AA { // \ +class ACQUIRED_AFTER(mu1) AA { // \ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}} }; -void aa_function() __attribute__((acquired_after(mu1))); // \ +void aa_function() ACQUIRED_AFTER(mu1); // \ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}} -void aa_function_params(int gv_lvar __attribute__((acquired_after(mu1)))); // \ +void aa_function_params(int gv_lvar ACQUIRED_AFTER(mu1)); // \ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}} void aa_testfn(int y){ - Mu x __attribute__((acquired_after(mu1))) = Mu(); // \ + Mutex x ACQUIRED_AFTER(mu1) = Mutex(); // \ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}} } //Check argument parsing. // legal attribute arguments -Mu aa_var_arg_1 __attribute__((acquired_after(muWrapper.mu))); -Mu aa_var_arg_2 __attribute__((acquired_after(muDoubleWrapper.muWrapper->mu))); -Mu aa_var_arg_3 __attribute__((acquired_after(muWrapper.getMu()))); -Mu aa_var_arg_4 __attribute__((acquired_after(*muWrapper.getMuPointer()))); -Mu aa_var_arg_5 __attribute__((acquired_after(&mu1))); -Mu aa_var_arg_6 __attribute__((acquired_after(muRef))); -Mu aa_var_arg_7 __attribute__((acquired_after(muDoubleWrapper.getWrapper()->getMu()))); -Mu aa_var_arg_8 __attribute__((acquired_after(muPointer))); +Mutex aa_var_arg_1 ACQUIRED_AFTER(muWrapper.mu); +Mutex aa_var_arg_2 ACQUIRED_AFTER(muDoubleWrapper.muWrapper->mu); +Mutex aa_var_arg_3 ACQUIRED_AFTER(muWrapper.getMu()); +Mutex aa_var_arg_4 ACQUIRED_AFTER(*muWrapper.getMuPointer()); +Mutex aa_var_arg_5 ACQUIRED_AFTER(&mu1); +Mutex aa_var_arg_6 ACQUIRED_AFTER(muRef); +Mutex aa_var_arg_7 ACQUIRED_AFTER(muDoubleWrapper.getWrapper()->getMu()); +Mutex aa_var_arg_8 ACQUIRED_AFTER(muPointer); // illegal attribute arguments -Mu aa_var_arg_bad_1 __attribute__((acquired_after(1))); // \ +Mutex aa_var_arg_bad_1 ACQUIRED_AFTER(1); // \ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}} -Mu aa_var_arg_bad_2 __attribute__((acquired_after("mu"))); // \ +Mutex aa_var_arg_bad_2 ACQUIRED_AFTER("mu"); // \ // expected-warning {{ignoring 'acquired_after' attribute because its argument is invalid}} -Mu aa_var_arg_bad_3 __attribute__((acquired_after(muDoublePointer))); // \ +Mutex aa_var_arg_bad_3 ACQUIRED_AFTER(muDoublePointer); // \ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}} -Mu aa_var_arg_bad_4 __attribute__((acquired_after(umu))); // \ +Mutex aa_var_arg_bad_4 ACQUIRED_AFTER(umu); // \ // expected-warning {{'acquired_after' attribute requires arguments whose type is annotated with 'lockable' attribute}} -UnlockableMu aa_var_arg_bad_5 __attribute__((acquired_after(mu_aa))); // \ +UnlockableMu aa_var_arg_bad_5 ACQUIRED_AFTER(mu_aa); // \ // expected-warning {{'acquired_after' attribute can only be applied in a context annotated with 'lockable' attribute}} //-----------------------------------------// @@ -491,59 +491,59 @@ UnlockableMu aa_var_arg_bad_5 __attribute__((acquired_after(mu_aa))); // \ #error "Should support acquired_before attribute" #endif -Mu mu_ab __attribute__((acquired_before(mu1))); +Mutex mu_ab ACQUIRED_BEFORE(mu1); -Mu ab_var_noargs __attribute__((acquired_before)); // \ +Mutex ab_var_noargs __attribute__((acquired_before)); // \ // expected-error {{attribute takes at least 1 argument}} class ABFoo { private: - Mu ab_field_noargs __attribute__((acquired_before)); // \ + Mutex ab_field_noargs __attribute__((acquired_before)); // \ // expected-error {{attribute takes at least 1 argument}} - Mu ab_field_args __attribute__((acquired_before(mu1))); + Mutex ab_field_args ACQUIRED_BEFORE(mu1); }; -class __attribute__((acquired_before(mu1))) AB { // \ +class ACQUIRED_BEFORE(mu1) AB { // \ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}} }; -void ab_function() __attribute__((acquired_before(mu1))); // \ +void ab_function() ACQUIRED_BEFORE(mu1); // \ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}} -void ab_function_params(int gv_lvar __attribute__((acquired_before(mu1)))); // \ +void ab_function_params(int gv_lvar ACQUIRED_BEFORE(mu1)); // \ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}} void ab_testfn(int y){ - Mu x __attribute__((acquired_before(mu1))) = Mu(); // \ + Mutex x ACQUIRED_BEFORE(mu1) = Mutex(); // \ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}} } -// Note: illegal int ab_int __attribute__((acquired_before(mu1))) will +// Note: illegal int ab_int ACQUIRED_BEFORE(mu1) will // be taken care of by warnings that ab__int is not lockable. //Check argument parsing. // legal attribute arguments -Mu ab_var_arg_1 __attribute__((acquired_before(muWrapper.mu))); -Mu ab_var_arg_2 __attribute__((acquired_before(muDoubleWrapper.muWrapper->mu))); -Mu ab_var_arg_3 __attribute__((acquired_before(muWrapper.getMu()))); -Mu ab_var_arg_4 __attribute__((acquired_before(*muWrapper.getMuPointer()))); -Mu ab_var_arg_5 __attribute__((acquired_before(&mu1))); -Mu ab_var_arg_6 __attribute__((acquired_before(muRef))); -Mu ab_var_arg_7 __attribute__((acquired_before(muDoubleWrapper.getWrapper()->getMu()))); -Mu ab_var_arg_8 __attribute__((acquired_before(muPointer))); +Mutex ab_var_arg_1 ACQUIRED_BEFORE(muWrapper.mu); +Mutex ab_var_arg_2 ACQUIRED_BEFORE(muDoubleWrapper.muWrapper->mu); +Mutex ab_var_arg_3 ACQUIRED_BEFORE(muWrapper.getMu()); +Mutex ab_var_arg_4 ACQUIRED_BEFORE(*muWrapper.getMuPointer()); +Mutex ab_var_arg_5 ACQUIRED_BEFORE(&mu1); +Mutex ab_var_arg_6 ACQUIRED_BEFORE(muRef); +Mutex ab_var_arg_7 ACQUIRED_BEFORE(muDoubleWrapper.getWrapper()->getMu()); +Mutex ab_var_arg_8 ACQUIRED_BEFORE(muPointer); // illegal attribute arguments -Mu ab_var_arg_bad_1 __attribute__((acquired_before(1))); // \ +Mutex ab_var_arg_bad_1 ACQUIRED_BEFORE(1); // \ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}} -Mu ab_var_arg_bad_2 __attribute__((acquired_before("mu"))); // \ +Mutex ab_var_arg_bad_2 ACQUIRED_BEFORE("mu"); // \ // expected-warning {{ignoring 'acquired_before' attribute because its argument is invalid}} -Mu ab_var_arg_bad_3 __attribute__((acquired_before(muDoublePointer))); // \ +Mutex ab_var_arg_bad_3 ACQUIRED_BEFORE(muDoublePointer); // \ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}} -Mu ab_var_arg_bad_4 __attribute__((acquired_before(umu))); // \ +Mutex ab_var_arg_bad_4 ACQUIRED_BEFORE(umu); // \ // expected-warning {{'acquired_before' attribute requires arguments whose type is annotated with 'lockable' attribute}} -UnlockableMu ab_var_arg_bad_5 __attribute__((acquired_before(mu_ab))); // \ +UnlockableMu ab_var_arg_bad_5 ACQUIRED_BEFORE(mu_ab); // \ // expected-warning {{'acquired_before' attribute can only be applied in a context annotated with 'lockable' attribute}} @@ -557,65 +557,65 @@ UnlockableMu ab_var_arg_bad_5 __attribute__((acquired_before(mu_ab))); // \ // takes zero or more arguments, all locks (vars/fields) -void elf_function() __attribute__((exclusive_lock_function)); +void elf_function() EXCLUSIVE_LOCK_FUNCTION(); -void elf_function_args() __attribute__((exclusive_lock_function(mu1, mu2))); +void elf_function_args() EXCLUSIVE_LOCK_FUNCTION(mu1, mu2); -int elf_testfn(int y) __attribute__((exclusive_lock_function)); +int elf_testfn(int y) EXCLUSIVE_LOCK_FUNCTION(); int elf_testfn(int y) { - int x __attribute__((exclusive_lock_function)) = y; // \ + int x EXCLUSIVE_LOCK_FUNCTION() = y; // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} return x; }; -int elf_test_var __attribute__((exclusive_lock_function)); // \ +int elf_test_var EXCLUSIVE_LOCK_FUNCTION(); // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} class ElfFoo { private: - int test_field __attribute__((exclusive_lock_function)); // \ + int test_field EXCLUSIVE_LOCK_FUNCTION(); // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} - void test_method() __attribute__((exclusive_lock_function)); + void test_method() EXCLUSIVE_LOCK_FUNCTION(); }; -class __attribute__((exclusive_lock_function)) ElfTestClass { // \ +class EXCLUSIVE_LOCK_FUNCTION() ElfTestClass { // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} }; -void elf_fun_params(int lvar __attribute__((exclusive_lock_function))); // \ +void elf_fun_params(int lvar EXCLUSIVE_LOCK_FUNCTION()); // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} // Check argument parsing. // legal attribute arguments -int elf_function_1() __attribute__((exclusive_lock_function(muWrapper.mu))); -int elf_function_2() __attribute__((exclusive_lock_function(muDoubleWrapper.muWrapper->mu))); -int elf_function_3() __attribute__((exclusive_lock_function(muWrapper.getMu()))); -int elf_function_4() __attribute__((exclusive_lock_function(*muWrapper.getMuPointer()))); -int elf_function_5() __attribute__((exclusive_lock_function(&mu1))); -int elf_function_6() __attribute__((exclusive_lock_function(muRef))); -int elf_function_7() __attribute__((exclusive_lock_function(muDoubleWrapper.getWrapper()->getMu()))); -int elf_function_8() __attribute__((exclusive_lock_function(muPointer))); -int elf_function_9(Mu x) __attribute__((exclusive_lock_function(1))); -int elf_function_9(Mu x, Mu y) __attribute__((exclusive_lock_function(1,2))); +int elf_function_1() EXCLUSIVE_LOCK_FUNCTION(muWrapper.mu); +int elf_function_2() EXCLUSIVE_LOCK_FUNCTION(muDoubleWrapper.muWrapper->mu); +int elf_function_3() EXCLUSIVE_LOCK_FUNCTION(muWrapper.getMu()); +int elf_function_4() EXCLUSIVE_LOCK_FUNCTION(*muWrapper.getMuPointer()); +int elf_function_5() EXCLUSIVE_LOCK_FUNCTION(&mu1); +int elf_function_6() EXCLUSIVE_LOCK_FUNCTION(muRef); +int elf_function_7() EXCLUSIVE_LOCK_FUNCTION(muDoubleWrapper.getWrapper()->getMu()); +int elf_function_8() EXCLUSIVE_LOCK_FUNCTION(muPointer); +int elf_function_9(Mutex x) EXCLUSIVE_LOCK_FUNCTION(1); +int elf_function_9(Mutex x, Mutex y) EXCLUSIVE_LOCK_FUNCTION(1,2); // illegal attribute arguments -int elf_function_bad_2() __attribute__((exclusive_lock_function("mu"))); // \ +int elf_function_bad_2() EXCLUSIVE_LOCK_FUNCTION("mu"); // \ // expected-warning {{ignoring 'exclusive_lock_function' attribute because its argument is invalid}} -int elf_function_bad_3() __attribute__((exclusive_lock_function(muDoublePointer))); // \ +int elf_function_bad_3() EXCLUSIVE_LOCK_FUNCTION(muDoublePointer); // \ // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}} -int elf_function_bad_4() __attribute__((exclusive_lock_function(umu))); // \ +int elf_function_bad_4() EXCLUSIVE_LOCK_FUNCTION(umu); // \ // expected-warning {{'exclusive_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}} -int elf_function_bad_1() __attribute__((exclusive_lock_function(1))); // \ +int elf_function_bad_1() EXCLUSIVE_LOCK_FUNCTION(1); // \ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}} -int elf_function_bad_5(Mu x) __attribute__((exclusive_lock_function(0))); // \ +int elf_function_bad_5(Mutex x) EXCLUSIVE_LOCK_FUNCTION(0); // \ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: can only be 1, since there is one parameter}} -int elf_function_bad_6(Mu x, Mu y) __attribute__((exclusive_lock_function(0))); // \ +int elf_function_bad_6(Mutex x, Mutex y) EXCLUSIVE_LOCK_FUNCTION(0); // \ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: must be between 1 and 2}} -int elf_function_bad_7() __attribute__((exclusive_lock_function(0))); // \ +int elf_function_bad_7() EXCLUSIVE_LOCK_FUNCTION(0); // \ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}} @@ -629,65 +629,65 @@ int elf_function_bad_7() __attribute__((exclusive_lock_function(0))); // \ // takes zero or more arguments, all locks (vars/fields) -void slf_function() __attribute__((shared_lock_function)); +void slf_function() SHARED_LOCK_FUNCTION(); -void slf_function_args() __attribute__((shared_lock_function(mu1, mu2))); +void slf_function_args() SHARED_LOCK_FUNCTION(mu1, mu2); -int slf_testfn(int y) __attribute__((shared_lock_function)); +int slf_testfn(int y) SHARED_LOCK_FUNCTION(); int slf_testfn(int y) { - int x __attribute__((shared_lock_function)) = y; // \ + int x SHARED_LOCK_FUNCTION() = y; // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} return x; }; -int slf_test_var __attribute__((shared_lock_function)); // \ +int slf_test_var SHARED_LOCK_FUNCTION(); // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} -void slf_fun_params(int lvar __attribute__((shared_lock_function))); // \ +void slf_fun_params(int lvar SHARED_LOCK_FUNCTION()); // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} class SlfFoo { private: - int test_field __attribute__((shared_lock_function)); // \ + int test_field SHARED_LOCK_FUNCTION(); // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} - void test_method() __attribute__((shared_lock_function)); + void test_method() SHARED_LOCK_FUNCTION(); }; -class __attribute__((shared_lock_function)) SlfTestClass { // \ +class SHARED_LOCK_FUNCTION() SlfTestClass { // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} }; // Check argument parsing. // legal attribute arguments -int slf_function_1() __attribute__((shared_lock_function(muWrapper.mu))); -int slf_function_2() __attribute__((shared_lock_function(muDoubleWrapper.muWrapper->mu))); -int slf_function_3() __attribute__((shared_lock_function(muWrapper.getMu()))); -int slf_function_4() __attribute__((shared_lock_function(*muWrapper.getMuPointer()))); -int slf_function_5() __attribute__((shared_lock_function(&mu1))); -int slf_function_6() __attribute__((shared_lock_function(muRef))); -int slf_function_7() __attribute__((shared_lock_function(muDoubleWrapper.getWrapper()->getMu()))); -int slf_function_8() __attribute__((shared_lock_function(muPointer))); -int slf_function_9(Mu x) __attribute__((shared_lock_function(1))); -int slf_function_9(Mu x, Mu y) __attribute__((shared_lock_function(1,2))); +int slf_function_1() SHARED_LOCK_FUNCTION(muWrapper.mu); +int slf_function_2() SHARED_LOCK_FUNCTION(muDoubleWrapper.muWrapper->mu); +int slf_function_3() SHARED_LOCK_FUNCTION(muWrapper.getMu()); +int slf_function_4() SHARED_LOCK_FUNCTION(*muWrapper.getMuPointer()); +int slf_function_5() SHARED_LOCK_FUNCTION(&mu1); +int slf_function_6() SHARED_LOCK_FUNCTION(muRef); +int slf_function_7() SHARED_LOCK_FUNCTION(muDoubleWrapper.getWrapper()->getMu()); +int slf_function_8() SHARED_LOCK_FUNCTION(muPointer); +int slf_function_9(Mutex x) SHARED_LOCK_FUNCTION(1); +int slf_function_9(Mutex x, Mutex y) SHARED_LOCK_FUNCTION(1,2); // illegal attribute arguments -int slf_function_bad_2() __attribute__((shared_lock_function("mu"))); // \ +int slf_function_bad_2() SHARED_LOCK_FUNCTION("mu"); // \ // expected-warning {{ignoring 'shared_lock_function' attribute because its argument is invalid}} -int slf_function_bad_3() __attribute__((shared_lock_function(muDoublePointer))); // \ +int slf_function_bad_3() SHARED_LOCK_FUNCTION(muDoublePointer); // \ // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}} -int slf_function_bad_4() __attribute__((shared_lock_function(umu))); // \ +int slf_function_bad_4() SHARED_LOCK_FUNCTION(umu); // \ // expected-warning {{'shared_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}} -int slf_function_bad_1() __attribute__((shared_lock_function(1))); // \ +int slf_function_bad_1() SHARED_LOCK_FUNCTION(1); // \ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}} -int slf_function_bad_5(Mu x) __attribute__((shared_lock_function(0))); // \ +int slf_function_bad_5(Mutex x) SHARED_LOCK_FUNCTION(0); // \ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: can only be 1, since there is one parameter}} -int slf_function_bad_6(Mu x, Mu y) __attribute__((shared_lock_function(0))); // \ +int slf_function_bad_6(Mutex x, Mutex y) SHARED_LOCK_FUNCTION(0); // \ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: must be between 1 and 2}} -int slf_function_bad_7() __attribute__((shared_lock_function(0))); // \ +int slf_function_bad_7() SHARED_LOCK_FUNCTION(0); // \ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}} @@ -705,62 +705,62 @@ int slf_function_bad_7() __attribute__((shared_lock_function(0))); // \ void etf_function() __attribute__((exclusive_trylock_function)); // \ // expected-error {{attribute takes at least 1 argument}} -void etf_function_args() __attribute__((exclusive_trylock_function(1, mu2))); +void etf_function_args() EXCLUSIVE_TRYLOCK_FUNCTION(1, mu2); -void etf_function_arg() __attribute__((exclusive_trylock_function(1))); +void etf_function_arg() EXCLUSIVE_TRYLOCK_FUNCTION(1); -int etf_testfn(int y) __attribute__((exclusive_trylock_function(1))); +int etf_testfn(int y) EXCLUSIVE_TRYLOCK_FUNCTION(1); int etf_testfn(int y) { - int x __attribute__((exclusive_trylock_function(1))) = y; // \ + int x EXCLUSIVE_TRYLOCK_FUNCTION(1) = y; // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} return x; }; -int etf_test_var __attribute__((exclusive_trylock_function(1))); // \ +int etf_test_var EXCLUSIVE_TRYLOCK_FUNCTION(1); // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} class EtfFoo { private: - int test_field __attribute__((exclusive_trylock_function(1))); // \ + int test_field EXCLUSIVE_TRYLOCK_FUNCTION(1); // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} - void test_method() __attribute__((exclusive_trylock_function(1))); + void test_method() EXCLUSIVE_TRYLOCK_FUNCTION(1); }; -class __attribute__((exclusive_trylock_function(1))) EtfTestClass { // \ +class EXCLUSIVE_TRYLOCK_FUNCTION(1) EtfTestClass { // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} }; -void etf_fun_params(int lvar __attribute__((exclusive_trylock_function(1)))); // \ +void etf_fun_params(int lvar EXCLUSIVE_TRYLOCK_FUNCTION(1)); // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} // Check argument parsing. // legal attribute arguments -int etf_function_1() __attribute__((exclusive_trylock_function(1, muWrapper.mu))); -int etf_function_2() __attribute__((exclusive_trylock_function(1, muDoubleWrapper.muWrapper->mu))); -int etf_function_3() __attribute__((exclusive_trylock_function(1, muWrapper.getMu()))); -int etf_function_4() __attribute__((exclusive_trylock_function(1, *muWrapper.getMuPointer()))); -int etf_function_5() __attribute__((exclusive_trylock_function(1, &mu1))); -int etf_function_6() __attribute__((exclusive_trylock_function(1, muRef))); -int etf_function_7() __attribute__((exclusive_trylock_function(1, muDoubleWrapper.getWrapper()->getMu()))); -int etf_functetfn_8() __attribute__((exclusive_trylock_function(1, muPointer))); -int etf_function_9() __attribute__((exclusive_trylock_function(true))); +int etf_function_1() EXCLUSIVE_TRYLOCK_FUNCTION(1, muWrapper.mu); +int etf_function_2() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoubleWrapper.muWrapper->mu); +int etf_function_3() EXCLUSIVE_TRYLOCK_FUNCTION(1, muWrapper.getMu()); +int etf_function_4() EXCLUSIVE_TRYLOCK_FUNCTION(1, *muWrapper.getMuPointer()); +int etf_function_5() EXCLUSIVE_TRYLOCK_FUNCTION(1, &mu1); +int etf_function_6() EXCLUSIVE_TRYLOCK_FUNCTION(1, muRef); +int etf_function_7() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoubleWrapper.getWrapper()->getMu()); +int etf_functetfn_8() EXCLUSIVE_TRYLOCK_FUNCTION(1, muPointer); +int etf_function_9() EXCLUSIVE_TRYLOCK_FUNCTION(true); // illegal attribute arguments -int etf_function_bad_1() __attribute__((exclusive_trylock_function(mu1))); // \ +int etf_function_bad_1() EXCLUSIVE_TRYLOCK_FUNCTION(mu1); // \ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}} -int etf_function_bad_2() __attribute__((exclusive_trylock_function("mu"))); // \ +int etf_function_bad_2() EXCLUSIVE_TRYLOCK_FUNCTION("mu"); // \ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}} -int etf_function_bad_3() __attribute__((exclusive_trylock_function(muDoublePointer))); // \ +int etf_function_bad_3() EXCLUSIVE_TRYLOCK_FUNCTION(muDoublePointer); // \ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}} -int etf_function_bad_4() __attribute__((exclusive_trylock_function(1, "mu"))); // \ +int etf_function_bad_4() EXCLUSIVE_TRYLOCK_FUNCTION(1, "mu"); // \ // expected-warning {{ignoring 'exclusive_trylock_function' attribute because its argument is invalid}} -int etf_function_bad_5() __attribute__((exclusive_trylock_function(1, muDoublePointer))); // \ +int etf_function_bad_5() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoublePointer); // \ // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}} -int etf_function_bad_6() __attribute__((exclusive_trylock_function(1, umu))); // \ +int etf_function_bad_6() EXCLUSIVE_TRYLOCK_FUNCTION(1, umu); // \ // expected-warning {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -778,63 +778,63 @@ int etf_function_bad_6() __attribute__((excl |