]> granicus.if.org Git - clang/commitdiff
Revert "Try to correct a mistyped "-" or ">" to "->" for some C++ cases."
authorKaelyn Uhrain <rikka@google.com>
Tue, 5 Nov 2013 18:28:21 +0000 (18:28 +0000)
committerKaelyn Uhrain <rikka@google.com>
Tue, 5 Nov 2013 18:28:21 +0000 (18:28 +0000)
Revert this patch until cases of rejected valid code (e.g. identifiers
that require ADL to be resolved properly) are fixed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194088 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticParseKinds.td
lib/Parse/ParseExpr.cpp
test/SemaCXX/member-expr.cpp

index f79a04cb287f43301185966f8112c355936878bf..1df1713972af42863d19086d3a58731e0736ec8c 100644 (file)
@@ -499,9 +499,6 @@ def ext_abstract_pack_declarator_parens : ExtWarn<
 def err_function_is_not_record : Error<
   "unexpected '%select{.|->}0' in function call; perhaps remove the "
   "'%select{.|->}0'?">;
-def err_mistyped_arrow_in_member_access : Error<
-  "use of undeclared identifier %0; did you mean '->' instead of "
-  "'%select{-|>}1'?">;
 
 // C++ derived classes
 def err_dup_virtual : Error<"duplicate 'virtual' in base specifier">;
index 8ef055f9c74ff58eced232195357a421319f750c..e9cb827bd99dd2e032450cfde13708e622a15e27 100644 (file)
@@ -166,46 +166,6 @@ ExprResult Parser::ParseAssignmentExpression(TypeCastState isTypeCast) {
   ExprResult LHS = ParseCastExpression(/*isUnaryExpression=*/false,
                                        /*isAddressOfOperand=*/false,
                                        isTypeCast);
-
-  // Check for a possible typo of "-" or ">" instead of "->" after a
-  // pointer to a struct or class, while recovery is still possible.
-  if (LHS.isUsable() && (Tok.is(tok::minus) || Tok.is(tok::greater))) {
-    QualType LHSType = LHS.get()->getType();
-    const RecordType *Pointee =
-        LHSType->isPointerType()
-            ? LHSType->getPointeeType()->getAsStructureType()
-            : 0;
-    const RecordDecl *RD = Pointee ? Pointee->getDecl() : 0;
-    const Token &NextTok = NextToken();
-    if (RD && NextTok.is(tok::identifier)) {
-      UnqualifiedId Name;
-      CXXScopeSpec ScopeSpec;
-      SourceLocation TemplateKWLoc;
-      NoTypoCorrectionCCC NoTCValidator;
-      Name.setIdentifier(NextTok.getIdentifierInfo(), NextTok.getLocation());
-      Sema::SFINAETrap Trap(Actions);
-      ExprResult Res =
-          Actions.ActOnIdExpression(getCurScope(), ScopeSpec, TemplateKWLoc,
-                                    Name, false, false, &NoTCValidator);
-      if (Res.isInvalid()) {
-        Token OpTok = Tok;
-        Tok.setKind(tok::arrow);
-        PP.EnableBacktrackAtThisPos();
-        Res = ParsePostfixExpressionSuffix(LHS);
-        if (Res.isUsable()) {
-          LHS = Res;
-          PP.CommitBacktrackedTokens();
-          Diag(OpTok, diag::err_mistyped_arrow_in_member_access)
-              << NextTok.getIdentifierInfo() << OpTok.is(tok::greater)
-              << FixItHint::CreateReplacement(OpTok.getLocation(), "->");
-        } else {
-          Tok = OpTok;
-          PP.Backtrack();
-        }
-      }
-    }
-  }
-
   return ParseRHSOfBinaryExpression(LHS, prec::Assignment);
 }
 
index f5991a4634bda672f817fb07dbcc455c14853598..239aecff815d8982e9a530282d4e22b3979bdf03 100644 (file)
@@ -224,16 +224,3 @@ namespace pr16676 {
         .i;  // expected-error {{member reference type 'pr16676::S *' is a pointer; maybe you meant to use '->'}}
   }
 }
-
-namespace PR9054 {
-struct Foo {
-  void bar(int);
-  int fiz;
-};
-
-int test(struct Foo *foo) {
-  foo-bar(5);  // expected-error {{use of undeclared identifier 'bar'; did you mean '->' instead of '-'?}}
-  foo>baz(4);  // expected-error-re {{use of undeclared identifier 'baz'$}}
-  return foo>fiz;  // expected-error {{use of undeclared identifier 'fiz'; did you mean '->' instead of '>'?}}
-}
-}