diff options
author | Anders Carlsson <andersca@mac.com> | 2009-03-24 01:46:45 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-03-24 01:46:45 +0000 |
commit | 5eff73c7679349f39e3602e05fff1ff347a28858 (patch) | |
tree | 5f6da24e66a26abfbff200cb31ac35c749283c6c | |
parent | bc8a4f94a583217d8b0a39aaaeab8de453b29b0c (diff) |
Handle pointers to arrays of abstract types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67598 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 9 | ||||
-rw-r--r-- | test/SemaCXX/abstract.cpp | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index d1b210df46..89805a84ac 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -792,7 +792,16 @@ bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T, if (const ArrayType *AT = Context.getAsArrayType(T)) return RequireNonAbstractType(Loc, AT->getElementType(), DiagID, SelID); + + if (const PointerType *PT = T->getAsPointerType()) { + // Find the innermost pointer type. + while (const PointerType *T = PT->getPointeeType()->getAsPointerType()) + PT = T; + if (const ArrayType *AT = Context.getAsArrayType(PT->getPointeeType())) + return RequireNonAbstractType(Loc, AT->getElementType(), DiagID, SelID); + } + const RecordType *RT = T->getAsRecordType(); if (!RT) return false; diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp index 9c8e2dc977..dfe0a65798 100644 --- a/test/SemaCXX/abstract.cpp +++ b/test/SemaCXX/abstract.cpp @@ -42,7 +42,9 @@ void f() { t3(C()); // expected-error {{allocation of an object of abstract type 'C'}} } -C e[2]; // expected-error {{variable type 'C' is an abstract class}} +C e1[2]; // expected-error {{variable type 'C' is an abstract class}} +C (*e2)[2]; // expected-error {{variable type 'C' is an abstract class}} +C (**e3)[2]; // expected-error {{variable type 'C' is an abstract class}} void t4(C c[2]); // expected-error {{parameter type 'C' is an abstract class}} |