]> granicus.if.org Git - clang/commitdiff
Improve error reporting of property and setter/getter
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 6 Dec 2008 21:48:16 +0000 (21:48 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 6 Dec 2008 21:48:16 +0000 (21:48 +0000)
type mimatches.

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

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/property-typecheck-1.m

index 933993be56f7eaffa4bee412df32fbdf61f8e0eb..ac204b17935e9d2d16927b196bb12bfc676f4f58 100644 (file)
@@ -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,
index 83013a7de3ba0c9650a5707afad1fbc3b47c4b9a..a5ffb7090565f3e47b1ae575c527ce18271cba22 100644 (file)
@@ -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);
+    }
   }
 }
 
index c02cbe03b85db38e00e0fd52fd6c27ebf7e88872..d5ee8d1b8881e925cdc5e44c7170bd65408a443e 100644 (file)
@@ -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