]> granicus.if.org Git - clang/commitdiff
Don't forget the lvalue-to-rvalue conversion on the LHS when instantiating a
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Oct 2011 06:33:21 +0000 (06:33 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 25 Oct 2011 06:33:21 +0000 (06:33 +0000)
dependent ->, where the member being referred to is an anonymous struct or
union. This path was missed by the fix in r142890.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142910 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/TreeTransform.h
test/SemaCXX/warn-thread-safety-analysis.cpp

index 46bd05b14ba6787cedf134d96a136533d5c629dd..3c118cb423deb7c3958fa818252102b3d3940683 100644 (file)
@@ -1482,6 +1482,11 @@ public:
                                                 FoundDecl, Member);
       if (BaseResult.isInvalid())
         return ExprError();
+      if (isArrow) {
+        BaseResult = getSema().DefaultLvalueConversion(BaseResult.take());
+        if (BaseResult.isInvalid())
+          return ExprError();
+      }
       Base = BaseResult.take();
       ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
       MemberExpr *ME =
index b020e5712a0372b3879de7c55081ea3cd7357d35..b4d44170fec33828188c2600f4c0073ac4966ebe 100644 (file)
@@ -1516,10 +1516,17 @@ namespace template_member_test {
     Mutex m;
     S *s GUARDED_BY(this->m);
   };
+  Mutex m;
+  struct U {
+    union {
+      int n;
+    };
+  } *u GUARDED_BY(m);
 
   template<typename U>
   struct IndirectLock {
     int DoNaughtyThings(T *t) {
+      u->n = 0; // expected-warning {{reading variable 'u' requires locking 'm'}}
       return t->s->n; // expected-warning {{reading variable 's' requires locking 'm'}}
     }
   };