]> granicus.if.org Git - clang/commitdiff
Fix another case of giving the wrong value kind to a dependent cast to
authorJohn McCall <rjmccall@apple.com>
Tue, 30 Nov 2010 02:05:44 +0000 (02:05 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 30 Nov 2010 02:05:44 +0000 (02:05 +0000)
a non-dependent type.

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

lib/Sema/SemaCXXCast.cpp
test/SemaTemplate/dependent-expr.cpp

index 2a52f1787654d09f4f40c2f286011dc819fd6be3..214d1f6175585ddff376aff1aa0608c8d1df71c3 100644 (file)
@@ -1375,13 +1375,16 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK,
     return false;
   }
 
+  // Make sure we determine the value kind before we bail out for
+  // dependent types.
+  VK = Expr::getValueKindForType(CastTy);
+
   // If the type is dependent, we won't do any other semantic analysis now.
   if (CastTy->isDependentType() || CastExpr->isTypeDependent()) {
     Kind = CK_Dependent;
     return false;
   }
 
-  VK = Expr::getValueKindForType(CastTy);
   if (VK == VK_RValue && !CastTy->isRecordType())
     DefaultFunctionArrayLvalueConversion(CastExpr);
 
index f3970d1d71062b61bc60e84bf0336ddd9c8f7310..f26c85b1eccf4efc28038cbdbceb5b72ce4f430a 100644 (file)
@@ -52,3 +52,12 @@ namespace test4 {
              &const_cast<char&>(reinterpret_cast<const volatile char &>(v)));
   }
 }
+
+namespace test5 {
+  template <typename T> class chained_map {
+    int k;
+    void lookup() const {
+      int &v = (int &)k;
+    }
+  };
+}