aboutsummaryrefslogtreecommitdiff
path: root/AST/Type.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-07-24 21:46:40 +0000
committerSteve Naroff <snaroff@apple.com>2007-07-24 21:46:40 +0000
commit700204c74b455746752e851b25565ebf932f5340 (patch)
treef984053fde5c625c4dfe217fd23017ac4c2f6de0 /AST/Type.cpp
parent9572a5f5ea92fdb288f7030696950e86058601f3 (diff)
Fix Sema::ParseCallExpr()...it wasn't doing the default array/function promotions on it's argument types.
This resulted in the following errors when compiling promote_types_in_proto.c test... [dylan:~/llvm/tools/clang] admin% ../../Debug/bin/clang test/Parser/promote_types_in_proto.c test/Parser/promote_types_in_proto.c:7:24: error: incompatible types passing 'char *[]' to function expecting 'char *const []' arrayPromotion(argv); ~~~~~~~~~~~~~~ ^~~~ test/Parser/promote_types_in_proto.c:8:27: error: incompatible types passing 'void (char *const [])' to function expecting 'void (char *const [])' functionPromotion(arrayPromotion); ~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~ 2 diagnostics generated. When fixing this, noticed that both ParseCallExpr() and ParseReturnStmt() were prematurely comparing types for equivalence. This is incorrect (since the expr. promotions haven't been done yet). To fix this, I moved the check "down" to Sema::CheckAssignmentConstraints(). I also converted Type::isArrayType() to the modern API (since I needed it). Still more Type predicates to convert. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40475 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'AST/Type.cpp')
-rw-r--r--AST/Type.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/AST/Type.cpp b/AST/Type.cpp
index 4e415e4ab6..b09d3afa63 100644
--- a/AST/Type.cpp
+++ b/AST/Type.cpp
@@ -84,8 +84,16 @@ const ReferenceType *Type::isReferenceType() const {
return 0;
}
-bool Type::isArrayType() const {
- return isa<ArrayType>(CanonicalType);
+const ArrayType *Type::isArrayType() const {
+ // If this is directly a reference type, return it.
+ if (const ArrayType *ATy = dyn_cast<ArrayType>(this))
+ return ATy;
+
+ // If this is a typedef for an array type, strip the typedef off without
+ // losing all typedef information.
+ if (isa<ArrayType>(CanonicalType))
+ return cast<ArrayType>(cast<TypedefType>(this)->LookThroughTypedefs());
+ return 0;
}
bool Type::isStructureType() const {