r186342 - Move the "->" to "." fixit from r186128 into a separate note since
Kaelyn Uhrain
rikka at google.com
Mon Jul 15 12:54:54 PDT 2013
Author: rikka
Date: Mon Jul 15 14:54:54 2013
New Revision: 186342
URL: http://llvm.org/viewvc/llvm-project?rev=186342&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/FixIt/fixit.cpp
cfe/trunk/test/SemaCXX/member-expr.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=186342&r1=186341&r2=186342&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul 15 14:54:54 2013
@@ -4241,6 +4241,8 @@ def err_typecheck_member_reference_arrow
"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<
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=186342&r1=186341&r2=186342&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Jul 15 14:54:54 2013
@@ -11355,13 +11355,11 @@ Sema::BuildOverloadedArrowExpr(Scope *S,
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)
Modified: cfe/trunk/test/FixIt/fixit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.cpp?rev=186342&r1=186341&r2=186342&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit.cpp (original)
+++ cfe/trunk/test/FixIt/fixit.cpp Mon Jul 15 14:54:54 2013
@@ -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:
Modified: cfe/trunk/test/SemaCXX/member-expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/member-expr.cpp?rev=186342&r1=186341&r2=186342&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/member-expr.cpp (original)
+++ cfe/trunk/test/SemaCXX/member-expr.cpp Mon Jul 15 14:54:54 2013
@@ -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?}}
+ }
+}
More information about the cfe-commits
mailing list