[cfe-commits] r53834 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaExpr.cpp
Chris Lattner
sabre at nondot.org
Sun Jul 20 22:35:34 PDT 2008
Author: lattner
Date: Mon Jul 21 00:35:34 2008
New Revision: 53834
URL: http://llvm.org/viewvc/llvm-project?rev=53834&view=rev
Log:
improve invalid member reference diagnostics to print the type and
have better source ranges. Before:
t.m:11:53: error: member reference is not to a structure or union
CGFloat maxOffsetY = [_outlineLayer contentSize].height - [_outlineLayer frame].size.height;
^~~~~~~
after:
t.m:11:54: error: member reference base type ('id') is not a structure or union
CGFloat maxOffsetY = [_outlineLayer contentSize].height - [_outlineLayer frame].size.height;
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
Modified:
cfe/trunk/include/clang/Basic/DiagnosticKinds.def
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=53834&r1=53833&r2=53834&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Mon Jul 21 00:35:34 2008
@@ -879,8 +879,8 @@
"array subscript is not an integer")
DIAG(err_typecheck_subscript_not_object, ERROR,
"illegal subscript of non-object type '%0'")
-DIAG(err_typecheck_member_reference_structUnion, ERROR,
- "member reference is not to a structure or union")
+DIAG(err_typecheck_member_reference_struct_union, ERROR,
+ "member reference base type ('%0') is not a structure or union")
DIAG(err_typecheck_member_reference_ivar, ERROR,
"'%0' does not have a member named '%1'")
DIAG(err_typecheck_member_reference_arrow, ERROR,
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=53834&r1=53833&r2=53834&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jul 21 00:35:34 2008
@@ -588,8 +588,8 @@
if (const PointerType *PT = BaseType->getAsPointerType())
BaseType = PT->getPointeeType();
else
- return Diag(OpLoc, diag::err_typecheck_member_reference_arrow,
- SourceRange(MemberLoc));
+ return Diag(MemberLoc, diag::err_typecheck_member_reference_arrow,
+ BaseType.getAsString(), BaseExpr->getSourceRange());
}
// Handle field access to simple records. This also handles access to fields
@@ -602,8 +602,8 @@
// The record definition is complete, now make sure the member is valid.
FieldDecl *MemberDecl = RDecl->getMember(&Member);
if (!MemberDecl)
- return Diag(OpLoc, diag::err_typecheck_no_member, Member.getName(),
- SourceRange(MemberLoc));
+ return Diag(MemberLoc, diag::err_typecheck_no_member, Member.getName(),
+ BaseExpr->getSourceRange());
// Figure out the type of the member; see C99 6.5.2.3p3
// FIXME: Handle address space modifiers
@@ -622,9 +622,9 @@
if (ObjCIvarDecl *IV = IFTy->getDecl()->lookupInstanceVariable(&Member))
return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr,
OpKind == tok::arrow);
- return Diag(OpLoc, diag::err_typecheck_member_reference_ivar,
+ return Diag(MemberLoc, diag::err_typecheck_member_reference_ivar,
IFTy->getDecl()->getName(), Member.getName(),
- BaseExpr->getSourceRange(), SourceRange(MemberLoc));
+ BaseExpr->getSourceRange());
}
// Handle Objective-C property access, which is "Obj.property" where Obj is a
@@ -665,16 +665,16 @@
// Component access limited to variables (reject vec4.rg.g).
if (!isa<DeclRefExpr>(BaseExpr) && !isa<ArraySubscriptExpr>(BaseExpr) &&
!isa<ExtVectorElementExpr>(BaseExpr))
- return Diag(OpLoc, diag::err_ext_vector_component_access,
- SourceRange(MemberLoc));
+ return Diag(MemberLoc, diag::err_ext_vector_component_access,
+ BaseExpr->getSourceRange());
QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc);
if (ret.isNull())
return true;
return new ExtVectorElementExpr(ret, BaseExpr, Member, MemberLoc);
}
- return Diag(OpLoc, diag::err_typecheck_member_reference_structUnion,
- SourceRange(MemberLoc));
+ return Diag(MemberLoc, diag::err_typecheck_member_reference_struct_union,
+ BaseType.getAsString(), BaseExpr->getSourceRange());
}
/// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
More information about the cfe-commits
mailing list