diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-05-24 07:43:19 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-05-24 07:43:19 +0000 |
commit | 1f8f2d52ff3712770a49f318a687b0c8b0ada9d0 (patch) | |
tree | 5608ad9a3f055215aceab4f229602f6612c312fe | |
parent | 74a5fd8bcc68b540b58f6fcd2d80e6e926966e71 (diff) |
Fix a bug in -Wundefined-reinterpret-cast where we failed to look
through sugared types when testing for TagTypes. This was the actual
cause of the only false positive in Clang+LLVM.
Next evaluation will be over a much larger selection of code including
large amounts of open source code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131957 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/reinterpret-cast.cpp | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index c7038322e1..32fd0be375 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -1330,7 +1330,7 @@ void Sema::CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, return; } // or one of the types is a tag type. - if (isa<TagType>(SrcTy) || isa<TagType>(DestTy)) { + if (SrcTy->getAs<TagType>() || DestTy->getAs<TagType>()) { return; } diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp index 449fecb160..68005a5270 100644 --- a/test/SemaCXX/reinterpret-cast.cpp +++ b/test/SemaCXX/reinterpret-cast.cpp @@ -119,9 +119,13 @@ namespace PR9564 { void dereference_reinterpret_cast() { struct A {}; + typedef A A2; class B {}; + typedef B B2; A a; B b; + A2 a2; + B2 b2; long l; double d; float f; @@ -142,6 +146,10 @@ void dereference_reinterpret_cast() { (void)*reinterpret_cast<A*>(&b); (void)reinterpret_cast<B&>(a); (void)*reinterpret_cast<B*>(&a); + (void)reinterpret_cast<A2&>(b2); + (void)*reinterpret_cast<A2*>(&b2); + (void)reinterpret_cast<B2&>(a2); + (void)*reinterpret_cast<B2*>(&a2); // Casting to itself is allowed (void)reinterpret_cast<A&>(a); |