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 | a0109e284457c996d4eb8f231e01dda303d1a345 (patch) | |
tree | 9265c30c711de7f921f9bdd5f8c2f72aceac71d4 /lib/Parse/ParseExpr.cpp | |
parent | d03de6aaa312d57dcd6e2bc76bed1e89f5c5019d (diff) |
Produce a diagnostic if alignas is applied to an expression. Neither C11 nor
C++11 allows that.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173789 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 9c788a1336..86cf657674 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/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(), |