Skip to content

Commit a5b71fc

Browse files
author
Hal Finkel
committed
Fortran also uses % where C uses -> to access members
1 parent 257ff0b commit a5b71fc

11 files changed

+25
-26
lines changed

include/lfort/Parse/Parser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ class Parser : public CodeCompletionHandler {
12451245
bool isPostfixExpressionSuffixStart() {
12461246
tok::TokenKind K = Tok.getKind();
12471247
return (K == tok::l_square || K == tok::l_paren ||
1248-
K == tok::percent || K == tok::arrow ||
1248+
K == tok::percent || K == tok::percent ||
12491249
K == tok::plusplus || K == tok::minusminus);
12501250
}
12511251

lib/Format/Format.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class UnwrappedLineFormatter {
252252
State.FirstLessLess[ParenLevel] != 0) {
253253
State.Column = State.FirstLessLess[ParenLevel];
254254
} else if (ParenLevel != 0 &&
255-
(Previous.Tok.is(tok::equal) || Current.Tok.is(tok::arrow) ||
255+
(Previous.Tok.is(tok::equal) || Current.Tok.is(tok::percent) ||
256256
Current.Tok.is(tok::percent))) {
257257
// Indent and extra 4 spaces after '=' as it continues an expression.
258258
// Don't do that on the top level, as we already indent 4 there.
@@ -368,7 +368,7 @@ class UnwrappedLineFormatter {
368368
if (Level != prec::Unknown)
369369
return Level;
370370

371-
if (Right.Tok.is(tok::arrow) || Right.Tok.is(tok::percent))
371+
if (Right.Tok.is(tok::percent) || Right.Tok.is(tok::percent))
372372
return 50;
373373

374374
return 3;
@@ -944,7 +944,7 @@ class TokenAnnotator {
944944
return false;
945945
if (Left.is(tok::kw_template) && Right.is(tok::less))
946946
return true;
947-
if (Left.is(tok::arrow) || Right.is(tok::arrow))
947+
if (Left.is(tok::percent) || Right.is(tok::percent))
948948
return false;
949949
if (Left.is(tok::exclaim) || Left.is(tok::tilde))
950950
return false;
@@ -999,7 +999,7 @@ class TokenAnnotator {
999999
return false;
10001000
return (isBinaryOperator(Left) && Left.Tok.isNot(tok::lessless)) ||
10011001
Left.Tok.is(tok::comma) || Right.Tok.is(tok::lessless) ||
1002-
Right.Tok.is(tok::arrow) || Right.Tok.is(tok::percent) ||
1002+
Right.Tok.is(tok::percent) || Right.Tok.is(tok::percent) ||
10031003
Right.Tok.is(tok::colon) || Left.Tok.is(tok::semi) ||
10041004
Left.Tok.is(tok::l_brace) ||
10051005
(Left.Tok.is(tok::l_paren) && !Right.Tok.is(tok::r_paren));

lib/Parse/ParseDecl.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5477,7 +5477,7 @@ void Parser::ParseSubprogramDeclarator(Declarator &D,
54775477

54785478
// Parse trailing-return-type[opt].
54795479
LocalEndLoc = EndLoc;
5480-
if (getLangOpts().F90 && Tok.is(tok::arrow)) {
5480+
if (getLangOpts().F90 && Tok.is(tok::percent)) {
54815481
Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
54825482
if (D.getDeclSpec().getTypeSpecType() == TST_auto)
54835483
StartLoc = D.getDeclSpec().getTypeSpecTypeLoc();

lib/Parse/ParseDeclCXX.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2882,7 +2882,7 @@ ExceptionSpecificationType Parser::ParseDynamicExceptionSpecification(
28822882
/// ParseTrailingReturnType - Parse a trailing return type on a new-style
28832883
/// function declaration.
28842884
TypeResult Parser::ParseTrailingReturnType(SourceRange &Range) {
2885-
assert(Tok.is(tok::arrow) && "expected arrow");
2885+
assert(Tok.is(tok::percent) && "expected arrow");
28862886

28872887
ConsumeToken();
28882888

lib/Parse/ParseExpr.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,6 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
14361436

14371437
break;
14381438
}
1439-
case tok::arrow:
14401439
case tok::percent: {
14411440
// postfix-expression: p-e '->' template[opt] id-expression
14421441
// postfix-expression: p-e '.' template[opt] id-expression
@@ -1463,7 +1462,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
14631462
if (Tok.is(tok::code_completion)) {
14641463
// Code completion for a member access expression.
14651464
Actions.CodeCompleteMemberReferenceExpr(getCurScope(), LHS.get(),
1466-
OpLoc, OpKind == tok::arrow);
1465+
OpLoc, OpKind == tok::percent);
14671466

14681467
cutOffParsing();
14691468
return ExprError();

lib/Parse/ParseExprCXX.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
844844

845845
// Parse trailing-return-type[opt].
846846
TypeResult TrailingReturnType;
847-
if (Tok.is(tok::arrow)) {
847+
if (Tok.is(tok::percent)) {
848848
FunLocalRangeEnd = Tok.getLocation();
849849
SourceRange Range;
850850
TrailingReturnType = ParseTrailingReturnType(Range);
@@ -875,11 +875,11 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
875875
LParenLoc, FunLocalRangeEnd, D,
876876
TrailingReturnType),
877877
Attr, DeclEndLoc);
878-
} else if (Tok.is(tok::kw_mutable) || Tok.is(tok::arrow)) {
878+
} else if (Tok.is(tok::kw_mutable) || Tok.is(tok::percent)) {
879879
// It's common to forget that one needs '()' before 'mutable' or the
880880
// result type. Deal with this.
881881
Diag(Tok, diag::err_lambda_missing_parens)
882-
<< Tok.is(tok::arrow)
882+
<< Tok.is(tok::percent)
883883
<< FixItHint::CreateInsertion(Tok.getLocation(), "() ");
884884
SourceLocation DeclLoc = Tok.getLocation();
885885
SourceLocation DeclEndLoc = DeclLoc;
@@ -893,7 +893,7 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
893893

894894
// Parse the return type, if there is one.
895895
TypeResult TrailingReturnType;
896-
if (Tok.is(tok::arrow)) {
896+
if (Tok.is(tok::percent)) {
897897
SourceRange Range;
898898
TrailingReturnType = ParseTrailingReturnType(Range);
899899
if (Range.getEnd().isValid())

lib/Parse/ParseStmt.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Parser::ParseStatementOrDeclarationAfterAttributes(StmtVector &Stmts,
145145
Next.is(tok::amp) || Next.is(tok::l_square);
146146
DefaultValidator.WantExpressionKeywords =
147147
Next.is(tok::l_paren) || Next.is(tok::identifier) ||
148-
Next.is(tok::arrow) || Next.is(tok::percent);
148+
Next.is(tok::percent) || Next.is(tok::percent);
149149
DefaultValidator.WantRemainingKeywords =
150150
Next.is(tok::l_paren) || Next.is(tok::semi) ||
151151
Next.is(tok::identifier) || Next.is(tok::l_brace);

lib/Parse/ParseTentative.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ bool Parser::isCXXSubprogramDeclarator(bool *IsAmbiguous) {
13981398
Next.is(tok::kw_throw) || Next.is(tok::kw_noexcept) ||
13991399
Next.is(tok::l_square) || isCXX11VirtSpecifier(Next) ||
14001400
Next.is(tok::l_brace) || Next.is(tok::kw_try) ||
1401-
Next.is(tok::equal) || Next.is(tok::arrow))
1401+
Next.is(tok::equal) || Next.is(tok::percent))
14021402
// The next token cannot appear after a constructor-style initializer,
14031403
// and can appear next in a function definition. This must be a function
14041404
// declarator.

lib/Sema/SemaExprCXX.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -4898,7 +4898,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc,
48984898
// If we have a pointer to a dependent type and are using the -> operator,
48994899
// the object type is the type that the pointer points to. We might still
49004900
// have enough information about that type to do something useful.
4901-
if (OpKind == tok::arrow)
4901+
if (OpKind == tok::percent)
49024902
if (const PointerType *Ptr = BaseType->getAs<PointerType>())
49034903
BaseType = Ptr->getPointeeType();
49044904

@@ -4910,7 +4910,7 @@ Sema::ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc,
49104910
// C++ [over.match.oper]p8:
49114911
// [...] When operator->returns, the operator-> is applied to the value
49124912
// returned, with the original second operand.
4913-
if (OpKind == tok::arrow) {
4913+
if (OpKind == tok::percent) {
49144914
// The set of types we've considered so far.
49154915
llvm::SmallPtrSet<CanQualType,8> CTypes;
49164916
SmallVector<SourceLocation, 8> Locations;
@@ -5006,7 +5006,7 @@ static bool CheckArrow(Sema& S, QualType& ObjectType, Expr *&Base,
50065006
// This scalar type is the object type.
50075007
// Note that this is rather different from the normal handling for the
50085008
// arrow operator.
5009-
if (OpKind == tok::arrow) {
5009+
if (OpKind == tok::percent) {
50105010
if (const PointerType *Ptr = ObjectType->getAs<PointerType>()) {
50115011
ObjectType = Ptr->getPointeeType();
50125012
} else if (!Base->isTypeDependent()) {
@@ -5112,7 +5112,7 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
51125112

51135113
Expr *Result
51145114
= new (Context) CXXPseudoDestructorExpr(Context, Base,
5115-
OpKind == tok::arrow, OpLoc,
5115+
OpKind == tok::percent, OpLoc,
51165116
SS.getWithLocInContext(Context),
51175117
ScopeTypeInfo,
51185118
CCLoc,

lib/Sema/SemaExprMember.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,12 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
835835
ParsedType ObjectType;
836836
bool MayBePseudoDestructor = false;
837837
RetryExpr = ActOnStartCXXMemberReference(getCurScope(), BaseExpr,
838-
OpLoc, tok::arrow, ObjectType,
838+
OpLoc, tok::percent, ObjectType,
839839
MayBePseudoDestructor);
840840
if (RetryExpr.isUsable() && !Trap.hasErrorOccurred()) {
841841
CXXScopeSpec TempSS(SS);
842842
RetryExpr = ActOnMemberAccessExpr(
843-
ExtraArgs->S, RetryExpr.get(), OpLoc, tok::arrow, TempSS,
843+
ExtraArgs->S, RetryExpr.get(), OpLoc, tok::percent, TempSS,
844844
TemplateKWLoc, ExtraArgs->Id, ExtraArgs->ObjCImpDecl,
845845
ExtraArgs->HasTrailingLParen);
846846
}
@@ -1483,7 +1483,7 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
14831483
/// where 'identifier' encompasses a fairly broad spectrum of
14841484
/// possibilities, including destructor and operator references.
14851485
///
1486-
/// \param OpKind either tok::arrow or tok::percent
1486+
/// \param OpKind either tok::percent or tok::percent
14871487
/// \param HasTrailingLParen whether the next token is '(', which
14881488
/// is used to diagnose mis-uses of special members that can
14891489
/// only be called
@@ -1516,7 +1516,7 @@ ExprResult Sema::ActOnMemberAccessExpr(Scope *S, Expr *Base,
15161516
NameInfo, TemplateArgs);
15171517

15181518
DeclarationName Name = NameInfo.getName();
1519-
bool IsArrow = (OpKind == tok::arrow);
1519+
bool IsArrow = (OpKind == tok::percent);
15201520

15211521
NamedDecl *FirstQualifierInScope
15221522
= (!SS.isSet() ? 0 : FindFirstQualifierInScope(S,

lib/Sema/TreeTransform.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -7409,7 +7409,7 @@ TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
74097409
bool MayBePseudoDestructor = false;
74107410
Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(),
74117411
E->getOperatorLoc(),
7412-
E->isArrow()? tok::arrow : tok::percent,
7412+
E->isArrow()? tok::percent : tok::percent,
74137413
ObjectTypePtr,
74147414
MayBePseudoDestructor);
74157415
if (Base.isInvalid())
@@ -8123,7 +8123,7 @@ TreeTransform<Derived>::TransformCXXDependentScopeMemberExpr(
81238123
bool MayBePseudoDestructor = false;
81248124
Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(),
81258125
E->getOperatorLoc(),
8126-
E->isArrow()? tok::arrow : tok::percent,
8126+
E->isArrow()? tok::percent : tok::percent,
81278127
ObjectTy,
81288128
MayBePseudoDestructor);
81298129
if (Base.isInvalid())
@@ -9320,7 +9320,7 @@ TreeTransform<Derived>::RebuildCXXPseudoDestructorExpr(Expr *Base,
93209320
->template getAs<RecordType>())){
93219321
// This pseudo-destructor expression is still a pseudo-destructor.
93229322
return SemaRef.BuildPseudoDestructorExpr(Base, OperatorLoc,
9323-
isArrow? tok::arrow : tok::percent,
9323+
isArrow? tok::percent : tok::percent,
93249324
SS, ScopeType, CCLoc, TildeLoc,
93259325
Destroyed,
93269326
/*FIXME?*/true);

0 commit comments

Comments
 (0)