summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-01 06:57:39 +0000
committerChris Lattner <sabre@nondot.org>2008-02-01 06:57:39 +0000
commita34783486980e8b3929a5314fee55e89f0c84bac (patch)
tree200085e2d63c123157022c26cdeb25c5b437d933
parent617bfc39ffeafa7dff1eaa47f980b8e8043efc2a (diff)
downloadbcm5719-llvm-a34783486980e8b3929a5314fee55e89f0c84bac.tar.gz
bcm5719-llvm-a34783486980e8b3929a5314fee55e89f0c84bac.zip
make some diagnostics more terse, update testcases.
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__; }); llvm-svn: 46633
-rw-r--r--clang/Sema/SemaExprObjC.cpp17
-rw-r--r--clang/include/clang/Basic/DiagnosticKinds.def6
-rw-r--r--clang/test/Parser/objc-forcollection-neg-2.m2
-rw-r--r--clang/test/Parser/objc-forcollection-neg.m8
-rw-r--r--clang/test/Sema/objc-bad-receiver-1.m2
5 files changed, 17 insertions, 18 deletions
diff --git a/clang/Sema/SemaExprObjC.cpp b/clang/Sema/SemaExprObjC.cpp
index 0f53bbd804c..3e73930e9b6 100644
--- a/clang/Sema/SemaExprObjC.cpp
+++ b/clang/Sema/SemaExprObjC.cpp
@@ -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();
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def
index 02d3159c6ad..489575c989a 100644
--- a/clang/include/clang/Basic/DiagnosticKinds.def
+++ b/clang/include/clang/Basic/DiagnosticKinds.def
@@ -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
diff --git a/clang/test/Parser/objc-forcollection-neg-2.m b/clang/test/Parser/objc-forcollection-neg-2.m
index ba870aac20c..bde7d223596 100644
--- a/clang/test/Parser/objc-forcollection-neg-2.m
+++ b/clang/test/Parser/objc-forcollection-neg-2.m
@@ -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;
}
diff --git a/clang/test/Parser/objc-forcollection-neg.m b/clang/test/Parser/objc-forcollection-neg.m
index 4137e6304b4..8e1c05a0590 100644
--- a/clang/test/Parser/objc-forcollection-neg.m
+++ b/clang/test/Parser/objc-forcollection-neg.m
@@ -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
diff --git a/clang/test/Sema/objc-bad-receiver-1.m b/clang/test/Sema/objc-bad-receiver-1.m
index b18190894be..8376a5ced7a 100644
--- a/clang/test/Sema/objc-bad-receiver-1.m
+++ b/clang/test/Sema/objc-bad-receiver-1.m
@@ -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'" }}
}
OpenPOWER on IntegriCloud