do
nxt_token = cpp_peek_token (pfile, idx++);
while (nxt_token->type == CPP_PADDING);
- if (nxt_token->type == CPP_SCOPE)
+ if (!c_dialect_cxx ()
+ && nxt_token->type == CPP_COLON
+ && (nxt_token->flags & COLON_SCOPE) != 0)
+ {
+ const cpp_token *prev_token = nxt_token;
+ do
+ nxt_token = cpp_peek_token (pfile, idx++);
+ while (nxt_token->type == CPP_PADDING);
+ if (nxt_token->type == CPP_COLON)
+ {
+ /* __has_attribute (vendor::attr) in -std=c17 etc. modes.
+ :: isn't CPP_SCOPE but 2 CPP_COLON tokens, where the
+ first one should have COLON_SCOPE flag to distinguish
+ it from : :. */
+ have_scope = true;
+ get_token_no_padding (pfile); // Eat first colon.
+ }
+ else
+ nxt_token = prev_token;
+ }
+ if (nxt_token->type == CPP_SCOPE || have_scope)
{
- have_scope = true;
get_token_no_padding (pfile); // Eat scope.
nxt_token = get_token_no_padding (pfile);
if (nxt_token->type == CPP_NAME)
"attribute identifier required after scope");
attr_name = NULL_TREE;
}
+ if (have_scope)
+ {
+ /* The parser in this case won't be able to parse
+ [[vendor::attr]], so ensure 0 is returned. */
+ result = 0;
+ attr_name = NULL_TREE;
+ }
+ else
+ have_scope = true;
}
else
{
#define BOL (1 << 6) /* Token at beginning of line. */
#define PURE_ZERO (1 << 7) /* Single 0 digit, used by the C++ frontend,
set in c-lex.c. */
+#define COLON_SCOPE PURE_ZERO /* Adjacent colons in C < 23. */
#define SP_DIGRAPH (1 << 8) /* # or ## token was a digraph. */
#define SP_PREV_WHITE (1 << 9) /* If whitespace before a ##
operator, or before this token
case ':':
result->type = CPP_COLON;
- if (*buffer->cur == ':' && CPP_OPTION (pfile, scope))
- buffer->cur++, result->type = CPP_SCOPE;
+ if (*buffer->cur == ':')
+ {
+ if (CPP_OPTION (pfile, scope))
+ buffer->cur++, result->type = CPP_SCOPE;
+ else
+ result->flags |= COLON_SCOPE;
+ }
else if (*buffer->cur == '>' && CPP_OPTION (pfile, digraphs))
{
buffer->cur++;