]> granicus.if.org Git - clang/commitdiff
Handle pointers to arrays of abstract types.
authorAnders Carlsson <andersca@mac.com>
Tue, 24 Mar 2009 01:46:45 +0000 (01:46 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 24 Mar 2009 01:46:45 +0000 (01:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67598 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/abstract.cpp

index d1b210df46291c5b7180119d70c6553a452f9514..89805a84ac3f47d61e6f299b0f601c81ce8741b0 100644 (file)
@@ -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;
index 9c8e2dc977465fad71cd2ade5814b17ae687c1c5..dfe0a657982cd719984a266878e1111fd25aeb82 100644 (file)
@@ -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}}