From 97f9fe06e7acd55d7d9075a41e33f54855c75eae Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 25 Oct 2011 00:41:24 +0000 Subject: [PATCH] Don't forget the lvalue-to-rvalue conversion on the LHS of an -> when rebuilding it during template instantiation, for a known RHS decl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142890 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/TreeTransform.h | 5 +++++ test/SemaCXX/warn-thread-safety-analysis.cpp | 21 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 03a1d78aa0..b4073eb650 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -1485,6 +1485,11 @@ public: ExprResult BaseResult = getSema().DefaultFunctionArrayConversion(Base); if (BaseResult.isInvalid()) return ExprError(); + if (isArrow) { + BaseResult = getSema().DefaultLvalueConversion(BaseResult.get()); + if (BaseResult.isInvalid()) + return ExprError(); + } Base = BaseResult.take(); QualType BaseType = Base->getType(); diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp index 7adead763e..83e0ff08b9 100644 --- a/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/test/SemaCXX/warn-thread-safety-analysis.cpp @@ -1509,4 +1509,25 @@ void foo() { } // end namespace invalid_lock_expression_test +namespace template_member_test { + struct S { int n; }; + struct T { + Mutex m; + S *s GUARDED_BY(this->m); + }; + + template + struct IndirectLock { + int DoNaughtyThings(T *t) { + return t->s->n; // expected-warning {{reading variable 's' requires locking 'm'}} + } + }; + + struct MutexWrapper { + typedef Mutex Lock; + }; + + template struct IndirectLock; // expected-note {{here}} + +} -- 2.40.0