]> granicus.if.org Git - clang/commitdiff
Don't forget the lvalue-to-rvalue conversion on the LHS of an -> when rebuilding
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Oct 2011 00:41:24 +0000 (00:41 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Oct 2011 00:41:24 +0000 (00:41 +0000)
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
test/SemaCXX/warn-thread-safety-analysis.cpp

index 03a1d78aa01cfd4cb6eaafb39f999ee9fcf74e39..b4073eb650e883351a0d4df96a45e21a868d9387 100644 (file)
@@ -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();
 
index 7adead763ee211f7ffc89a63614a622aa0aa40c3..83e0ff08b9ef94d8ca45d0128c67c8d1dd5bb229 100644 (file)
@@ -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<typename U>
+  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<MutexWrapper>; // expected-note {{here}}
+
+}