summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/include/clang/Parse/Action.h4
-rw-r--r--clang/lib/Parse/ParseExpr.cpp3
-rw-r--r--clang/lib/Sema/Sema.h3
-rw-r--r--clang/test/Sema/cast.c4
4 files changed, 13 insertions, 1 deletions
diff --git a/clang/include/clang/Parse/Action.h b/clang/include/clang/Parse/Action.h
index abe50d05bcc..de5a82f071d 100644
--- a/clang/include/clang/Parse/Action.h
+++ b/clang/include/clang/Parse/Action.h
@@ -1048,6 +1048,10 @@ public:
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/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index bb6dfcebb57..5eb19d07cd6 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1365,7 +1365,8 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
// 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/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index cff346b9dfc..9e20771b826 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -1536,6 +1536,9 @@ public:
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/clang/test/Sema/cast.c b/clang/test/Sema/cast.c
index ec19626d28e..d2e3e0c7e3a 100644
--- a/clang/test/Sema/cast.c
+++ b/clang/test/Sema/cast.c
@@ -12,3 +12,7 @@ void bar() {
a = (char*)b; // expected-error {{cannot be cast to a pointer type}}
}
+long bar1(long *next) {
+ return (long)(*next)++;
+}
+
OpenPOWER on IntegriCloud