diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 38 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 4 |
2 files changed, 31 insertions, 11 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 8ce3bc1746..3511f4abde 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -1552,19 +1552,28 @@ Parser::getDeclSpecContextFromDeclaratorContext(unsigned Context) { /// FIXME: Simply returns an alignof() expression if the argument is a /// type. Ideally, the type should be propagated directly into Sema. /// -/// [C1X/C++0x] type-id -/// [C1X] constant-expression -/// [C++0x] assignment-expression -ExprResult Parser::ParseAlignArgument(SourceLocation Start) { +/// [C1X] type-id +/// [C1X] constant-expression +/// [C++0x] type-id ...[opt] +/// [C++0x] assignment-expression ...[opt] +ExprResult Parser::ParseAlignArgument(SourceLocation Start, + SourceLocation &EllipsisLoc) { + ExprResult ER; if (isTypeIdInParens()) { - EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated); SourceLocation TypeLoc = Tok.getLocation(); ParsedType Ty = ParseTypeName().get(); SourceRange TypeRange(Start, Tok.getLocation()); - return Actions.ActOnUnaryExprOrTypeTraitExpr(TypeLoc, UETT_AlignOf, true, - Ty.getAsOpaquePtr(), TypeRange); + ER = Actions.ActOnUnaryExprOrTypeTraitExpr(TypeLoc, UETT_AlignOf, true, + Ty.getAsOpaquePtr(), TypeRange); } else - return ParseConstantExpression(); + ER = ParseConstantExpression(); + + if (getLang().CPlusPlus0x && Tok.is(tok::ellipsis)) { + EllipsisLoc = Tok.getLocation(); + ConsumeToken(); + } + + return ER; } /// ParseAlignmentSpecifier - Parse an alignment-specifier, and add the @@ -1573,8 +1582,8 @@ ExprResult Parser::ParseAlignArgument(SourceLocation Start) { /// alignment-specifier: /// [C1X] '_Alignas' '(' type-id ')' /// [C1X] '_Alignas' '(' constant-expression ')' -/// [C++0x] 'alignas' '(' type-id ')' -/// [C++0x] 'alignas' '(' assignment-expression ')' +/// [C++0x] 'alignas' '(' type-id ...[opt] ')' +/// [C++0x] 'alignas' '(' assignment-expression ...[opt] ')' void Parser::ParseAlignmentSpecifier(ParsedAttributes &Attrs, SourceLocation *endLoc) { assert((Tok.is(tok::kw_alignas) || Tok.is(tok::kw__Alignas)) && @@ -1587,7 +1596,8 @@ void Parser::ParseAlignmentSpecifier(ParsedAttributes &Attrs, if (T.expectAndConsume(diag::err_expected_lparen)) return; - ExprResult ArgExpr = ParseAlignArgument(T.getOpenLocation()); + SourceLocation EllipsisLoc; + ExprResult ArgExpr = ParseAlignArgument(T.getOpenLocation(), EllipsisLoc); if (ArgExpr.isInvalid()) { SkipUntil(tok::r_paren); return; @@ -1597,6 +1607,12 @@ void Parser::ParseAlignmentSpecifier(ParsedAttributes &Attrs, if (endLoc) *endLoc = T.getCloseLocation(); + // FIXME: Handle pack-expansions here. + if (EllipsisLoc.isValid()) { + Diag(EllipsisLoc, diag::err_alignas_pack_exp_unsupported); + return; + } + ExprVector ArgExprs(Actions); ArgExprs.push_back(ArgExpr.release()); Attrs.addNew(PP.getIdentifierInfo("aligned"), KWLoc, 0, KWLoc, diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index d801664ad6..d43e1f1a9b 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -2544,6 +2544,10 @@ static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr) { } void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E) { + // FIXME: Handle pack-expansions here. + if (DiagnoseUnexpandedParameterPack(E)) + return; + if (E->isTypeDependent() || E->isValueDependent()) { // Save dependent expressions in the AST to be instantiated. D->addAttr(::new (Context) AlignedAttr(AttrRange, Context, true, E)); |