Skip to content
Snippets Groups Projects
Commit 9760a666 authored by Douglas Gregor's avatar Douglas Gregor
Browse files

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
parent 84a6a0a3
No related branches found
No related tags found
No related merge requests found
...@@ -1728,7 +1728,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, ...@@ -1728,7 +1728,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
// cv-qualifiers on return types are pointless except when the type is a // cv-qualifiers on return types are pointless except when the type is a
// class type in C++. // class type in C++.
if (T->isPointerType() && T.getCVRQualifiers() && if (isa<PointerType>(T) && T.getLocalCVRQualifiers() &&
(!getLangOptions().CPlusPlus || !T->isDependentType())) { (!getLangOptions().CPlusPlus || !T->isDependentType())) {
assert(chunkIndex + 1 < e && "No DeclaratorChunk for the return type?"); assert(chunkIndex + 1 < e && "No DeclaratorChunk for the return type?");
DeclaratorChunk ReturnTypeChunk = D.getTypeObject(chunkIndex + 1); DeclaratorChunk ReturnTypeChunk = D.getTypeObject(chunkIndex + 1);
......
...@@ -41,3 +41,11 @@ char* volatile i(); // expected-warning{{'volatile' type qualifier on return typ ...@@ -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}} 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}}
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment