зеркало из https://github.com/microsoft/clang-1.git
This patch does the following.
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
This commit is contained in:
Родитель
23d8bea705
Коммит
16b10378a9
|
@ -1363,6 +1363,8 @@ def err_typecheck_indirection_requires_pointer : Error<
|
|||
"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<
|
||||
|
|
|
@ -5023,15 +5023,8 @@ QualType Sema::CheckIndirectionOperand(Expr *Op, SourceLocation OpLoc) {
|
|||
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();
|
||||
|
|
|
@ -26,7 +26,15 @@ using namespace clang;
|
|||
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.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: clang-cc -triple i386-unknown-unknown -fsyntax-only -verify %s
|
||||
// RUN: clang-cc -fsyntax-only -verify %s
|
||||
|
||||
@interface foo
|
||||
@end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
// 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
|
||||
{
|
||||
|
@ -13,6 +14,5 @@ current *pc;
|
|||
|
||||
int foo()
|
||||
{
|
||||
// FIXME. This should be OK in nonfragile-abi as well.
|
||||
return pc->ivar2 + (*pc).ivar + pc->ivar1;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче