r193799 - Fix a C struct diagnostic regression introduced by r187504 (PR17762).
Kaelyn Uhrain
rikka at google.com
Thu Oct 31 13:32:56 PDT 2013
Author: rikka
Date: Thu Oct 31 15:32:56 2013
New Revision: 193799
URL: http://llvm.org/viewvc/llvm-project?rev=193799&view=rev
Log:
Fix a C struct diagnostic regression introduced by r187504 (PR17762).
Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/test/Sema/member-reference.c
Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=193799&r1=193798&r2=193799&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Thu Oct 31 15:32:56 2013
@@ -1158,6 +1158,11 @@ Sema::LookupMemberExpr(LookupResult &R,
// overloaded operator->, but that should have been dealt with
// by now--or a diagnostic message already issued if a problem
// was encountered while looking for the overloaded operator->.
+ if (!getLangOpts().CPlusPlus) {
+ Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
+ << BaseType << int(IsArrow) << BaseExpr.get()->getSourceRange()
+ << FixItHint::CreateReplacement(OpLoc, ".");
+ }
IsArrow = false;
} else if (BaseType->isFunctionType()) {
goto fail;
Modified: cfe/trunk/test/Sema/member-reference.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/member-reference.c?rev=193799&r1=193798&r2=193799&view=diff
==============================================================================
--- cfe/trunk/test/Sema/member-reference.c (original)
+++ cfe/trunk/test/Sema/member-reference.c Thu Oct 31 15:32:56 2013
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only
-// expected-no-diagnostics
struct simple { int i; };
@@ -19,3 +18,7 @@ void g(void) {
s->x = 1;
s->z = 2;
}
+
+int PR17762(struct simple c) {
+ return c->i; // expected-error {{member reference type 'struct simple' is not a pointer; maybe you meant to use '.'?}}
+}
More information about the cfe-commits
mailing list