@@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
473
473
// /
474
474
ExprResult Parser::ParseCastExpression (bool isUnaryExpression,
475
475
bool isAddressOfOperand,
476
- TypeCastState isTypeCast) {
476
+ TypeCastState isTypeCast,
477
+ bool isVectorLiteral) {
477
478
bool NotCastExpr;
478
479
ExprResult Res = ParseCastExpression (isUnaryExpression,
479
480
isAddressOfOperand,
480
481
NotCastExpr,
481
- isTypeCast);
482
+ isTypeCast,
483
+ isVectorLiteral);
482
484
if (NotCastExpr)
483
485
Diag (Tok, diag::err_expected_expression);
484
486
return Res;
@@ -694,7 +696,8 @@ class CastExpressionIdValidator : public CorrectionCandidateCallback {
694
696
ExprResult Parser::ParseCastExpression (bool isUnaryExpression,
695
697
bool isAddressOfOperand,
696
698
bool &NotCastExpr,
697
- TypeCastState isTypeCast) {
699
+ TypeCastState isTypeCast,
700
+ bool isVectorLiteral) {
698
701
ExprResult Res;
699
702
tok::TokenKind SavedKind = Tok.getKind ();
700
703
NotCastExpr = false ;
@@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
722
725
Res = ParseParenExpression (ParenExprType, false /* stopIfCastExr*/ ,
723
726
isTypeCast == IsTypeCast, CastTy, RParenLoc);
724
727
728
+ if (isVectorLiteral)
729
+ return Res;
730
+
725
731
switch (ParenExprType) {
726
732
case SimpleExpr: break ; // Nothing else to do.
727
733
case CompoundStmt: break ; // Nothing else to do.
@@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
2350
2356
return ParseCompoundLiteralExpression (Ty.get (), OpenLoc, RParenLoc);
2351
2357
}
2352
2358
2359
+ if (Tok.is (tok::l_paren)) {
2360
+ // This could be OpenCL vector Literals
2361
+ if (getLangOpts ().OpenCL )
2362
+ {
2363
+ TypeResult Ty;
2364
+ {
2365
+ InMessageExpressionRAIIObject InMessage (*this , false );
2366
+ Ty = Actions.ActOnTypeName (getCurScope (), DeclaratorInfo);
2367
+ }
2368
+ if (Ty.isInvalid ())
2369
+ {
2370
+ return ExprError ();
2371
+ }
2372
+ QualType QT = Ty.get ().get ().getCanonicalType ();
2373
+ if (QT->isVectorType ())
2374
+ {
2375
+ // We parsed '(' vector-type-name ')' followed by '('
2376
+
2377
+ // Parse the cast-expression that follows it next.
2378
+ // isVectorLiteral = true will make sure we don't parse any
2379
+ // Postfix expression yet
2380
+ Result = ParseCastExpression (/* isUnaryExpression=*/ false ,
2381
+ /* isAddressOfOperand=*/ false ,
2382
+ /* isTypeCast=*/ IsTypeCast,
2383
+ /* isVectorLiteral=*/ true );
2384
+
2385
+ if (!Result.isInvalid ()) {
2386
+ Result = Actions.ActOnCastExpr (getCurScope (), OpenLoc,
2387
+ DeclaratorInfo, CastTy,
2388
+ RParenLoc, Result.get ());
2389
+ }
2390
+
2391
+ // After we performed the cast we can check for postfix-expr pieces.
2392
+ if (!Result.isInvalid ()) {
2393
+ Result = ParsePostfixExpressionSuffix (Result);
2394
+ }
2395
+
2396
+ return Result;
2397
+ }
2398
+ }
2399
+ }
2400
+
2353
2401
if (ExprType == CastExpr) {
2354
2402
// We parsed '(' type-name ')' and the thing after it wasn't a '{'.
2355
2403
@@ -2379,10 +2427,13 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
2379
2427
}
2380
2428
2381
2429
// Parse the cast-expression that follows it next.
2430
+ // isVectorLiteral = true will make sure we don't parse any
2431
+ // Postfix expression yet
2382
2432
// TODO: For cast expression with CastTy.
2383
2433
Result = ParseCastExpression (/* isUnaryExpression=*/ false ,
2384
2434
/* isAddressOfOperand=*/ false ,
2385
- /* isTypeCast=*/ IsTypeCast);
2435
+ /* isTypeCast=*/ IsTypeCast,
2436
+ /* isVectorLiteral=*/ true );
2386
2437
if (!Result.isInvalid ()) {
2387
2438
Result = Actions.ActOnCastExpr (getCurScope (), OpenLoc,
2388
2439
DeclaratorInfo, CastTy,
0 commit comments