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 | 9760a666d603a814ce65c361f8d5eb6f0f64cfc7 (patch) | |
| tree | 6ff7d8c255851909c16fb17006cffa84143bd4fe /clang | |
| parent | 84a6a0a3ce7d45a5a948e79f1a48f9fbf236a481 (diff) | |
| download | bcm5719-llvm-9760a666d603a814ce65c361f8d5eb6f0f64cfc7.tar.gz bcm5719-llvm-9760a666d603a814ce65c361f8d5eb6f0f64cfc7.zip | |
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>.
llvm-svn: 126751
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/return.cpp | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 1c8a58b07ce..afd118e2caa 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/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/clang/test/SemaCXX/return.cpp b/clang/test/SemaCXX/return.cpp index 017633bce95..285fb09980e 100644 --- a/clang/test/SemaCXX/return.cpp +++ b/clang/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}} + }; +} |

