} else {
QualType R = GetTypeForDeclarator(D, S);
assert(!R.isNull() && "GetTypeForDeclarator() returned null type");
+ if (R.getTypePtr()->isObjcInterfaceType()) {
+ Diag(D.getIdentifierLoc(), diag::err_statically_allocated_object,
+ D.getIdentifier()->getName());
+ InvalidDecl = true;
+ }
VarDecl *NewVD;
VarDecl::StorageClass SC;
}
}
}
+ /// A field cannot be an Objective-c object
+ if (FDTy->isObjcInterfaceType()) {
+ Diag(FD->getLocation(), diag::err_statically_allocated_object,
+ FD->getName());
+ FD->setInvalidDecl();
+ EnclosingDecl->setInvalidDecl();
+ continue;
+ }
// Keep track of the number of named members.
if (IdentifierInfo *II = FD->getIdentifier()) {
// Detect duplicate member names.
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
+ compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";
bool isUnionType() const;
bool isVectorType() const; // GCC vector type.
bool isOCUVectorType() const; // OCU vector type.
+ bool isObjcInterfaceType() const; // includes conforming protocol type
// Type Checking Functions: Check to see if this type is structurally the
// specified type, ignoring typedefs, and return a pointer to the best type
inline bool Type::isOCUVectorType() const {
return isa<OCUVectorType>(CanonicalType);
}
-
+inline bool Type::isObjcInterfaceType() const {
+ return isa<ObjcInterfaceType>(CanonicalType)
+ || isa<ObjcQualifiedInterfaceType>(CanonicalType);
+}
} // end namespace clang
#endif
"previous declaration is here")
DIAG(err_conflicting_aliasing_type, ERROR,
"conflicting types for alias %0'")
+DIAG(err_statically_allocated_object, ERROR,
+ "statically allocated Objective-c object '%0'")
//===----------------------------------------------------------------------===//
// Semantic Analysis
--- /dev/null
+// RUN: clang -fsyntax-only -verify %s
+
+@interface Super @end
+Super s1; // expected-error{{statically allocated Objective-c object 's1'}}
+
+extern Super e1; // expected-error{{statically allocated Objective-c object 'e1'}}
+
+struct S {
+ Super s1; // expected-error{{statically allocated Objective-c object 's1'}}
+};
+
+@protocol P1 @end
+
+@interface INTF
+{
+ Super ivar1; // expected-error{{statically allocated Objective-c object 'ivar1'}}
+}
+@end
+
+@interface MyIntf
+{
+ Super<P1> ivar1; // expected-error{{statically allocated Objective-c object 'ivar1'}}
+}
+@end
+
+Super foo(Super parm1) {
+ Super p1; // expected-error{{statically allocated Objective-c object 'p1'}}
+ return p1;
+}