diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-27 20:28:01 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-27 20:28:01 +0000 |
commit | 9f3611365d0f2297a910cf246e056708726ed10a (patch) | |
tree | 0a7e343e34257ac2fd57ac49b78027cc387e5c61 /lib/Parse | |
parent | 63e7d25d2e6036616b42f744fd4a39cd5f911960 (diff) |
Implement the Microsoft __is_convertible_to type trait, modeling the
semantics after the C++0x is_convertible type trait. This
implementation is not 100% complete, because it allows access errors
to be hard errors (rather than just evaluating false).
Original patch by Steven Watanabe!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124425 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 6 | ||||
-rw-r--r-- | lib/Parse/ParseExprCXX.cpp | 1 | ||||
-rw-r--r-- | lib/Parse/ParseTentative.cpp | 1 |
3 files changed, 6 insertions, 2 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 67351f7e2f..5928871987 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -537,8 +537,9 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, /// '__is_polymorphic' /// '__is_union' /// -/// [GNU] binary-type-trait: -/// '__is_base_of' [TODO] +/// binary-type-trait: +/// [GNU] '__is_base_of' +/// [MS] '__is_convertible_to' /// ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, @@ -988,6 +989,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, case tok::kw___builtin_types_compatible_p: case tok::kw___is_base_of: + case tok::kw___is_convertible_to: return ParseBinaryTypeTrait(); case tok::at: { diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp index 5a16729d80..e769ecac50 100644 --- a/lib/Parse/ParseExprCXX.cpp +++ b/lib/Parse/ParseExprCXX.cpp @@ -1828,6 +1828,7 @@ static BinaryTypeTrait BinaryTypeTraitFromTokKind(tok::TokenKind kind) { default: llvm_unreachable("Not a known binary type trait"); case tok::kw___is_base_of: return BTT_IsBaseOf; case tok::kw___builtin_types_compatible_p: return BTT_TypeCompatible; + case tok::kw___is_convertible_to: return BTT_IsConvertibleTo; } } diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp index 35d72547cd..a603c37a53 100644 --- a/lib/Parse/ParseTentative.cpp +++ b/lib/Parse/ParseTentative.cpp @@ -655,6 +655,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { case tok::kw___is_abstract: case tok::kw___is_base_of: case tok::kw___is_class: + case tok::kw___is_convertible_to: case tok::kw___is_empty: case tok::kw___is_enum: case tok::kw___is_pod: |