Fix isStructureType and isUnionType to ignore typedefs, as stated
in the header. Patch by Cédric Venet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44519 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Type.cpp b/AST/Type.cpp
index b0ba353..e1d2083 100644
--- a/AST/Type.cpp
+++ b/AST/Type.cpp
@@ -61,13 +61,13 @@
}
bool Type::isStructureType() const {
- if (const RecordType *RT = dyn_cast<RecordType>(this))
+ if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType))
if (RT->getDecl()->getKind() == Decl::Struct)
return true;
return false;
}
bool Type::isUnionType() const {
- if (const RecordType *RT = dyn_cast<RecordType>(this))
+ if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType))
if (RT->getDecl()->getKind() == Decl::Union)
return true;
return false;
diff --git a/test/CodeGen/union.c b/test/CodeGen/union.c
index 8102f9b..4732938 100644
--- a/test/CodeGen/union.c
+++ b/test/CodeGen/union.c
@@ -16,3 +16,9 @@
}__u;
return (int)(__u.__u >> 31);
}
+
+typedef union { int i; int *j; } value;
+
+int f3(value v) {
+ return *v.j;
+}