Index: include/clang/Basic/DiagnosticParseKinds.td =================================================================== --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -964,6 +964,8 @@ // OpenCL Section 6.8.g def err_opencl_unknown_type_specifier : Error< "OpenCL does not support the '%0' %select{type qualifier|storage class specifier}1">; +def err_opencl_logical_exclusive_or : Error< + "^^ is a reserved operator in OpenCL">; // OpenCL EXTENSION pragma (OpenCL 1.1 [9.1]) def warn_pragma_expected_colon : Warning< Index: include/clang/Basic/TokenKinds.def =================================================================== --- include/clang/Basic/TokenKinds.def +++ include/clang/Basic/TokenKinds.def @@ -219,6 +219,9 @@ 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 Index: lib/Basic/OperatorPrecedence.cpp =================================================================== --- lib/Basic/OperatorPrecedence.cpp +++ lib/Basic/OperatorPrecedence.cpp @@ -53,6 +53,7 @@ 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; Index: lib/Lex/Lexer.cpp =================================================================== --- lib/Lex/Lexer.cpp +++ lib/Lex/Lexer.cpp @@ -3473,6 +3473,9 @@ 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; } Index: lib/Parse/ParseExpr.cpp =================================================================== --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -261,6 +261,9 @@ 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, } Index: test/SemaOpenCL/unsupported.cl =================================================================== --- test/SemaOpenCL/unsupported.cl +++ test/SemaOpenCL/unsupported.cl @@ -7,3 +7,7 @@ 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}} +}