Fix a recent regression probably caused by addition of altivec-style
type-casts in the parser.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89691 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index abe50d0..de5a82f 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -1048,6 +1048,10 @@
return ExprEmpty();
}
+ virtual bool TypeIsVectorType(TypeTy *Ty) {
+ return false;
+ }
+
virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
tok::TokenKind Kind,
ExprArg LHS, ExprArg RHS) {
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index bb6dfce..5eb19d0 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -1365,7 +1365,8 @@
// Parse the cast-expression that follows it next.
// TODO: For cast expression with CastTy.
- Result = ParseCastExpression(false, false, true);
+ Result = ParseCastExpression(false, false,
+ Actions.TypeIsVectorType(CastTy));
if (!Result.isInvalid())
Result = Actions.ActOnCastExpr(CurScope, OpenLoc, CastTy, RParenLoc,
move(Result));
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index cff346b..9e20771 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1536,6 +1536,9 @@
virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
TypeTy *Ty, SourceLocation RParenLoc,
ExprArg Op);
+ virtual bool TypeIsVectorType(TypeTy *Ty) {
+ return GetTypeFromParser(Ty)->isVectorType();
+ }
OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg ME);
OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
diff --git a/test/Sema/cast.c b/test/Sema/cast.c
index ec19626..d2e3e0c 100644
--- a/test/Sema/cast.c
+++ b/test/Sema/cast.c
@@ -12,3 +12,7 @@
a = (char*)b; // expected-error {{cannot be cast to a pointer type}}
}
+long bar1(long *next) {
+ return (long)(*next)++;
+}
+