From: Anders Carlsson Date: Tue, 24 Mar 2009 01:46:45 +0000 (+0000) Subject: Handle pointers to arrays of abstract types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5eff73c7679349f39e3602e05fff1ff347a28858;p=clang Handle pointers to arrays of abstract types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67598 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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}}