From: Seo Sanghyeon Date: Sun, 2 Dec 2007 16:57:27 +0000 (+0000) Subject: Fix isStructureType and isUnionType to ignore typedefs, as stated X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2de3b3a4aca5bb900b0b201bba1a44860e1a4b77;p=clang 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 b0ba353112..e1d20831fc 100644 --- a/AST/Type.cpp +++ b/AST/Type.cpp @@ -61,13 +61,13 @@ bool Type::isDerivedType() const { } bool Type::isStructureType() const { - if (const RecordType *RT = dyn_cast(this)) + if (const RecordType *RT = dyn_cast(CanonicalType)) if (RT->getDecl()->getKind() == Decl::Struct) return true; return false; } bool Type::isUnionType() const { - if (const RecordType *RT = dyn_cast(this)) + if (const RecordType *RT = dyn_cast(CanonicalType)) if (RT->getDecl()->getKind() == Decl::Union) return true; return false; diff --git a/test/CodeGen/union.c b/test/CodeGen/union.c index 8102f9b6fd..473293847c 100644 --- a/test/CodeGen/union.c +++ b/test/CodeGen/union.c @@ -16,3 +16,9 @@ int f2( float __x ) { }__u; return (int)(__u.__u >> 31); } + +typedef union { int i; int *j; } value; + +int f3(value v) { + return *v.j; +}