Skip to content

Commit 30adb9f

Browse files
zhouzhouyi-hubErich Keane
authored andcommitted
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
1 parent 4c9bfec commit 30adb9f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

clang/lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,6 @@ CanThrowResult FunctionProtoType::canThrow() const {
33253325
switch (getExceptionSpecType()) {
33263326
case EST_Unparsed:
33273327
case EST_Unevaluated:
3328-
case EST_Uninstantiated:
33293328
llvm_unreachable("should not call this with unresolved exception specs");
33303329

33313330
case EST_DynamicNone:
@@ -3347,6 +3346,7 @@ CanThrowResult FunctionProtoType::canThrow() const {
33473346
return CT_Can;
33483347
return CT_Dependent;
33493348

3349+
case EST_Uninstantiated:
33503350
case EST_DependentNoexcept:
33513351
return CT_Dependent;
33523352
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang_cc1 -verify %s
2+
// RUN: %clang_cc1 -std=c++11 -verify %s
3+
// RUN: %clang_cc1 -std=c++17 -verify %s
4+
// RUN: %clang_cc1 -std=c++1z -verify %s
5+
#if __cplusplus >= 201703
6+
// expected-no-diagnostics
7+
#endif
8+
class A {
9+
public:
10+
static const char X;
11+
};
12+
const char A::X = 0;
13+
14+
template<typename U> void func() noexcept(U::X);
15+
16+
template<class... B, char x>
17+
#if __cplusplus >= 201703
18+
void foo(void(B...) noexcept(x)) {}
19+
#else
20+
void foo(void(B...) noexcept(x)) {} // expected-note{{candidate template ignored}}
21+
#endif
22+
23+
void bar()
24+
{
25+
#if __cplusplus >= 201703
26+
foo(func<A>);
27+
#else
28+
foo(func<A>); // expected-error{{no matching function for call}}
29+
#endif
30+
}
31+
32+

0 commit comments

Comments
 (0)