Move the "->" to "." fixit from r186128 into a separate note since

recovery is not attempted with the fixit. Also move the associated test
case from FixIt/fixit.cpp to SemaCXX/member-expr.cpp since the fixit is
no longer automatically applied.

llvm-svn: 186342
This commit is contained in:
Kaelyn Uhrain 2013-07-15 19:54:54 +00:00
parent dae7b4e4d1
commit bad7fb09b2
4 changed files with 20 additions and 18 deletions

View File

@ -4241,6 +4241,8 @@ def err_typecheck_member_reference_arrow : Error<
"member reference type %0 is not a pointer">;
def err_typecheck_member_reference_suggestion : Error<
"member reference type %0 is %select{a|not a}1 pointer; maybe you meant to use '%select{->|.}1'?">;
def note_typecheck_member_reference_suggestion : Note<
"did you meant to use '.' instead?">;
def err_typecheck_member_reference_type : Error<
"cannot refer to type member %0 in %1 with '%select{.|->}2'">;
def err_typecheck_member_reference_unknown : Error<

View File

@ -11355,13 +11355,11 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc) {
case OR_No_Viable_Function:
if (CandidateSet.empty()) {
QualType BaseType = Base->getType();
Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
<< BaseType << Base->getSourceRange();
if (BaseType->isRecordType() && !BaseType->isPointerType()) {
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
<< BaseType << 1 << Base->getSourceRange()
Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
<< FixItHint::CreateReplacement(OpLoc, ".");
} else {
Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
<< BaseType << Base->getSourceRange();
}
} else
Diag(OpLoc, diag::err_ovl_no_viable_oper)

View File

@ -313,18 +313,6 @@ namespace PR5066 {
X<int *p> x; // expected-error {{type-id cannot have a name}}
}
namespace PR15045 {
class Cl0 {
public:
int a;
};
int f() {
Cl0 c;
return c->a; // expected-error {{member reference type 'PR15045::Cl0' is not a pointer; maybe you meant to use '.'?}}
}
}
namespace PR5898 {
class A {
public:

View File

@ -87,7 +87,8 @@ namespace test5 {
}
void test2(A &x) {
x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}}
x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}} \
// expected-note {{did you meant to use '.' instead?}}
}
}
@ -172,3 +173,16 @@ void f(int i) {
j = 0;
}
}
namespace PR15045 {
class Cl0 {
public:
int a;
};
int f() {
Cl0 c;
return c->a; // expected-error {{member reference type 'PR15045::Cl0' is not a pointer}} \
// expected-note {{did you meant to use '.' instead?}}
}
}