|
1 | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
|
2 | 2 | // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
|
3 |
| -// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s -D CPP11 |
| 3 | +// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s |
4 | 4 |
|
5 | 5 | #define LOCKABLE __attribute__ ((lockable))
|
6 | 6 | #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
|
@@ -643,6 +643,24 @@ int elf_function_bad_6(Mutex x, Mutex y) EXCLUSIVE_LOCK_FUNCTION(0); // \
|
643 | 643 | int elf_function_bad_7() EXCLUSIVE_LOCK_FUNCTION(0); // \
|
644 | 644 | // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
|
645 | 645 |
|
| 646 | +template<typename Mu> |
| 647 | +int elf_template(Mu& mu) EXCLUSIVE_LOCK_FUNCTION(mu) {} |
| 648 | + |
| 649 | +template int elf_template<Mutex>(Mutex&); |
| 650 | +// FIXME: warn on template instantiation. |
| 651 | +template int elf_template<UnlockableMu>(UnlockableMu&); |
| 652 | + |
| 653 | +#if __cplusplus >= 201103 |
| 654 | + |
| 655 | +template<typename... Mus> |
| 656 | +int elf_variadic_template(Mus&... mus) EXCLUSIVE_LOCK_FUNCTION(mus...) {} |
| 657 | + |
| 658 | +template int elf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 659 | +// FIXME: warn on template instantiation. |
| 660 | +template int elf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 661 | + |
| 662 | +#endif |
| 663 | + |
646 | 664 |
|
647 | 665 | //-----------------------------------------//
|
648 | 666 | // Shared Lock Function (slf)
|
@@ -719,6 +737,24 @@ int slf_function_bad_6(Mutex x, Mutex y) SHARED_LOCK_FUNCTION(0); // \
|
719 | 737 | int slf_function_bad_7() SHARED_LOCK_FUNCTION(0); // \
|
720 | 738 | // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
|
721 | 739 |
|
| 740 | +template<typename Mu> |
| 741 | +int slf_template(Mu& mu) SHARED_LOCK_FUNCTION(mu) {} |
| 742 | + |
| 743 | +template int slf_template<Mutex>(Mutex&); |
| 744 | +// FIXME: warn on template instantiation. |
| 745 | +template int slf_template<UnlockableMu>(UnlockableMu&); |
| 746 | + |
| 747 | +#if __cplusplus >= 201103 |
| 748 | + |
| 749 | +template<typename... Mus> |
| 750 | +int slf_variadic_template(Mus&... mus) SHARED_LOCK_FUNCTION(mus...) {} |
| 751 | + |
| 752 | +template int slf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 753 | +// FIXME: warn on template instantiation. |
| 754 | +template int slf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 755 | + |
| 756 | +#endif |
| 757 | + |
722 | 758 |
|
723 | 759 | //-----------------------------------------//
|
724 | 760 | // Exclusive TryLock Function (etf)
|
@@ -796,6 +832,24 @@ int etf_function_bad_5() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoublePointer); // \
|
796 | 832 | int etf_function_bad_6() EXCLUSIVE_TRYLOCK_FUNCTION(1, umu); // \
|
797 | 833 | // expected-warning {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
798 | 834 |
|
| 835 | +template<typename Mu> |
| 836 | +int etf_template(Mu& mu) EXCLUSIVE_TRYLOCK_FUNCTION(1, mu) {} |
| 837 | + |
| 838 | +template int etf_template<Mutex>(Mutex&); |
| 839 | +// FIXME: warn on template instantiation. |
| 840 | +template int etf_template<UnlockableMu>(UnlockableMu&); |
| 841 | + |
| 842 | +#if __cplusplus >= 201103 |
| 843 | + |
| 844 | +template<typename... Mus> |
| 845 | +int etf_variadic_template(Mus&... mus) EXCLUSIVE_TRYLOCK_FUNCTION(1, mus...) {} |
| 846 | + |
| 847 | +template int etf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 848 | +// FIXME: warn on template instantiation. |
| 849 | +template int etf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 850 | + |
| 851 | +#endif |
| 852 | + |
799 | 853 |
|
800 | 854 | //-----------------------------------------//
|
801 | 855 | // Shared TryLock Function (stf)
|
@@ -874,6 +928,24 @@ int stf_function_bad_5() SHARED_TRYLOCK_FUNCTION(1, muDoublePointer); // \
|
874 | 928 | int stf_function_bad_6() SHARED_TRYLOCK_FUNCTION(1, umu); // \
|
875 | 929 | // expected-warning {{'shared_trylock_function' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
876 | 930 |
|
| 931 | +template<typename Mu> |
| 932 | +int stf_template(Mu& mu) SHARED_TRYLOCK_FUNCTION(1, mu) {} |
| 933 | + |
| 934 | +template int stf_template<Mutex>(Mutex&); |
| 935 | +// FIXME: warn on template instantiation. |
| 936 | +template int stf_template<UnlockableMu>(UnlockableMu&); |
| 937 | + |
| 938 | +#if __cplusplus >= 201103 |
| 939 | + |
| 940 | +template<typename... Mus> |
| 941 | +int stf_variadic_template(Mus&... mus) SHARED_TRYLOCK_FUNCTION(1, mus...) {} |
| 942 | + |
| 943 | +template int stf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 944 | +// FIXME: warn on template instantiation. |
| 945 | +template int stf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 946 | + |
| 947 | +#endif |
| 948 | + |
877 | 949 |
|
878 | 950 | //-----------------------------------------//
|
879 | 951 | // Unlock Function (uf)
|
@@ -953,6 +1025,24 @@ int uf_function_bad_6(Mutex x, Mutex y) UNLOCK_FUNCTION(0); // \
|
953 | 1025 | int uf_function_bad_7() UNLOCK_FUNCTION(0); // \
|
954 | 1026 | // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
|
955 | 1027 |
|
| 1028 | +template<typename Mu> |
| 1029 | +int uf_template(Mu& mu) UNLOCK_FUNCTION(mu) {} |
| 1030 | + |
| 1031 | +template int uf_template<Mutex>(Mutex&); |
| 1032 | +// FIXME: warn on template instantiation. |
| 1033 | +template int uf_template<UnlockableMu>(UnlockableMu&); |
| 1034 | + |
| 1035 | +#if __cplusplus >= 201103 |
| 1036 | + |
| 1037 | +template<typename... Mus> |
| 1038 | +int uf_variadic_template(Mus&... mus) UNLOCK_FUNCTION(mus...) {} |
| 1039 | + |
| 1040 | +template int uf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 1041 | +// FIXME: warn on template instantiation. |
| 1042 | +template int uf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 1043 | + |
| 1044 | +#endif |
| 1045 | + |
956 | 1046 |
|
957 | 1047 | //-----------------------------------------//
|
958 | 1048 | // Lock Returned (lr)
|
@@ -1088,6 +1178,23 @@ int le_function_bad_3() LOCKS_EXCLUDED(muDoublePointer); // \
|
1088 | 1178 | int le_function_bad_4() LOCKS_EXCLUDED(umu); // \
|
1089 | 1179 | // expected-warning {{'locks_excluded' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
1090 | 1180 |
|
| 1181 | +template<typename Mu> |
| 1182 | +int le_template(Mu& mu) LOCKS_EXCLUDED(mu) {} |
| 1183 | + |
| 1184 | +template int le_template<Mutex>(Mutex&); |
| 1185 | +// FIXME: warn on template instantiation. |
| 1186 | +template int le_template<UnlockableMu>(UnlockableMu&); |
| 1187 | + |
| 1188 | +#if __cplusplus >= 201103 |
| 1189 | + |
| 1190 | +template<typename... Mus> |
| 1191 | +int le_variadic_template(Mus&... mus) LOCKS_EXCLUDED(mus...) {} |
| 1192 | + |
| 1193 | +template int le_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 1194 | +// FIXME: warn on template instantiation. |
| 1195 | +template int le_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 1196 | + |
| 1197 | +#endif |
1091 | 1198 |
|
1092 | 1199 |
|
1093 | 1200 | //-----------------------------------------//
|
@@ -1156,6 +1263,24 @@ int elr_function_bad_3() EXCLUSIVE_LOCKS_REQUIRED(muDoublePointer); // \
|
1156 | 1263 | int elr_function_bad_4() EXCLUSIVE_LOCKS_REQUIRED(umu); // \
|
1157 | 1264 | // expected-warning {{'exclusive_locks_required' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
1158 | 1265 |
|
| 1266 | +template<typename Mu> |
| 1267 | +int elr_template(Mu& mu) EXCLUSIVE_LOCKS_REQUIRED(mu) {} |
| 1268 | + |
| 1269 | +template int elr_template<Mutex>(Mutex&); |
| 1270 | +// FIXME: warn on template instantiation. |
| 1271 | +template int elr_template<UnlockableMu>(UnlockableMu&); |
| 1272 | + |
| 1273 | +#if __cplusplus >= 201103 |
| 1274 | + |
| 1275 | +template<typename... Mus> |
| 1276 | +int elr_variadic_template(Mus&... mus) EXCLUSIVE_LOCKS_REQUIRED(mus...) {} |
| 1277 | + |
| 1278 | +template int elr_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 1279 | +// FIXME: warn on template instantiation. |
| 1280 | +template int elr_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 1281 | + |
| 1282 | +#endif |
| 1283 | + |
1159 | 1284 |
|
1160 | 1285 |
|
1161 | 1286 |
|
@@ -1225,6 +1350,24 @@ int slr_function_bad_3() SHARED_LOCKS_REQUIRED(muDoublePointer); // \
|
1225 | 1350 | int slr_function_bad_4() SHARED_LOCKS_REQUIRED(umu); // \
|
1226 | 1351 | // expected-warning {{'shared_locks_required' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
1227 | 1352 |
|
| 1353 | +template<typename Mu> |
| 1354 | +int slr_template(Mu& mu) SHARED_LOCKS_REQUIRED(mu) {} |
| 1355 | + |
| 1356 | +template int slr_template<Mutex>(Mutex&); |
| 1357 | +// FIXME: warn on template instantiation. |
| 1358 | +template int slr_template<UnlockableMu>(UnlockableMu&); |
| 1359 | + |
| 1360 | +#if __cplusplus >= 201103 |
| 1361 | + |
| 1362 | +template<typename... Mus> |
| 1363 | +int slr_variadic_template(Mus&... mus) SHARED_LOCKS_REQUIRED(mus...) {} |
| 1364 | + |
| 1365 | +template int slr_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 1366 | +// FIXME: warn on template instantiation. |
| 1367 | +template int slr_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 1368 | + |
| 1369 | +#endif |
| 1370 | + |
1228 | 1371 |
|
1229 | 1372 | //-----------------------------------------//
|
1230 | 1373 | // Regression tests for unusual cases.
|
@@ -1582,7 +1725,7 @@ class Foo {
|
1582 | 1725 | } // end namespace FunctionAttributesInsideClass_ICE_Test
|
1583 | 1726 |
|
1584 | 1727 |
|
1585 |
| -#ifdef CPP11 |
| 1728 | +#if __cplusplus >= 201103 |
1586 | 1729 | namespace CRASH_POST_R301735 {
|
1587 | 1730 | class SomeClass {
|
1588 | 1731 | public:
|
|
0 commit comments