diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-03-01 17:04:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-03-01 17:04:42 +0000 |
commit | fff951371dfc309160a99d423e43a7841aeb35aa (patch) | |
tree | bb77a5cd39bcf41c3102f3d26e1e8d678f361e0c | |
parent | ef24c4b85e354255240bbbc21772098e6c3f6ae8 (diff) |
When digging into a cv-qualified return type that is a pointer type to
diagnose ignored qualifiers on return types, only assume that there is
a pointer chunk if the type is *structurally* a pointer type, not if
it's a typedef of a pointer type. Fixes PR9328/<rdar://problem/9055428>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126751 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaType.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/return.cpp | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 1c8a58b07c..afd118e2ca 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1728,7 +1728,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, // cv-qualifiers on return types are pointless except when the type is a // class type in C++. - if (T->isPointerType() && T.getCVRQualifiers() && + if (isa<PointerType>(T) && T.getLocalCVRQualifiers() && (!getLangOptions().CPlusPlus || !T->isDependentType())) { assert(chunkIndex + 1 < e && "No DeclaratorChunk for the return type?"); DeclaratorChunk ReturnTypeChunk = D.getTypeObject(chunkIndex + 1); diff --git a/test/SemaCXX/return.cpp b/test/SemaCXX/return.cpp index 017633bce9..285fb09980 100644 --- a/test/SemaCXX/return.cpp +++ b/test/SemaCXX/return.cpp @@ -41,3 +41,11 @@ char* volatile i(); // expected-warning{{'volatile' type qualifier on return typ const volatile int scalar_cv(); // expected-warning{{'const volatile' type qualifiers on return type have no effect}} } + +namespace PR9328 { + typedef char *PCHAR; + class Test + { + const PCHAR GetName() { return 0; } // expected-warning{{'const' type qualifier on return type has no effect}} + }; +} |