diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2008-12-06 21:48:16 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-12-06 21:48:16 +0000 |
| commit | ff83998e31db3b1f072000f98c6511563e604c8d (patch) | |
| tree | 9f4751fb92be9cc1d028dbe92e103e1510296e2d /clang | |
| parent | 8707e322cc9d71b9ba169a3b74c23f251d67a87f (diff) | |
| download | bcm5719-llvm-ff83998e31db3b1f072000f98c6511563e604c8d.tar.gz bcm5719-llvm-ff83998e31db3b1f072000f98c6511563e604c8d.zip | |
Improve error reporting of property and setter/getter
type mimatches.
llvm-svn: 60630
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticKinds.def | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 8 | ||||
| -rw-r--r-- | clang/test/SemaObjC/property-typecheck-1.m | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/DiagnosticKinds.def b/clang/include/clang/Basic/DiagnosticKinds.def index 933993be56f..ac204b17935 100644 --- a/clang/include/clang/Basic/DiagnosticKinds.def +++ b/clang/include/clang/Basic/DiagnosticKinds.def @@ -571,6 +571,8 @@ DIAG(warn_property_attr_mismatch, WARNING, "property attribute in continuation class does not match the primary class") DIAG(err_accessor_property_type_mismatch, ERROR, "type of property %0 does not match type of accessor %1") +DIAG(note_declared_at, NOTE, + "declared at") DIAG(err_setter_type_void, ERROR, "type of setter must be void") DIAG(warn_conflicting_types, WARNING, diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 83013a7de3b..a5ffb709056 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -933,21 +933,25 @@ Sema::diagnosePropertySetterGetterMismatch(ObjCPropertyDecl *property, const ObjCMethodDecl *GetterMethod, const ObjCMethodDecl *SetterMethod) { if (GetterMethod && - GetterMethod->getResultType() != property->getType()) + GetterMethod->getResultType() != property->getType()) { Diag(property->getLocation(), diag::err_accessor_property_type_mismatch) << property->getDeclName() << GetterMethod->getSelector().getAsIdentifierInfo(); + Diag(GetterMethod->getLocation(), diag::note_declared_at); + } if (SetterMethod) { if (SetterMethod->getResultType() != Context.VoidTy) Diag(SetterMethod->getLocation(), diag::err_setter_type_void); if (SetterMethod->getNumParams() != 1 || - (SetterMethod->getParamDecl(0)->getType() != property->getType())) + (SetterMethod->getParamDecl(0)->getType() != property->getType())) { Diag(property->getLocation(), diag::err_accessor_property_type_mismatch) << property->getDeclName() << SetterMethod->getSelector().getAsIdentifierInfo(); + Diag(SetterMethod->getLocation(), diag::note_declared_at); + } } } diff --git a/clang/test/SemaObjC/property-typecheck-1.m b/clang/test/SemaObjC/property-typecheck-1.m index c02cbe03b85..d5ee8d1b888 100644 --- a/clang/test/SemaObjC/property-typecheck-1.m +++ b/clang/test/SemaObjC/property-typecheck-1.m @@ -1,7 +1,7 @@ // RUN: clang -fsyntax-only -verify %s @interface A --(float) x; +-(float) x; // expected-note {{declared at}} @property int x; // expected-error {{type of property 'x' does not match type of accessor 'x'}} @end |

