diff options
-rw-r--r-- | clang/include/clang/Sema/Template.h | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/warn-thread-safety-negative.cpp | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 6c34e5862f7..b822b11126e 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -273,6 +273,11 @@ namespace clang { /// outermost scope. LocalInstantiationScope *cloneScopes(LocalInstantiationScope *Outermost) { if (this == Outermost) return this; + + // Save the current scope from SemaRef since the LocalInstantiationScope + // will overwrite it on construction + LocalInstantiationScope *oldScope = SemaRef.CurrentInstantiationScope; + LocalInstantiationScope *newScope = new LocalInstantiationScope(SemaRef, CombineWithOuterScope); @@ -299,6 +304,8 @@ namespace clang { newScope->ArgumentPacks.push_back(NewPack); } } + // Restore the saved scope to SemaRef + SemaRef.CurrentInstantiationScope = oldScope; return newScope; } diff --git a/clang/test/SemaCXX/warn-thread-safety-negative.cpp b/clang/test/SemaCXX/warn-thread-safety-negative.cpp index f88233a60b2..f831010293b 100644 --- a/clang/test/SemaCXX/warn-thread-safety-negative.cpp +++ b/clang/test/SemaCXX/warn-thread-safety-negative.cpp @@ -102,3 +102,20 @@ public: }; } // end namespace SimpleTest + +namespace DoubleAttribute { + +struct Foo { + Mutex &mutex(); +}; + +template <typename A> +class TemplateClass { + template <typename B> + static void Function(Foo *F) + EXCLUSIVE_LOCKS_REQUIRED(F->mutex()) UNLOCK_FUNCTION(F->mutex()) {} +}; + +void test() { TemplateClass<int> TC; } + +} // end namespace DoubleAttribute |