From 0676fb5ae65584389f7340d30d1c13148d778b6c Mon Sep 17 00:00:00 2001 From: Egor Churaev Date: Wed, 29 Mar 2017 05:40:45 +0000 Subject: [PATCH] Reverted r298976 [OpenCL] Added parsing for OpenCL vector types. llvm-svn: 298978 --- clang/include/clang/Parse/Parser.h | 6 +-- clang/lib/Parse/ParseExpr.cpp | 59 ++----------------------- clang/test/Parser/vector-cast-define.cl | 10 ----- 3 files changed, 6 insertions(+), 69 deletions(-) delete mode 100644 clang/test/Parser/vector-cast-define.cl diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index ff099cce1798..e1d395c85f6b 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -1449,12 +1449,10 @@ private: ExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast, - bool isVectorLiteral = false); + TypeCastState isTypeCast); ExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand = false, - TypeCastState isTypeCast = NotTypeCast, - bool isVectorLiteral = false); + TypeCastState isTypeCast = NotTypeCast); /// Returns true if the next token cannot start an expression. bool isNotExpressionStart(); diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index e1439d637809..4dcdfbf993e1 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -473,14 +473,12 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { /// ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, - TypeCastState isTypeCast, - bool isVectorLiteral) { + TypeCastState isTypeCast) { bool NotCastExpr; ExprResult Res = ParseCastExpression(isUnaryExpression, isAddressOfOperand, NotCastExpr, - isTypeCast, - isVectorLiteral); + isTypeCast); if (NotCastExpr) Diag(Tok, diag::err_expected_expression); return Res; @@ -696,8 +694,7 @@ class CastExpressionIdValidator : public CorrectionCandidateCallback { ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast, - bool isVectorLiteral) { + TypeCastState isTypeCast) { ExprResult Res; tok::TokenKind SavedKind = Tok.getKind(); NotCastExpr = false; @@ -725,9 +722,6 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/, isTypeCast == IsTypeCast, CastTy, RParenLoc); - if (isVectorLiteral) - return Res; - switch (ParenExprType) { case SimpleExpr: break; // Nothing else to do. case CompoundStmt: break; // Nothing else to do. @@ -2356,48 +2350,6 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc); } - if (Tok.is(tok::l_paren)) { - // This could be OpenCL vector Literals - if (getLangOpts().OpenCL) - { - TypeResult Ty; - { - InMessageExpressionRAIIObject InMessage(*this, false); - Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); - } - if(Ty.isInvalid()) - { - return ExprError(); - } - QualType QT = Ty.get().get().getCanonicalType(); - if (QT->isVectorType()) - { - // We parsed '(' vector-type-name ')' followed by '(' - - // Parse the cast-expression that follows it next. - // isVectorLiteral = true will make sure we don't parse any - // Postfix expression yet - Result = ParseCastExpression(/*isUnaryExpression=*/false, - /*isAddressOfOperand=*/false, - /*isTypeCast=*/IsTypeCast, - /*isVectorLiteral=*/true); - - if (!Result.isInvalid()) { - Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc, - DeclaratorInfo, CastTy, - RParenLoc, Result.get()); - } - - // After we performed the cast we can check for postfix-expr pieces. - if (!Result.isInvalid()) { - Result = ParsePostfixExpressionSuffix(Result); - } - - return Result; - } - } - } - if (ExprType == CastExpr) { // We parsed '(' type-name ')' and the thing after it wasn't a '{'. @@ -2427,13 +2379,10 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr, } // Parse the cast-expression that follows it next. - // isVectorLiteral = true will make sure we don't parse any - // Postfix expression yet // TODO: For cast expression with CastTy. Result = ParseCastExpression(/*isUnaryExpression=*/false, /*isAddressOfOperand=*/false, - /*isTypeCast=*/IsTypeCast, - /*isVectorLiteral=*/true); + /*isTypeCast=*/IsTypeCast); if (!Result.isInvalid()) { Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc, DeclaratorInfo, CastTy, diff --git a/clang/test/Parser/vector-cast-define.cl b/clang/test/Parser/vector-cast-define.cl deleted file mode 100644 index ec4eba7a7848..000000000000 --- a/clang/test/Parser/vector-cast-define.cl +++ /dev/null @@ -1,10 +0,0 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -// expected-no-diagnostics - -typedef int int3 __attribute__((ext_vector_type(3))); - -void test() -{ - int index = (int3)(1, 2, 3).x * (int3)(3, 2, 1).y; -} -