]> granicus.if.org Git - clang/commitdiff
make some diagnostics more terse, update testcases.
authorChris Lattner <sabre@nondot.org>
Fri, 1 Feb 2008 06:57:39 +0000 (06:57 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 1 Feb 2008 06:57:39 +0000 (06:57 +0000)
Fix Sema::ActOnInstanceMessage to correctly do things in terms of canonical
types, fixing bogus errors like:

NSDistantObject.m:10383:120: error: bad receiver type 'typeof((id<NSMutableCopying>)self)'
    id mess = ({ id __inv__ = ((void *)0); id __mb__ = _NSMessageBuilder((id <NSMutableCopying>)self, &__inv__); (void)[(__typeof__((id <NSMutableCopying>)self))__mb__ mutableCopyWithZone:((void *)0)]; if (!objc_collecting_enabled()) object_dispose(__mb__); __inv__; });

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46633 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaExprObjC.cpp
include/clang/Basic/DiagnosticKinds.def
test/Parser/objc-forcollection-neg-2.m
test/Parser/objc-forcollection-neg.m
test/Sema/objc-bad-receiver-1.m

index 0f53bbd804c958fc0828322205df0941f449ffa5..3e73930e9b65d6b7fadafaa4d0aa26bff5db07fd 100644 (file)
@@ -197,18 +197,16 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
   
   Expr **ArgExprs = reinterpret_cast<Expr **>(Args);
   Expr *RExpr = static_cast<Expr *>(receiver);
-  QualType receiverType = RExpr->getType();
+  QualType receiverType = RExpr->getType().getCanonicalType();
   QualType returnType;
   ObjCMethodDecl *Method = 0;
   
-  // FIXME:
-  // FIXME: This code is not stripping off type qualifiers or typedefs!
-  // FIXME:
-  if (receiverType == Context.getObjCIdType() ||
-      receiverType == Context.getObjCClassType()) {
+  // FIXME: This code is not stripping off type qualifiers! Should it?
+  if (receiverType == Context.getObjCIdType().getCanonicalType() ||
+      receiverType == Context.getObjCClassType().getCanonicalType()) {
     Method = InstanceMethodPool[Sel].Method;
-       if (!Method)
-         Method = FactoryMethodPool[Sel].Method;
+    if (!Method)
+      Method = FactoryMethodPool[Sel].Method;
     if (!Method) {
       Diag(lbrac, diag::warn_method_not_found, std::string("-"), Sel.getName(),
            SourceRange(lbrac, rbrac));
@@ -261,7 +259,8 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
     else {
       ObjCInterfaceType *OCIReceiver =dyn_cast<ObjCInterfaceType>(receiverType);
       if (OCIReceiver == 0) {
-        Diag(lbrac, diag::error_bad_receiver_type, receiverType.getAsString());
+        Diag(lbrac, diag::error_bad_receiver_type,
+             RExpr->getType().getAsString());
         return true;
       }
       ClassDecl = OCIReceiver->getDecl();
index 02d3159c6ad572b1067e95a85f5570d8ca6d5c6c..489575c989ab38746362cf4ae810f0e15621186e 100644 (file)
@@ -477,15 +477,15 @@ DIAG(warn_method_not_found, WARNING,
 DIAG(warn_method_not_found_in_protocol, WARNING,
      "method '%0%1' not found in protocol (return type defaults to 'id')")
 DIAG(err_collection_expr_type, ERROR,
-     "collection expression is not of valid object type (its type is '%0')")
+     "collection expression type ('%0') is not a valid object")
 DIAG(err_selector_element_type, ERROR,
-     "selector element is not of valid object type (its type is '%0')")
+     "selector element type ('%0') is not a valid object")
 DIAG(err_toomany_element_decls, ERROR,
      "Only one element declaration is allowed")
 DIAG(warn_expected_implementation, WARNING,
      "@end must appear in an @implementation context")
 DIAG(error_bad_receiver_type, ERROR,
-     "bad receiver type (its type is '%0')")
+     "bad receiver type '%0'")
 
 //===----------------------------------------------------------------------===//
 // Semantic Analysis
index ba870aac20cdada6ba2db95b3410214a85a356fe..bde7d223596ebb0a527b5855fb67e25ea55ae45d 100644 (file)
@@ -30,7 +30,7 @@ typedef struct objc_object {
         for (id el in self) 
            ++i;
        MyList<P> ***p;
-        for (p in self)  // expected-error {{selector element is not of valid object type (its type is 'MyList<P> ***')}}
+        for (p in self)  // expected-error {{selector element type ('MyList<P> ***') is not a valid object type}}
            ++i;
 
 }
index 4137e6304b4dbd744e105114c9a86d9cd9d51725..8e1c05a05904d2b7d154a55ef897edc4fc73d767 100644 (file)
@@ -24,13 +24,13 @@ typedef struct objc_object {
 - (void)compilerTestAgainst {
 
         int i=0;
-        for (int * elem in elem) // expected-error {{selector element is not of valid object type (its type is 'int *')}} \
-                                   expected-error {{collection expression is not of valid object type (its type is 'int *')}}
+        for (int * elem in elem) // expected-error {{selector element type ('int *') is not a valid object}} \
+                                   expected-error {{collection expression type ('int *') is not a valid object}}
            ++i;
         for (i in elem)  // expected-error {{use of undeclared identifier 'elem'}} \
-                           expected-error {{selector element is not of valid object type (its type is 'int')}}
+                           expected-error {{selector element type ('int') is not a valid object}}
            ++i;
-        for (id se in i) // expected-error {{collection expression is not of valid object type (its type is 'int')}} 
+        for (id se in i) // expected-error {{collection expression type ('int') is not a valid object}} 
            ++i;
 }
 @end
index b18190894be7a50bbed5edb9aee43793e28801b6..8376a5ced7acad9e90de5baffa19028536888e8e 100644 (file)
@@ -5,5 +5,5 @@
 @end
 
 void __raiseExc1() {
- [objc_lookUpClass("NSString") retain]; // expected-error {{ "bad receiver type (its type is 'int')" }}
+ [objc_lookUpClass("NSString") retain]; // expected-error {{ "bad receiver type 'int'" }}
 }