r259651 - [OpenCL] Adding reserved operator logical xor for OpenCL
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 3 07:17:16 PST 2016
Author: stulova
Date: Wed Feb 3 09:17:14 2016
New Revision: 259651
URL: http://llvm.org/viewvc/llvm-project?rev=259651&view=rev
Log:
[OpenCL] Adding reserved operator logical xor for OpenCL
This patch adds the reserved operator ^^ when compiling for OpenCL (spec v1.1 s6.3.g),
which results in a more meaningful error message.
Patch by Neil Hickey!
Review: http://reviews.llvm.org/D13280
M test/SemaOpenCL/unsupported.cl
M include/clang/Basic/TokenKinds.def
M include/clang/Basic/DiagnosticParseKinds.td
M lib/Basic/OperatorPrecedence.cpp
M lib/Lex/Lexer.cpp
M lib/Parse/ParseExpr.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Basic/OperatorPrecedence.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/SemaOpenCL/unsupported.cl
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=259651&r1=259650&r2=259651&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Wed Feb 3 09:17:14 2016
@@ -910,9 +910,11 @@ def warn_pragma_expected_enable_disable
def warn_pragma_unknown_extension : Warning<
"unknown OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>;
-// OpenCL error
+// 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">;
// OpenMP support.
def warn_pragma_omp_ignored : Warning<
Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=259651&r1=259650&r2=259651&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Wed Feb 3 09:17:14 2016
@@ -219,6 +219,9 @@ 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
Modified: cfe/trunk/lib/Basic/OperatorPrecedence.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OperatorPrecedence.cpp?rev=259651&r1=259650&r2=259651&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/OperatorPrecedence.cpp (original)
+++ cfe/trunk/lib/Basic/OperatorPrecedence.cpp Wed Feb 3 09:17:14 2016
@@ -53,6 +53,7 @@ prec::Level getBinOpPrecedence(tok::Toke
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;
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=259651&r1=259650&r2=259651&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Feb 3 09:17:14 2016
@@ -3505,6 +3505,9 @@ LexNextToken:
if (Char == '=') {
CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
Kind = tok::caretequal;
+ } else if (LangOpts.OpenCL && Char == '^') {
+ CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
+ Kind = tok::caretcaret;
} else {
Kind = tok::caret;
}
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=259651&r1=259650&r2=259651&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Feb 3 09:17:14 2016
@@ -263,6 +263,9 @@ Parser::ParseRHSOfBinaryExpression(ExprR
Token OpToken = Tok;
ConsumeToken();
+ if (OpToken.is(tok::caretcaret)) {
+ return ExprError(Diag(Tok, diag::err_opencl_logical_exclusive_or));
+ }
// Bail out when encountering a comma followed by a token which can't
// possibly be the start of an expression. For instance:
// int f() { return 1, }
Modified: cfe/trunk/test/SemaOpenCL/unsupported.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/unsupported.cl?rev=259651&r1=259650&r2=259651&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/unsupported.cl (original)
+++ cfe/trunk/test/SemaOpenCL/unsupported.cl Wed Feb 3 09:17:14 2016
@@ -7,3 +7,7 @@ struct {
void no_vla(int n) {
int a[n]; // expected-error {{variable length arrays are not supported in OpenCL}}
}
+
+void no_logxor(int n) {
+ int logxor = n ^^ n; // expected-error {{^^ is a reserved operator in OpenCL}}
+}
More information about the cfe-commits
mailing list