Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ^^ as a token in OpenCL #108224

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ struct AvoidUnconditionalPreprocessorIfPPCallbacks : public PPCallbacks {
return (Tok.getRawIdentifier() == "true" ||
Tok.getRawIdentifier() == "false");
default:
return Tok.getKind() >= tok::l_square && Tok.getKind() <= tok::caretcaret;
return Tok.getKind() >= tok::l_square &&
Tok.getKind() <= tok::greatergreatergreater;
}
}

Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/pseudo/lib/cxx/cxx.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,6 @@ operator-name := >
operator-name := <=
operator-name := >=
operator-name := <=>
operator-name := ^^
operator-name := ||
operator-name := <<
operator-name := greatergreater
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticLexKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ def note_macro_expansion_here : Note<"expansion of macro %0 requested here">;

def ext_pp_opencl_variadic_macros : Extension<
"variadic macros are a Clang extension in OpenCL">;
def err_opencl_logical_exclusive_or : Error<
"^^ is a reserved operator in OpenCL">;

def ext_pp_gnu_line_directive : Extension<
"this style of line directive is a GNU extension">,
Expand Down
2 changes: 0 additions & 2 deletions clang/include/clang/Basic/DiagnosticParseKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -1394,8 +1394,6 @@ def err_modifier_expected_colon : Error<"missing ':' after %0 modifier">;
// OpenCL errors.
def err_opencl_taking_function_address_parser : Error<
"taking address of function is not allowed">;
def err_opencl_logical_exclusive_or : Error<
"^^ is a reserved operator in OpenCL">;

// C++ for OpenCL.
def err_openclcxx_virtual_function : Error<
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Basic/TokenKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,6 @@ PUNCTUATOR(at, "@")
PUNCTUATOR(lesslessless, "<<<")
PUNCTUATOR(greatergreatergreater, ">>>")

// CL support
PUNCTUATOR(caretcaret, "^^")

// C99 6.4.1: Keywords. These turn into kw_* tokens.
// Flags allowed:
// KEYALL - This is a keyword in all variants of C and C++, or it
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Basic/OperatorPrecedence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator,
case tok::pipeequal: return prec::Assignment;
case tok::question: return prec::Conditional;
case tok::pipepipe: return prec::LogicalOr;
case tok::caretcaret:
case tok::ampamp: return prec::LogicalAnd;
case tok::pipe: return prec::InclusiveOr;
case tok::caret: return prec::ExclusiveOr;
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Lex/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4325,10 +4325,9 @@ bool Lexer::LexTokenInternal(Token &Result, bool TokAtPhysicalStartOfLine) {
if (Char == '=') {
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::caretequal;
} else if (LangOpts.OpenCL && Char == '^') {
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::caretcaret;
} else {
if (LangOpts.OpenCL && Char == '^')
Diag(CurPtr, diag::err_opencl_logical_exclusive_or);
Kind = tok::caret;
}
break;
Expand Down
4 changes: 0 additions & 4 deletions clang/lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,6 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
Token OpToken = Tok;
ConsumeToken();

if (OpToken.is(tok::caretcaret)) {
return ExprError(Diag(Tok, diag::err_opencl_logical_exclusive_or));
}

// If we're potentially in a template-id, we may now be able to determine
// whether we're actually in one or not.
if (OpToken.isOneOf(tok::comma, tok::greater, tok::greatergreater,
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Sema/SemaCodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ static QualType getPreferredTypeOfBinaryRHS(Sema &S, Expr *LHS,
// Logical operators, assume we want bool.
case tok::ampamp:
case tok::pipepipe:
case tok::caretcaret:
return S.getASTContext().BoolTy;
// Operators often used for bit manipulation are typically used with the type
// of the left argument.
Expand Down
4 changes: 3 additions & 1 deletion clang/test/SemaOpenCL/unsupported.cl
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ void no_vla(int n) {
}

void no_logxor(int n) {
int logxor = n ^^ n; // expected-error {{^^ is a reserved operator in OpenCL}}
int logxor = n ^^ n; // expected-error {{^^ is a reserved operator in OpenCL}} \
expected-error {{type name requires a specifier or qualifier}} \
expected-error {{expected expression}}
}
Loading