aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorFrancois Pichet <pichet2000@gmail.com>2010-12-08 22:35:30 +0000
committerFrancois Pichet <pichet2000@gmail.com>2010-12-08 22:35:30 +0000
commitf187237d916afa97c491ac32fe98be7d335c5b63 (patch)
tree28daf88fb8a7b6fdfffc1716162497acdcedb831 /lib/Sema/SemaExprCXX.cpp
parent259461d46a4f9505e1b609b0d4a25e1d54b39f79 (diff)
Remove the TypesCompatibleExprClass AST node. Merge its functionality into BinaryTypeTraitExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121298 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r--lib/Sema/SemaExprCXX.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 100f787059..92441918d1 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -2378,6 +2378,9 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, BinaryTypeTrait BTT,
return true;
return false;
+ case BTT_TypeCompatible:
+ return Self.Context.typesAreCompatible(LhsT.getUnqualifiedType(),
+ RhsT.getUnqualifiedType());
}
llvm_unreachable("Unknown type trait or not implemented");
}
@@ -2402,15 +2405,29 @@ ExprResult Sema::BuildBinaryTypeTrait(BinaryTypeTrait BTT,
RequireCompleteType(KWLoc, RhsT,
diag::err_incomplete_type_used_in_type_trait_expr))
return ExprError();
+ } else if (BTT == BTT_TypeCompatible) {
+ if (getLangOptions().CPlusPlus) {
+ Diag(KWLoc, diag::err_types_compatible_p_in_cplusplus)
+ << SourceRange(KWLoc, RParen);
+ return ExprError();
+ }
}
bool Value = false;
if (!LhsT->isDependentType() && !RhsT->isDependentType())
Value = EvaluateBinaryTypeTrait(*this, BTT, LhsT, RhsT, KWLoc);
+ // Select trait result type.
+ QualType ResultType;
+ switch (BTT) {
+ default: llvm_unreachable("Unknown type trait or not implemented");
+ case BTT_IsBaseOf: ResultType = Context.BoolTy; break;
+ case BTT_TypeCompatible: ResultType = Context.IntTy; break;
+ }
+
return Owned(new (Context) BinaryTypeTraitExpr(KWLoc, BTT, LhsTSInfo,
RhsTSInfo, Value, RParen,
- Context.BoolTy));
+ ResultType));
}
QualType Sema::CheckPointerToMemberOperands(Expr *&lex, Expr *&rex,