forked from OSchip/llvm-project
[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 llvm-svn: 259651
This commit is contained in:
parent
b4ee0af4fa
commit
735c6cdebd
|
@ -910,9 +910,11 @@ def warn_pragma_expected_enable_disable : Warning<
|
|||
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<
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -53,6 +53,7 @@ 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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -263,6 +263,9 @@ 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));
|
||||
}
|
||||
// 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, }
|
||||
|
|
|
@ -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}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue