aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td2
-rw-r--r--lib/Sema/SemaExpr.cpp11
-rw-r--r--lib/Sema/SemaStmt.cpp10
-rw-r--r--test/SemaObjC/method-bad-param.m2
-rw-r--r--test/SemaObjC/static-ivar-ref-1.m4
5 files changed, 16 insertions, 13 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index a5d318eb25..ea1b2a4689 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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<
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 7072443829..c01097e363 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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();
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index ae59aec565..76113107ba 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -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.
diff --git a/test/SemaObjC/method-bad-param.m b/test/SemaObjC/method-bad-param.m
index 96d8a18092..f797188669 100644
--- a/test/SemaObjC/method-bad-param.m
+++ b/test/SemaObjC/method-bad-param.m
@@ -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
diff --git a/test/SemaObjC/static-ivar-ref-1.m b/test/SemaObjC/static-ivar-ref-1.m
index 4d0e7ba899..6b1a31226b 100644
--- a/test/SemaObjC/static-ivar-ref-1.m
+++ b/test/SemaObjC/static-ivar-ref-1.m
@@ -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;
}