This revision was automatically updated to reflect the committed changes.
Closed by commit rL315638: [Sema][Crash] Correctly handle an non-dependent 
noexcept expr in function… (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38700?vs=118245&id=118858#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38700

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/CXX/except/except.spec/p1.cpp


Index: cfe/trunk/test/CXX/except/except.spec/p1.cpp
===================================================================
--- cfe/trunk/test/CXX/except/except.spec/p1.cpp
+++ cfe/trunk/test/CXX/except/except.spec/p1.cpp
@@ -86,3 +86,12 @@
     f<0>(); // expected-note{{in instantiation of function template 
specialization}}
   }
 }
+
+namespace FuncTmplNoexceptError {
+  int a = 0;
+  // expected-error@+1{{argument to noexcept specifier must be a constant 
expression}}
+  template <class T> T f() noexcept(a++){ return {};}
+  void g(){
+    f<int>();
+  }
+};
Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -14865,10 +14865,16 @@
         return;
       }
 
-      if (!NoexceptExpr->isValueDependent())
-        NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, nullptr,
-                         diag::err_noexcept_needs_constant_expression,
-                         /*AllowFold*/ false).get();
+      if (!NoexceptExpr->isValueDependent()) {
+        ExprResult Result = VerifyIntegerConstantExpression(
+            NoexceptExpr, nullptr, 
diag::err_noexcept_needs_constant_expression,
+            /*AllowFold*/ false);
+        if (Result.isInvalid()) {
+          ESI.Type = EST_BasicNoexcept;
+          return;
+        }
+        NoexceptExpr = Result.get();
+      }
       ESI.NoexceptExpr = NoexceptExpr;
     }
     return;


Index: cfe/trunk/test/CXX/except/except.spec/p1.cpp
===================================================================
--- cfe/trunk/test/CXX/except/except.spec/p1.cpp
+++ cfe/trunk/test/CXX/except/except.spec/p1.cpp
@@ -86,3 +86,12 @@
     f<0>(); // expected-note{{in instantiation of function template specialization}}
   }
 }
+
+namespace FuncTmplNoexceptError {
+  int a = 0;
+  // expected-error@+1{{argument to noexcept specifier must be a constant expression}}
+  template <class T> T f() noexcept(a++){ return {};}
+  void g(){
+    f<int>();
+  }
+};
Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -14865,10 +14865,16 @@
         return;
       }
 
-      if (!NoexceptExpr->isValueDependent())
-        NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, nullptr,
-                         diag::err_noexcept_needs_constant_expression,
-                         /*AllowFold*/ false).get();
+      if (!NoexceptExpr->isValueDependent()) {
+        ExprResult Result = VerifyIntegerConstantExpression(
+            NoexceptExpr, nullptr, diag::err_noexcept_needs_constant_expression,
+            /*AllowFold*/ false);
+        if (Result.isInvalid()) {
+          ESI.Type = EST_BasicNoexcept;
+          return;
+        }
+        NoexceptExpr = Result.get();
+      }
       ESI.NoexceptExpr = NoexceptExpr;
     }
     return;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to