[cfe-commits] r126751 - in /cfe/trunk: lib/Sema/SemaType.cpp test/SemaCXX/return.cpp
Douglas Gregor
dgregor at apple.com
Tue Mar 1 09:04:42 PST 2011
Author: dgregor
Date: Tue Mar 1 11:04:42 2011
New Revision: 126751
URL: http://llvm.org/viewvc/llvm-project?rev=126751&view=rev
Log:
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>.
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaCXX/return.cpp
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=126751&r1=126750&r2=126751&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Mar 1 11:04:42 2011
@@ -1728,7 +1728,7 @@
// 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);
Modified: cfe/trunk/test/SemaCXX/return.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/return.cpp?rev=126751&r1=126750&r2=126751&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/return.cpp (original)
+++ cfe/trunk/test/SemaCXX/return.cpp Tue Mar 1 11:04:42 2011
@@ -41,3 +41,11 @@
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}}
+ };
+}
More information about the cfe-commits
mailing list