@@ -867,7 +867,6 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
867
867
SemaOpenACC::OpenACCParsedClause ParsedClause (DirKind, ClauseKind, ClauseLoc);
868
868
869
869
if (ClauseHasRequiredParens (DirKind, ClauseKind)) {
870
- ParsedClause.setLParenLoc (getCurToken ().getLocation ());
871
870
if (Parens.expectAndConsume ()) {
872
871
// We are missing a paren, so assume that the person just forgot the
873
872
// parameter. Return 'false' so we try to continue on and parse the next
@@ -876,6 +875,7 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
876
875
Parser::StopBeforeMatch);
877
876
return OpenACCCanContinue ();
878
877
}
878
+ ParsedClause.setLParenLoc (Parens.getOpenLocation ());
879
879
880
880
switch (ClauseKind) {
881
881
case OpenACCClauseKind::Default: {
@@ -1048,8 +1048,8 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
1048
1048
return OpenACCCannotContinue ();
1049
1049
1050
1050
} else if (ClauseHasOptionalParens (DirKind, ClauseKind)) {
1051
- ParsedClause.setLParenLoc (getCurToken ().getLocation ());
1052
1051
if (!Parens.consumeOpen ()) {
1052
+ ParsedClause.setLParenLoc (Parens.getOpenLocation ());
1053
1053
switch (ClauseKind) {
1054
1054
case OpenACCClauseKind::Self: {
1055
1055
assert (DirKind != OpenACCDirectiveKind::Update);
@@ -1099,13 +1099,19 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
1099
1099
return OpenACCCanContinue ();
1100
1100
}
1101
1101
break ;
1102
- case OpenACCClauseKind::Wait:
1103
- if (ParseOpenACCWaitArgument (ClauseLoc,
1104
- /* IsDirective=*/ false )) {
1102
+ case OpenACCClauseKind::Wait: {
1103
+ OpenACCWaitParseInfo Info =
1104
+ ParseOpenACCWaitArgument (ClauseLoc,
1105
+ /* IsDirective=*/ false );
1106
+ if (Info.Failed ) {
1105
1107
Parens.skipToEnd ();
1106
1108
return OpenACCCanContinue ();
1107
1109
}
1110
+
1111
+ ParsedClause.setWaitDetails (Info.DevNumExpr , Info.QueuesLoc ,
1112
+ std::move (Info.QueueIdExprs ));
1108
1113
break ;
1114
+ }
1109
1115
default :
1110
1116
llvm_unreachable (" Not an optional parens type?" );
1111
1117
}
@@ -1139,7 +1145,9 @@ Parser::ParseOpenACCAsyncArgument(OpenACCDirectiveKind DK, OpenACCClauseKind CK,
1139
1145
// / In this section and throughout the specification, the term wait-argument
1140
1146
// / means:
1141
1147
// / [ devnum : int-expr : ] [ queues : ] async-argument-list
1142
- bool Parser::ParseOpenACCWaitArgument (SourceLocation Loc, bool IsDirective) {
1148
+ Parser::OpenACCWaitParseInfo
1149
+ Parser::ParseOpenACCWaitArgument (SourceLocation Loc, bool IsDirective) {
1150
+ OpenACCWaitParseInfo Result;
1143
1151
// [devnum : int-expr : ]
1144
1152
if (isOpenACCSpecialToken (OpenACCSpecialTokenKind::DevNum, Tok) &&
1145
1153
NextToken ().is (tok::colon)) {
@@ -1153,18 +1161,25 @@ bool Parser::ParseOpenACCWaitArgument(SourceLocation Loc, bool IsDirective) {
1153
1161
: OpenACCDirectiveKind::Invalid,
1154
1162
IsDirective ? OpenACCClauseKind::Invalid : OpenACCClauseKind::Wait,
1155
1163
Loc);
1156
- if (Res.first .isInvalid () && Res.second == OpenACCParseCanContinue::Cannot)
1157
- return true ;
1164
+ if (Res.first .isInvalid () &&
1165
+ Res.second == OpenACCParseCanContinue::Cannot) {
1166
+ Result.Failed = true ;
1167
+ return Result;
1168
+ }
1158
1169
1159
- if (ExpectAndConsume (tok::colon))
1160
- return true ;
1170
+ if (ExpectAndConsume (tok::colon)) {
1171
+ Result.Failed = true ;
1172
+ return Result;
1173
+ }
1174
+
1175
+ Result.DevNumExpr = Res.first .get ();
1161
1176
}
1162
1177
1163
1178
// [ queues : ]
1164
1179
if (isOpenACCSpecialToken (OpenACCSpecialTokenKind::Queues, Tok) &&
1165
1180
NextToken ().is (tok::colon)) {
1166
1181
// Consume queues.
1167
- ConsumeToken ();
1182
+ Result. QueuesLoc = ConsumeToken ();
1168
1183
// Consume colon.
1169
1184
ConsumeToken ();
1170
1185
}
@@ -1176,8 +1191,10 @@ bool Parser::ParseOpenACCWaitArgument(SourceLocation Loc, bool IsDirective) {
1176
1191
bool FirstArg = true ;
1177
1192
while (!getCurToken ().isOneOf (tok::r_paren, tok::annot_pragma_openacc_end)) {
1178
1193
if (!FirstArg) {
1179
- if (ExpectAndConsume (tok::comma))
1180
- return true ;
1194
+ if (ExpectAndConsume (tok::comma)) {
1195
+ Result.Failed = true ;
1196
+ return Result;
1197
+ }
1181
1198
}
1182
1199
FirstArg = false ;
1183
1200
@@ -1187,11 +1204,16 @@ bool Parser::ParseOpenACCWaitArgument(SourceLocation Loc, bool IsDirective) {
1187
1204
IsDirective ? OpenACCClauseKind::Invalid : OpenACCClauseKind::Wait,
1188
1205
Loc);
1189
1206
1190
- if (Res.first .isInvalid () && Res.second == OpenACCParseCanContinue::Cannot)
1191
- return true ;
1207
+ if (Res.first .isInvalid () &&
1208
+ Res.second == OpenACCParseCanContinue::Cannot) {
1209
+ Result.Failed = true ;
1210
+ return Result;
1211
+ }
1212
+
1213
+ Result.QueueIdExprs .push_back (Res.first .get ());
1192
1214
}
1193
1215
1194
- return false ;
1216
+ return Result ;
1195
1217
}
1196
1218
1197
1219
ExprResult Parser::ParseOpenACCIDExpression () {
@@ -1360,7 +1382,7 @@ Parser::OpenACCDirectiveParseInfo Parser::ParseOpenACCDirective() {
1360
1382
break ;
1361
1383
case OpenACCDirectiveKind::Wait:
1362
1384
// OpenACC has an optional paren-wrapped 'wait-argument'.
1363
- if (ParseOpenACCWaitArgument (StartLoc, /* IsDirective=*/ true ))
1385
+ if (ParseOpenACCWaitArgument (StartLoc, /* IsDirective=*/ true ). Failed )
1364
1386
T.skipToEnd ();
1365
1387
else
1366
1388
T.consumeClose ();
0 commit comments