summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2013-09-19 01:12:33 +0000
committerEli Friedman <eli.friedman@gmail.com>2013-09-19 01:12:33 +0000
commit71271083578eeccf16421a295a7803ceda5bb44d (patch)
tree344bfd5c491c152b4e8ec13ee2942cf3f52bb195 /clang
parent0834a4b90139341eacdfff167b052595a95cf2e5 (diff)
downloadbcm5719-llvm-71271083578eeccf16421a295a7803ceda5bb44d.tar.gz
bcm5719-llvm-71271083578eeccf16421a295a7803ceda5bb44d.zip
Fix crash with cast of value-dependent expr.
We don't really need to perform semantic analysis on the dependent expression anyway, so just call the cast dependent. <rdar://problem/15012610> llvm-svn: 190981
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaCast.cpp7
-rw-r--r--clang/test/SemaTemplate/dependent-expr.cpp7
2 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 032cd6efb75..46b5b453064 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -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;
}
diff --git a/clang/test/SemaTemplate/dependent-expr.cpp b/clang/test/SemaTemplate/dependent-expr.cpp
index d75b0f3e302..01ac42ed421 100644
--- a/clang/test/SemaTemplate/dependent-expr.cpp
+++ b/clang/test/SemaTemplate/dependent-expr.cpp
@@ -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)));
+ }
+};
OpenPOWER on IntegriCloud