"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<
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)
}
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?}}
}
}
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?}}
+ }
+}