]> granicus.if.org Git - clang/commitdiff
Fix crash with cast of value-dependent expr.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 19 Sep 2013 01:12:33 +0000 (01:12 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 19 Sep 2013 01:12:33 +0000 (01:12 +0000)
We don't really need to perform semantic analysis on the dependent expression
anyway, so just call the cast dependent.

<rdar://problem/15012610>

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

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

index 032cd6efb7526c68cf0056c6cb43eaae668b5b89..46b5b45306485dbb50ea8cdd3a2a6b8b8cb510b6 100644 (file)
@@ -243,7 +243,9 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
 
   // If the type is dependent, we won't do the semantic analysis now.
   // FIXME: should we check this in a more fine-grained manner?
-  bool TypeDependent = DestType->isDependentType() || Ex.get()->isTypeDependent();
+  bool TypeDependent = DestType->isDependentType() ||
+                       Ex.get()->isTypeDependent() ||
+                       Ex.get()->isValueDependent();
 
   CastOperation Op(*this, DestType, E);
   Op.OpRange = SourceRange(OpLoc, Parens.getEnd());
@@ -2008,7 +2010,8 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
   }
 
   // If the type is dependent, we won't do any other semantic analysis now.
-  if (DestType->isDependentType() || SrcExpr.get()->isTypeDependent()) {
+  if (DestType->isDependentType() || SrcExpr.get()->isTypeDependent() ||
+      SrcExpr.get()->isValueDependent()) {
     assert(Kind == CK_Dependent);
     return;
   }
index d75b0f3e30298fad7a375b2383cbe935893ba4cd..01ac42ed42132f5ab23efbfbb68b7b47f37eee26 100644 (file)
@@ -72,3 +72,10 @@ namespace PR8795 {
     return data[0];
   }
 }
+
+template<typename T> struct CastDependentIntToPointer {
+  static void* f() {
+    T *x;
+    return ((void*)(((unsigned long)(x)|0x1ul)));
+  }
+};