llvm-capstone/clang/test/SemaTemplate/class-template-noexcept.cpp
Zhouyi Zhou 30adb9fd27 let EST_Uninstantiated in FunctionProtoType::canThrow return
CT_Dependent

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

class A {
  public:

  static const char X;

};
const char A::X = 0;

template<typename U> void func() noexcept(U::X);

template<class... B, char x>
void foo(void(B...) noexcept(x)) {}

void bar()
{

  foo(func<A>);

}

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

Differential Revision: https://reviews.llvm.org/D121498
2022-03-16 07:09:42 -07:00

33 lines
658 B
C++

// RUN: %clang_cc1 -verify %s
// RUN: %clang_cc1 -std=c++11 -verify %s
// RUN: %clang_cc1 -std=c++17 -verify %s
// RUN: %clang_cc1 -std=c++1z -verify %s
#if __cplusplus >= 201703
// expected-no-diagnostics
#endif
class A {
public:
static const char X;
};
const char A::X = 0;
template<typename U> void func() noexcept(U::X);
template<class... B, char x>
#if __cplusplus >= 201703
void foo(void(B...) noexcept(x)) {}
#else
void foo(void(B...) noexcept(x)) {} // expected-note{{candidate template ignored}}
#endif
void bar()
{
#if __cplusplus >= 201703
foo(func<A>);
#else
foo(func<A>); // expected-error{{no matching function for call}}
#endif
}