[cfe-commits] r60630 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDeclObjC.cpp test/SemaObjC/property-typecheck-1.m
Fariborz Jahanian
fjahanian at apple.com
Sat Dec 6 13:48:17 PST 2008
Author: fjahanian
Date: Sat Dec 6 15:48:16 2008
New Revision: 60630
URL: http://llvm.org/viewvc/llvm-project?rev=60630&view=rev
Log:
Improve error reporting of property and setter/getter
type mimatches.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjC/property-typecheck-1.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=60630&r1=60629&r2=60630&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Sat Dec 6 15:48:16 2008
@@ -571,6 +571,8 @@
"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,
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=60630&r1=60629&r2=60630&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sat Dec 6 15:48:16 2008
@@ -933,21 +933,25 @@
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);
+ }
}
}
Modified: cfe/trunk/test/SemaObjC/property-typecheck-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-typecheck-1.m?rev=60630&r1=60629&r2=60630&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/property-typecheck-1.m (original)
+++ cfe/trunk/test/SemaObjC/property-typecheck-1.m Sat Dec 6 15:48:16 2008
@@ -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
More information about the cfe-commits
mailing list