================ @@ -291,13 +307,63 @@ OpenACCDirectiveKind ParseOpenACCDirectiveKind(Parser &P) { return DirKind; } +bool ClauseHasRequiredParens(OpenACCClauseKind Kind) { + return Kind == OpenACCClauseKind::Default; +} + +bool ParseOpenACCClauseParams(Parser &P, OpenACCClauseKind Kind) { + BalancedDelimiterTracker Parens(P, tok::l_paren, + tok::annot_pragma_openacc_end); + + if (ClauseHasRequiredParens(Kind)) { + if (Parens.expectAndConsume()) { + // We are missing a paren, so assume that the person just forgot the + // parameter. Return 'false' so we try to continue on and parse the next + // clause. + P.SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openacc_end, + Parser::StopBeforeMatch); + return false; + } + + switch (Kind) { + case OpenACCClauseKind::Default: { + Token DefKindTok = P.getCurToken(); + // 'default' accepts 'present' or 'none'. Be a little liberal here to + // allow things like 'auto' or 'default'. + // TODO ERICH: Make 'keyword like tokens' via tok::getKeywordSpelling' + // or 'getIdentifierInfo' isKeyword + if (!DefKindTok.is(tok::identifier) && + (DefKindTok.isAnnotation() || !DefKindTok.getIdentifierInfo() || + !DefKindTok.getIdentifierInfo()->isKeyword(P.getLangOpts()))) { + P.Diag(P.getCurToken(), diag::err_expected) << tok::identifier; + break; + } ---------------- erichkeane wrote:
> Maybe you should remove the TODO though. Woops :) Removed as a part of my refactor. https://github.com/llvm/llvm-project/pull/77002 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits