[cfe-commits] r67598 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/abstract.cpp

Anders Carlsson andersca at mac.com
Mon Mar 23 18:46:46 PDT 2009


Author: andersca
Date: Mon Mar 23 20:46:45 2009
New Revision: 67598

URL: http://llvm.org/viewvc/llvm-project?rev=67598&view=rev
Log:
Handle pointers to arrays of abstract types.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/abstract.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=67598&r1=67597&r2=67598&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Mar 23 20:46:45 2009
@@ -792,7 +792,16 @@
   
   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;

Modified: cfe/trunk/test/SemaCXX/abstract.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/abstract.cpp?rev=67598&r1=67597&r2=67598&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/abstract.cpp (original)
+++ cfe/trunk/test/SemaCXX/abstract.cpp Mon Mar 23 20:46:45 2009
@@ -42,7 +42,9 @@
     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}}
 





More information about the cfe-commits mailing list