On Fri, Sep 10, 2010 at 1:55 PM, Sebastian Redl <[email protected]> wrote: > Author: cornedbee > Date: Fri Sep 10 15:55:37 2010 > New Revision: 113622 > > URL: http://llvm.org/viewvc/llvm-project?rev=113622&view=rev > Log: > Parse the noexcept operator and stub out sema. > > Modified: > cfe/trunk/include/clang/Basic/TokenKinds.def > cfe/trunk/include/clang/Sema/Sema.h > cfe/trunk/lib/Parse/ParseExpr.cpp > cfe/trunk/lib/Sema/SemaExprCXX.cpp > > Modified: cfe/trunk/include/clang/Basic/TokenKinds.def > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=113622&r1=113621&r2=113622&view=diff > ============================================================================== > --- cfe/trunk/include/clang/Basic/TokenKinds.def (original) > +++ cfe/trunk/include/clang/Basic/TokenKinds.def Fri Sep 10 15:55:37 2010 > @@ -278,6 +278,7 @@ > KEYWORD(char32_t , KEYCXX0X) > KEYWORD(constexpr , KEYCXX0X) > KEYWORD(decltype , KEYCXX0X) > +KEYWORD(noexcept , KEYCXX0X) > KEYWORD(nullptr , KEYCXX0X) > KEYWORD(static_assert , KEYCXX0X) > KEYWORD(thread_local , KEYCXX0X) > > Modified: cfe/trunk/include/clang/Sema/Sema.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=113622&r1=113621&r2=113622&view=diff > ============================================================================== > --- cfe/trunk/include/clang/Sema/Sema.h (original) > +++ cfe/trunk/include/clang/Sema/Sema.h Fri Sep 10 15:55:37 2010 > @@ -2249,6 +2249,9 @@ > SourceLocation StmtLoc, > bool ConvertToBoolean); > > + ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, > + Expr *Operand, SourceLocation RParen); > + > /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support > /// pseudo-functions. > ExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT, > > Modified: cfe/trunk/lib/Parse/ParseExpr.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=113622&r1=113621&r2=113622&view=diff > ============================================================================== > --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) > +++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Sep 10 15:55:37 2010 > @@ -457,6 +457,7 @@ > /// [GNU] '&&' identifier > /// [C++] new-expression > /// [C++] delete-expression > +/// [C++0x] 'noexcept' '(' expression ')' > /// > /// unary-operator: one of > /// '&' '*' '+' '-' '~' '!' > @@ -546,9 +547,9 @@ > /// '__is_base_of' [TODO] > /// > ExprResult Parser::ParseCastExpression(bool isUnaryExpression, > - bool isAddressOfOperand, > - bool &NotCastExpr, > - ParsedType TypeOfCast) { > + bool isAddressOfOperand, > + bool &NotCastExpr, > + ParsedType TypeOfCast) { > ExprResult Res; > tok::TokenKind SavedKind = Tok.getKind(); > NotCastExpr = false; > @@ -891,6 +892,19 @@ > case tok::kw_delete: // [C++] delete-expression > return ParseCXXDeleteExpression(false, Tok.getLocation()); > > + case tok::kw_noexcept: { // [C++0x] 'noexcept' '(' expression ')' > + SourceLocation KeyLoc = ConsumeToken(); > + SourceLocation LParen = Tok.getLocation(); > + if (ExpectAndConsume(tok::l_paren, > + diag::err_expected_lparen_after, "noexcept")) > + return ExprError(); > + ExprResult Result = ParseExpression(); > + SourceLocation RParen = MatchRHSPunctuation(tok::r_paren, LParen); > + if (!Result.isInvalid()) > + Result = Actions.ActOnNoexceptExpr(KeyLoc, LParen, Result.take(), > RParen); > + return move(Result); > + } > + > case tok::kw___is_pod: // [GNU] unary-type-trait > case tok::kw___is_class: > case tok::kw___is_enum:
Don't you need an EnterExpressionEvaluationContext here? > Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=113622&r1=113621&r2=113622&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original) > +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 10 15:55:37 2010 > @@ -3114,6 +3114,17 @@ > return CE; > } > > +ExprResult Sema::ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation > LParen, > + Expr *Operand, SourceLocation RParen) { > + // C++ [expr.unary.noexcept]p1: > + // The noexcept operator determines whether the evaluation of its > operand, > + // which is an unevaluated operand, can throw an exception. > + ExprEvalContexts.back().Context = Unevaluated; This assignment looks strange... -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
