aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-17 22:52:20 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-17 22:52:20 +0000
commit9103bb27f4eefa0e0d7935387750e3aca24abc49 (patch)
tree6aaea2ff73bf4fdc326954a76dd56f60d1962dc6 /lib
parentb74668edbc119880eb0a7e563432314432cb775d (diff)
Delay semantic analysis of the C++ names casts when the subexpression is type-dependent or the destination type is dependent.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61165 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaExpr.cpp3
-rw-r--r--lib/Sema/SemaNamedCast.cpp16
2 files changed, 15 insertions, 4 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 515169c557..096bcbe37b 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2876,6 +2876,9 @@ static NamedDecl *getPrimaryDecl(Expr *E) {
/// In C++, the operand might be an overloaded function name, in which case
/// we allow the '&' but retain the overloaded-function type.
QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) {
+ if (op->isTypeDependent())
+ return Context.DependentTy;
+
if (getLangOptions().C99) {
// Implement C99-only parts of addressof rules.
if (UnaryOperator* uOp = dyn_cast<UnaryOperator>(op)) {
diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp
index af1e2e0008..3d3572d00c 100644
--- a/lib/Sema/SemaNamedCast.cpp
+++ b/lib/Sema/SemaNamedCast.cpp
@@ -65,26 +65,34 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
SourceRange OpRange(OpLoc, RParenLoc);
SourceRange DestRange(LAngleBracketLoc, RAngleBracketLoc);
+ // 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->isTypeDependent();
+
switch (Kind) {
default: assert(0 && "Unknown C++ cast!");
case tok::kw_const_cast:
- CheckConstCast(*this, Ex, DestType, OpRange, DestRange);
+ if (!TypeDependent)
+ CheckConstCast(*this, Ex, DestType, OpRange, DestRange);
return new CXXConstCastExpr(DestType.getNonReferenceType(), Ex,
DestType, OpLoc);
case tok::kw_dynamic_cast:
- CheckDynamicCast(*this, Ex, DestType, OpRange, DestRange);
+ if (!TypeDependent)
+ CheckDynamicCast(*this, Ex, DestType, OpRange, DestRange);
return new CXXDynamicCastExpr(DestType.getNonReferenceType(), Ex,
DestType, OpLoc);
case tok::kw_reinterpret_cast:
- CheckReinterpretCast(*this, Ex, DestType, OpRange, DestRange);
+ if (!TypeDependent)
+ CheckReinterpretCast(*this, Ex, DestType, OpRange, DestRange);
return new CXXReinterpretCastExpr(DestType.getNonReferenceType(), Ex,
DestType, OpLoc);
case tok::kw_static_cast:
- CheckStaticCast(*this, Ex, DestType, OpRange);
+ if (!TypeDependent)
+ CheckStaticCast(*this, Ex, DestType, OpRange);
return new CXXStaticCastExpr(DestType.getNonReferenceType(), Ex,
DestType, OpLoc);
}