zhouyizhou created this revision.
zhouyizhou added reviewers: rsmith, erichkeane, CornedBee.
Herald added a project: All.
zhouyizhou requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When compile following code without -std=c++17, clang will abort by 
llvm_unreachable:

- code begin ---

template<class T>
void foo() noexcept(T::value);

struct S {

  static const bool value;

};

const bool S::value = 0;

template<class... Args, bool is_noexcept>
constexpr bool is_noexcept_function(void(Args...) noexcept(is_noexcept)) {

  return is_noexcept;

}

void fn()
{

  is_noexcept_function(foo<S>);

}

- code end ---

So, my solution is to let EST_Uninstantiated in FunctionProtoType::canThrow 
return CT_Dependent

Thanks
Zhouyi Zhou <zhouzho...@gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121498

Files:
  clang/lib/AST/Type.cpp


Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3320,8 +3320,9 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
     llvm_unreachable("should not call this with unresolved exception specs");
+  case EST_Uninstantiated:
+    return CT_Dependent;
 
   case EST_DynamicNone:
   case EST_BasicNoexcept:


Index: clang/lib/AST/Type.cpp
===================================================================
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3320,8 +3320,9 @@
   switch (getExceptionSpecType()) {
   case EST_Unparsed:
   case EST_Unevaluated:
-  case EST_Uninstantiated:
     llvm_unreachable("should not call this with unresolved exception specs");
+  case EST_Uninstantiated:
+    return CT_Dependent;
 
   case EST_DynamicNone:
   case EST_BasicNoexcept:
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to