forked from OSchip/llvm-project
Fix Altivec vector literal parser hack for C++11.
It doesn't make any sense to accept "..." in the argument to a C-style cast, so use a separate expression list parsing routine which rejects it. PR16874. llvm-svn: 188330
This commit is contained in:
parent
1a61f621da
commit
7a15c4af90
|
@ -1267,6 +1267,12 @@ private:
|
|||
ArrayRef<Expr *> Args) = 0,
|
||||
Expr *Data = 0);
|
||||
|
||||
/// ParseSimpleExpressionList - A simple comma-separated list of expressions,
|
||||
/// used for misc language extensions.
|
||||
bool ParseSimpleExpressionList(SmallVectorImpl<Expr*> &Exprs,
|
||||
SmallVectorImpl<SourceLocation> &CommaLocs);
|
||||
|
||||
|
||||
/// ParenParseOption - Control what ParseParenExpression will parse.
|
||||
enum ParenParseOption {
|
||||
SimpleExpr, // Only parse '(' expression ')'
|
||||
|
|
|
@ -1371,7 +1371,7 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
|
|||
CommaLocsTy ExecConfigCommaLocs;
|
||||
SourceLocation OpenLoc = ConsumeToken();
|
||||
|
||||
if (ParseExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
|
||||
if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
|
||||
LHS = ExprError();
|
||||
}
|
||||
|
||||
|
@ -2141,7 +2141,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, bool stopIfCastExpr,
|
|||
ExprVector ArgExprs;
|
||||
CommaLocsTy CommaLocs;
|
||||
|
||||
if (!ParseExpressionList(ArgExprs, CommaLocs)) {
|
||||
if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
|
||||
ExprType = SimpleExpr;
|
||||
Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
|
||||
ArgExprs);
|
||||
|
@ -2370,6 +2370,32 @@ bool Parser::ParseExpressionList(SmallVectorImpl<Expr*> &Exprs,
|
|||
}
|
||||
}
|
||||
|
||||
/// ParseSimpleExpressionList - A simple comma-separated list of expressions,
|
||||
/// used for misc language extensions.
|
||||
///
|
||||
/// \verbatim
|
||||
/// simple-expression-list:
|
||||
/// assignment-expression
|
||||
/// simple-expression-list , assignment-expression
|
||||
/// \endverbatim
|
||||
bool
|
||||
Parser::ParseSimpleExpressionList(SmallVectorImpl<Expr*> &Exprs,
|
||||
SmallVectorImpl<SourceLocation> &CommaLocs) {
|
||||
while (1) {
|
||||
ExprResult Expr = ParseAssignmentExpression();
|
||||
if (Expr.isInvalid())
|
||||
return true;
|
||||
|
||||
Exprs.push_back(Expr.release());
|
||||
|
||||
if (Tok.isNot(tok::comma))
|
||||
return false;
|
||||
|
||||
// Move to the next argument, remember where the comma was.
|
||||
CommaLocs.push_back(ConsumeToken());
|
||||
}
|
||||
}
|
||||
|
||||
/// ParseBlockId - Parse a block-id, which roughly looks like int (int x).
|
||||
///
|
||||
/// \verbatim
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify %s
|
||||
// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -faltivec -fsyntax-only -verify -std=c++11 %s
|
||||
|
||||
__vector char vv_c;
|
||||
__vector signed char vv_sc;
|
||||
|
@ -168,3 +168,7 @@ public:
|
|||
__vector float xyzw;
|
||||
__vector float abcd;
|
||||
} __attribute__((vecreturn)); // expected-error {{the vecreturn attribute can only be used on a class or structure with one member, which must be a vector}}
|
||||
|
||||
template<typename... Args> void PR16874() {
|
||||
(void) (Args::foo()...); // expected-error {{expression contains unexpanded parameter pack 'Args'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue