diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-01-29 10:18:18 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-01-29 10:18:18 +0000 |
commit | 7dd5fe5ce60c8a7146980dc4a30a1574a719986a (patch) | |
tree | 4f8d3802e5a680a4ca973e06cf0e6a01c04e86a0 /clang/lib/Parse/ParseExpr.cpp | |
parent | 810ad3eb447e663984a79553e3c756a04ae7c418 (diff) | |
download | bcm5719-llvm-7dd5fe5ce60c8a7146980dc4a30a1574a719986a.tar.gz bcm5719-llvm-7dd5fe5ce60c8a7146980dc4a30a1574a719986a.zip |
Produce a diagnostic if alignas is applied to an expression. Neither C11 nor
C++11 allows that.
llvm-svn: 173789
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 9c788a13364..86cf6576747 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1609,11 +1609,11 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token &OpTok, /// unary-expression: [C99 6.5.3] /// 'sizeof' unary-expression /// 'sizeof' '(' type-name ')' -/// [C++0x] 'sizeof' '...' '(' identifier ')' +/// [C++11] 'sizeof' '...' '(' identifier ')' /// [GNU] '__alignof' unary-expression /// [GNU] '__alignof' '(' type-name ')' /// [C11] '_Alignof' '(' type-name ')' -/// [C++0x] 'alignof' '(' type-id ')' +/// [C++11] 'alignof' '(' type-id ')' /// \endverbatim ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() { assert((Tok.is(tok::kw_sizeof) || Tok.is(tok::kw___alignof) || @@ -1623,7 +1623,7 @@ ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() { Token OpTok = Tok; ConsumeToken(); - // [C++0x] 'sizeof' '...' '(' identifier ')' + // [C++11] 'sizeof' '...' '(' identifier ')' if (Tok.is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) { SourceLocation EllipsisLoc = ConsumeToken(); SourceLocation LParenLoc, RParenLoc; @@ -1694,6 +1694,9 @@ ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() { CastTy.getAsOpaquePtr(), CastRange); + if (OpTok.is(tok::kw_alignof) || OpTok.is(tok::kw__Alignof)) + Diag(OpTok, diag::ext_alignof_expr) << OpTok.getIdentifierInfo(); + // If we get here, the operand to the sizeof/alignof was an expresion. if (!Operand.isInvalid()) Operand = Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(), |