1) Issue digsnostics in non-fragile ABI, when an expression
evaluates to an interface type (except when it is used to
access a non-fragile ivar).
2) Issue unsupported error in fragile ABI when an expression
evaluates to an interface type (except when it is used to
access a fragile ivar).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80860
91177308-0d34-0410-b5e6-
96231b3b80d8
"indirection requires pointer operand (%0 invalid)">;
def err_indirection_requires_nonfragile_object : Error<
"indirection cannot be to an interface in non-fragile ABI (%0 invalid)">;
+def err_direct_interface_unsupported : Error<
+ "indirection to an interface is not supported (%0 invalid)">;
def err_typecheck_invalid_operands : Error<
"invalid operands to binary expression (%0 and %1)">;
def err_typecheck_sub_ptr_object : Error<
if (const PointerType *PT = Ty->getAs<PointerType>())
return PT->getPointeeType();
- if (const ObjCObjectPointerType *OPT = Ty->getAsObjCObjectPointerType()) {
- QualType PTy = OPT->getPointeeType();
- if (LangOpts.ObjCNonFragileABI && PTy->isObjCInterfaceType()) {
- Diag(OpLoc, diag::err_indirection_requires_nonfragile_object)
- << Ty << Op->getSourceRange();
- return QualType();
- }
- return PTy;
- }
+ if (const ObjCObjectPointerType *OPT = Ty->getAsObjCObjectPointerType())
+ return OPT->getPointeeType();
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
<< Ty << Op->getSourceRange();
Sema::OwningStmtResult Sema::ActOnExprStmt(FullExprArg expr) {
Expr *E = expr->takeAs<Expr>();
assert(E && "ActOnExprStmt(): missing expression");
-
+ if (E->getType()->isObjCInterfaceType()) {
+ if (LangOpts.ObjCNonFragileABI)
+ Diag(E->getLocEnd(), diag::err_indirection_requires_nonfragile_object)
+ << E->getType();
+ else
+ Diag(E->getLocEnd(), diag::err_direct_interface_unsupported)
+ << E->getType();
+ return StmtError();
+ }
// C99 6.8.3p2: The expression in an expression statement is evaluated as a
// void expression for its side effects. Conversion to void allows any
// operand, even incomplete types.
-// RUN: clang-cc -triple i386-unknown-unknown -fsyntax-only -verify %s
+// RUN: clang-cc -fsyntax-only -verify %s
@interface foo
@end
-// RUN: clang-cc -triple i386-unknown-unknown -ast-print %s
+// RUN: clang-cc -triple i386-unknown-unknown -ast-print %s &&
+// RUN: clang-cc -triple x86_64-apple-darwin10 -ast-print %s
@interface current
{
int foo()
{
- // FIXME. This should be OK in nonfragile-abi as well.
return pc->ivar2 + (*pc).ivar + pc->ivar1;
}