[cfe-commits] r142890 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaCXX/warn-thread-safety-analysis.cpp

Richard Smith richard-llvm at metafoo.co.uk
Mon Oct 24 17:41:24 PDT 2011


Author: rsmith
Date: Mon Oct 24 19:41:24 2011
New Revision: 142890

URL: http://llvm.org/viewvc/llvm-project?rev=142890&view=rev
Log:
Don't forget the lvalue-to-rvalue conversion on the LHS of an -> when rebuilding
it during template instantiation, for a known RHS decl.

Modified:
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=142890&r1=142889&r2=142890&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Oct 24 19:41:24 2011
@@ -1485,6 +1485,11 @@
     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();
 

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=142890&r1=142889&r2=142890&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Mon Oct 24 19:41:24 2011
@@ -1509,4 +1509,25 @@
 
 } // 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}}
+
+}





More information about the cfe-commits mailing list