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
This commit is contained in:
Chandler Carruth 2011-05-24 07:43:19 +00:00
Родитель 74a5fd8bcc
Коммит 1f8f2d52ff
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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);