[cfe-commits] r80860 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp lib/Sema/SemaStmt.cpp test/SemaObjC/method-bad-param.m test/SemaObjC/static-ivar-ref-1.m

Fariborz Jahanian fjahanian at apple.com
Wed Sep 2 17:43:08 PDT 2009


Author: fjahanian
Date: Wed Sep  2 19:43:07 2009
New Revision: 80860

URL: http://llvm.org/viewvc/llvm-project?rev=80860&view=rev
Log:
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).


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/test/SemaObjC/method-bad-param.m
    cfe/trunk/test/SemaObjC/static-ivar-ref-1.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=80860&r1=80859&r2=80860&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep  2 19:43:07 2009
@@ -1363,6 +1363,8 @@
   "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<

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Sep  2 19:43:07 2009
@@ -5023,15 +5023,8 @@
   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();

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Sep  2 19:43:07 2009
@@ -26,7 +26,15 @@
 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.

Modified: cfe/trunk/test/SemaObjC/method-bad-param.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-bad-param.m?rev=80860&r1=80859&r2=80860&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/method-bad-param.m (original)
+++ cfe/trunk/test/SemaObjC/method-bad-param.m Wed Sep  2 19:43:07 2009
@@ -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

Modified: cfe/trunk/test/SemaObjC/static-ivar-ref-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/static-ivar-ref-1.m?rev=80860&r1=80859&r2=80860&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/static-ivar-ref-1.m (original)
+++ cfe/trunk/test/SemaObjC/static-ivar-ref-1.m Wed Sep  2 19:43:07 2009
@@ -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 @@
 
 int foo()
 {
-        // FIXME. This should be OK in nonfragile-abi as well.
 	return pc->ivar2 + (*pc).ivar + pc->ivar1;
 }





More information about the cfe-commits mailing list