]> granicus.if.org Git - clang/commitdiff
When digging into a cv-qualified return type that is a pointer type to
authorDouglas Gregor <dgregor@apple.com>
Tue, 1 Mar 2011 17:04:42 +0000 (17:04 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 1 Mar 2011 17:04:42 +0000 (17:04 +0000)
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

lib/Sema/SemaType.cpp
test/SemaCXX/return.cpp

index 1c8a58b07ce5b2fe5ec6321b2c392c81778443c1..afd118e2caab0553ae257ff1f0b3f46bda3e774a 100644 (file)
@@ -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);
index 017633bce957c252f900c9c120b43980be1d88da..285fb09980e6380c144fe950a5df874fd252a504 100644 (file)
@@ -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}}
+  };
+}