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}} + +}