]> granicus.if.org Git - clang/commitdiff
Eli helped me understand how evaluation contexts work.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Fri, 10 Sep 2010 21:57:27 +0000 (21:57 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Fri, 10 Sep 2010 21:57:27 +0000 (21:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113642 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExpr.cpp
lib/Sema/SemaExprCXX.cpp
test/CXX/expr/expr.unary/expr.unary.noexcept/cg.cpp

index f2cf78492cb8f194890830bf852fb11cbe8b017c..1c2b343141df6b9fbb4b07b7876e54a15eb15786 100644 (file)
@@ -898,6 +898,10 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
     if (ExpectAndConsume(tok::l_paren,
                          diag::err_expected_lparen_after, "noexcept"))
       return ExprError();
+    // C++ [expr.unary.noexcept]p1:
+    //   The noexcept operator determines whether the evaluation of its operand,
+    //   which is an unevaluated operand, can throw an exception.
+    EnterExpressionEvaluationContext Unevaluated(Actions, Sema::Unevaluated);
     ExprResult Result = ParseExpression();
     SourceLocation RParen = MatchRHSPunctuation(tok::r_paren, LParen);
     if (!Result.isInvalid())
index 8e29caa6a1ae3b49e1fcb166adec5d68340e670f..382e9bb1851c4c9f11228bced29d58be5248ff81 100644 (file)
@@ -3116,11 +3116,6 @@ CXXMemberCallExpr *Sema::BuildCXXMemberCallExpr(Expr *Exp,
 
 ExprResult Sema::BuildCXXNoexceptExpr(SourceLocation KeyLoc, 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;
-
   return Owned(new (Context) CXXNoexceptExpr(Context.BoolTy, Operand,
                                              Operand->CanThrow(Context),
                                              KeyLoc, RParen));
index c567eff8c3053762690e86fa656b5a8d5103f5e4..aa2d553542d2bffb10d9ce258b13e75dcb49c7bf 100644 (file)
@@ -2,14 +2,25 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-pch -o %t-ser.pch -std=c++0x -x c++ %S/ser.h
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -emit-llvm -std=c++0x -include-pch %t-ser.pch %s -o - | FileCheck %s
 
+struct D {
+  ~D() throw();
+};
+struct E {
+  ~E() throw();
+};
+
 void test() {
   bool b;
   // CHECK: store i8 1, i8* %b, align 1
   b = noexcept(0);
   // CHECK: store i8 0, i8* %b, align 1
   b = noexcept(throw 0);
-  // CHECK: ret i1 true
   b = f1();
-  // CHECK: ret i1 false
   b = f2();
+
+  // CHECK-NOT: call void @_ZN1ED1Ev
+  // CHECK: call void @_ZN1DD1Ev
+  D(), noexcept(E());
 }
+// CHECK: ret i1 true
+// CHECK: ret i1 false