[clang] [OpenACC} Improve diagnostics for 'tag's on clauses/directives (PR #77957)
Alexey Bataev via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 12 10:31:24 PST 2024
================
@@ -164,6 +164,49 @@ bool isOpenACCSpecialToken(OpenACCSpecialTokenKind Kind, Token Tok) {
llvm_unreachable("Unknown 'Kind' Passed");
}
+// Used for cases where we have a token we want to check against an
+// 'identifier-like' token, but don't want to give awkward error messages in
+// cases where it is accidentially a keyword.
+bool isTokenIdentifierOrKeyword(Parser &P, Token Tok) {
+ if (Tok.is(tok::identifier))
+ return true;
+
+ if (!Tok.isAnnotation() && Tok.getIdentifierInfo() &&
+ Tok.getIdentifierInfo()->isKeyword(P.getLangOpts()))
+ return true;
+
+ return false;
+}
+
+
+/// Parses and consumes an identifer followed immediately by a single colon, and
+/// diagnoses if it is not the 'special token' kind that we require. Used when
+/// the tag is the only valid value.
+/// Return 'true' if the special token was matched, false if no special token,
+/// or an invalid special token was found.
+template <typename DirOrClauseTy>
+bool TryParseAndConsumeSpecialTokenKind(Parser &P, OpenACCSpecialTokenKind Kind,
----------------
alexey-bataev wrote:
tryParseAndConsumeSpecialTokenKind
https://github.com/llvm/llvm-project/pull/77957
More information about the cfe-commits
mailing list