|
1 |
| -// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -verify -Wthread-safety %s |
2 |
| -// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -verify -Wthread-safety -std=c++98 %s |
3 |
| -// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -verify -Wthread-safety -std=c++11 %s -D CPP11 |
4 |
| - |
5 |
| -#include <warn-thread-safety-parsing.h> |
| 1 | +// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s |
| 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 |
6 | 4 |
|
7 | 5 | #define LOCKABLE __attribute__ ((lockable))
|
8 | 6 | #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
|
@@ -658,6 +656,24 @@ int elf_function_bad_6(Mutex x, Mutex y) EXCLUSIVE_LOCK_FUNCTION(0); // \
|
658 | 656 | int elf_function_bad_7() EXCLUSIVE_LOCK_FUNCTION(0); // \
|
659 | 657 | // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
|
660 | 658 |
|
| 659 | +template<typename Mu> |
| 660 | +int elf_template(Mu& mu) EXCLUSIVE_LOCK_FUNCTION(mu) {} |
| 661 | + |
| 662 | +template int elf_template<Mutex>(Mutex&); |
| 663 | +// FIXME: warn on template instantiation. |
| 664 | +template int elf_template<UnlockableMu>(UnlockableMu&); |
| 665 | + |
| 666 | +#if __cplusplus >= 201103 |
| 667 | + |
| 668 | +template<typename... Mus> |
| 669 | +int elf_variadic_template(Mus&... mus) EXCLUSIVE_LOCK_FUNCTION(mus...) {} |
| 670 | + |
| 671 | +template int elf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 672 | +// FIXME: warn on template instantiation. |
| 673 | +template int elf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 674 | + |
| 675 | +#endif |
| 676 | + |
661 | 677 |
|
662 | 678 | //-----------------------------------------//
|
663 | 679 | // Shared Lock Function (slf)
|
@@ -734,6 +750,24 @@ int slf_function_bad_6(Mutex x, Mutex y) SHARED_LOCK_FUNCTION(0); // \
|
734 | 750 | int slf_function_bad_7() SHARED_LOCK_FUNCTION(0); // \
|
735 | 751 | // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
|
736 | 752 |
|
| 753 | +template<typename Mu> |
| 754 | +int slf_template(Mu& mu) SHARED_LOCK_FUNCTION(mu) {} |
| 755 | + |
| 756 | +template int slf_template<Mutex>(Mutex&); |
| 757 | +// FIXME: warn on template instantiation. |
| 758 | +template int slf_template<UnlockableMu>(UnlockableMu&); |
| 759 | + |
| 760 | +#if __cplusplus >= 201103 |
| 761 | + |
| 762 | +template<typename... Mus> |
| 763 | +int slf_variadic_template(Mus&... mus) SHARED_LOCK_FUNCTION(mus...) {} |
| 764 | + |
| 765 | +template int slf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 766 | +// FIXME: warn on template instantiation. |
| 767 | +template int slf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 768 | + |
| 769 | +#endif |
| 770 | + |
737 | 771 |
|
738 | 772 | //-----------------------------------------//
|
739 | 773 | // Exclusive TryLock Function (etf)
|
@@ -811,6 +845,24 @@ int etf_function_bad_5() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoublePointer); // \
|
811 | 845 | int etf_function_bad_6() EXCLUSIVE_TRYLOCK_FUNCTION(1, umu); // \
|
812 | 846 | // expected-warning {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
813 | 847 |
|
| 848 | +template<typename Mu> |
| 849 | +int etf_template(Mu& mu) EXCLUSIVE_TRYLOCK_FUNCTION(1, mu) {} |
| 850 | + |
| 851 | +template int etf_template<Mutex>(Mutex&); |
| 852 | +// FIXME: warn on template instantiation. |
| 853 | +template int etf_template<UnlockableMu>(UnlockableMu&); |
| 854 | + |
| 855 | +#if __cplusplus >= 201103 |
| 856 | + |
| 857 | +template<typename... Mus> |
| 858 | +int etf_variadic_template(Mus&... mus) EXCLUSIVE_TRYLOCK_FUNCTION(1, mus...) {} |
| 859 | + |
| 860 | +template int etf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 861 | +// FIXME: warn on template instantiation. |
| 862 | +template int etf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 863 | + |
| 864 | +#endif |
| 865 | + |
814 | 866 |
|
815 | 867 | //-----------------------------------------//
|
816 | 868 | // Shared TryLock Function (stf)
|
@@ -889,6 +941,24 @@ int stf_function_bad_5() SHARED_TRYLOCK_FUNCTION(1, muDoublePointer); // \
|
889 | 941 | int stf_function_bad_6() SHARED_TRYLOCK_FUNCTION(1, umu); // \
|
890 | 942 | // expected-warning {{'shared_trylock_function' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
891 | 943 |
|
| 944 | +template<typename Mu> |
| 945 | +int stf_template(Mu& mu) SHARED_TRYLOCK_FUNCTION(1, mu) {} |
| 946 | + |
| 947 | +template int stf_template<Mutex>(Mutex&); |
| 948 | +// FIXME: warn on template instantiation. |
| 949 | +template int stf_template<UnlockableMu>(UnlockableMu&); |
| 950 | + |
| 951 | +#if __cplusplus >= 201103 |
| 952 | + |
| 953 | +template<typename... Mus> |
| 954 | +int stf_variadic_template(Mus&... mus) SHARED_TRYLOCK_FUNCTION(1, mus...) {} |
| 955 | + |
| 956 | +template int stf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 957 | +// FIXME: warn on template instantiation. |
| 958 | +template int stf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 959 | + |
| 960 | +#endif |
| 961 | + |
892 | 962 |
|
893 | 963 | //-----------------------------------------//
|
894 | 964 | // Unlock Function (uf)
|
@@ -968,6 +1038,24 @@ int uf_function_bad_6(Mutex x, Mutex y) UNLOCK_FUNCTION(0); // \
|
968 | 1038 | int uf_function_bad_7() UNLOCK_FUNCTION(0); // \
|
969 | 1039 | // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: no parameters to index into}}
|
970 | 1040 |
|
| 1041 | +template<typename Mu> |
| 1042 | +int uf_template(Mu& mu) UNLOCK_FUNCTION(mu) {} |
| 1043 | + |
| 1044 | +template int uf_template<Mutex>(Mutex&); |
| 1045 | +// FIXME: warn on template instantiation. |
| 1046 | +template int uf_template<UnlockableMu>(UnlockableMu&); |
| 1047 | + |
| 1048 | +#if __cplusplus >= 201103 |
| 1049 | + |
| 1050 | +template<typename... Mus> |
| 1051 | +int uf_variadic_template(Mus&... mus) UNLOCK_FUNCTION(mus...) {} |
| 1052 | + |
| 1053 | +template int uf_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 1054 | +// FIXME: warn on template instantiation. |
| 1055 | +template int uf_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 1056 | + |
| 1057 | +#endif |
| 1058 | + |
971 | 1059 |
|
972 | 1060 | //-----------------------------------------//
|
973 | 1061 | // Lock Returned (lr)
|
@@ -1103,6 +1191,23 @@ int le_function_bad_3() LOCKS_EXCLUDED(muDoublePointer); // \
|
1103 | 1191 | int le_function_bad_4() LOCKS_EXCLUDED(umu); // \
|
1104 | 1192 | // expected-warning {{'locks_excluded' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
1105 | 1193 |
|
| 1194 | +template<typename Mu> |
| 1195 | +int le_template(Mu& mu) LOCKS_EXCLUDED(mu) {} |
| 1196 | + |
| 1197 | +template int le_template<Mutex>(Mutex&); |
| 1198 | +// FIXME: warn on template instantiation. |
| 1199 | +template int le_template<UnlockableMu>(UnlockableMu&); |
| 1200 | + |
| 1201 | +#if __cplusplus >= 201103 |
| 1202 | + |
| 1203 | +template<typename... Mus> |
| 1204 | +int le_variadic_template(Mus&... mus) LOCKS_EXCLUDED(mus...) {} |
| 1205 | + |
| 1206 | +template int le_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 1207 | +// FIXME: warn on template instantiation. |
| 1208 | +template int le_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 1209 | + |
| 1210 | +#endif |
1106 | 1211 |
|
1107 | 1212 |
|
1108 | 1213 | //-----------------------------------------//
|
@@ -1171,6 +1276,24 @@ int elr_function_bad_3() EXCLUSIVE_LOCKS_REQUIRED(muDoublePointer); // \
|
1171 | 1276 | int elr_function_bad_4() EXCLUSIVE_LOCKS_REQUIRED(umu); // \
|
1172 | 1277 | // expected-warning {{'exclusive_locks_required' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
1173 | 1278 |
|
| 1279 | +template<typename Mu> |
| 1280 | +int elr_template(Mu& mu) EXCLUSIVE_LOCKS_REQUIRED(mu) {} |
| 1281 | + |
| 1282 | +template int elr_template<Mutex>(Mutex&); |
| 1283 | +// FIXME: warn on template instantiation. |
| 1284 | +template int elr_template<UnlockableMu>(UnlockableMu&); |
| 1285 | + |
| 1286 | +#if __cplusplus >= 201103 |
| 1287 | + |
| 1288 | +template<typename... Mus> |
| 1289 | +int elr_variadic_template(Mus&... mus) EXCLUSIVE_LOCKS_REQUIRED(mus...) {} |
| 1290 | + |
| 1291 | +template int elr_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 1292 | +// FIXME: warn on template instantiation. |
| 1293 | +template int elr_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 1294 | + |
| 1295 | +#endif |
| 1296 | + |
1174 | 1297 |
|
1175 | 1298 |
|
1176 | 1299 |
|
@@ -1240,6 +1363,24 @@ int slr_function_bad_3() SHARED_LOCKS_REQUIRED(muDoublePointer); // \
|
1240 | 1363 | int slr_function_bad_4() SHARED_LOCKS_REQUIRED(umu); // \
|
1241 | 1364 | // expected-warning {{'shared_locks_required' attribute requires arguments whose type is annotated with 'capability' attribute}}
|
1242 | 1365 |
|
| 1366 | +template<typename Mu> |
| 1367 | +int slr_template(Mu& mu) SHARED_LOCKS_REQUIRED(mu) {} |
| 1368 | + |
| 1369 | +template int slr_template<Mutex>(Mutex&); |
| 1370 | +// FIXME: warn on template instantiation. |
| 1371 | +template int slr_template<UnlockableMu>(UnlockableMu&); |
| 1372 | + |
| 1373 | +#if __cplusplus >= 201103 |
| 1374 | + |
| 1375 | +template<typename... Mus> |
| 1376 | +int slr_variadic_template(Mus&... mus) SHARED_LOCKS_REQUIRED(mus...) {} |
| 1377 | + |
| 1378 | +template int slr_variadic_template<Mutex, Mutex>(Mutex&, Mutex&); |
| 1379 | +// FIXME: warn on template instantiation. |
| 1380 | +template int slr_variadic_template<Mutex, UnlockableMu>(Mutex&, UnlockableMu&); |
| 1381 | + |
| 1382 | +#endif |
| 1383 | + |
1243 | 1384 |
|
1244 | 1385 | //-----------------------------------------//
|
1245 | 1386 | // Regression tests for unusual cases.
|
@@ -1597,7 +1738,7 @@ class Foo {
|
1597 | 1738 | } // end namespace FunctionAttributesInsideClass_ICE_Test
|
1598 | 1739 |
|
1599 | 1740 |
|
1600 |
| -#ifdef CPP11 |
| 1741 | +#if __cplusplus >= 201103 |
1601 | 1742 | namespace CRASH_POST_R301735 {
|
1602 | 1743 | class SomeClass {
|
1603 | 1744 | public:
|
|
0 commit comments