Skip to content

Commit 0c78d66

Browse files
committed
Partial fix for #14982 internalAstError for noexcept function with requires clause
1 parent 2e19539 commit 0c78d66

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

lib/templatesimplifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3831,7 +3831,7 @@ void TemplateSimplifier::simplifyTemplates(const std::time_t maxtime)
38313831
// Remove concepts/requires
38323832
// TODO concepts are not removed yet
38333833
for (Token *tok = mTokenList.front(); tok; tok = tok->next()) {
3834-
if (!Token::Match(tok, ")|>|>> requires %name%|("))
3834+
if (!Token::Match(tok, ")|>|>>|const|final|noexcept|override requires %name%|("))
38353835
continue;
38363836
const Token* end = skipRequires(tok->next());
38373837
if (end)

test/testsimplifytemplate.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ class TestSimplifyTemplate : public TestFixture {
314314
TEST_CASE(requires3);
315315
TEST_CASE(requires4);
316316
TEST_CASE(requires5);
317+
TEST_CASE(requires6);
317318

318319
TEST_CASE(explicitBool1);
319320
TEST_CASE(explicitBool2);
@@ -6696,6 +6697,22 @@ class TestSimplifyTemplate : public TestFixture {
66966697
ASSERT_EQUALS(expected, tok(code));
66976698
}
66986699

6700+
void requires6() {
6701+
const char code[] = "template <int N>\n" // #14982
6702+
"struct S {\n"
6703+
" static void f() noexcept\n"
6704+
" requires(N >= 5) {}\n"
6705+
" void g() const\n"
6706+
" requires(N >= 5) {}\n"
6707+
"};";
6708+
const char expected[] = "template < int N > "
6709+
"struct S { "
6710+
"static void f ( ) noexcept { } "
6711+
"void g ( ) const { } "
6712+
"} ;";
6713+
ASSERT_EQUALS(expected, tok(code));
6714+
}
6715+
66996716
void explicitBool1() {
67006717
const char code[] = "class Fred { explicit(true) Fred(int); };";
67016718
ASSERT_EQUALS("class Fred { explicit Fred ( int ) ; } ;", tok(code));

0 commit comments

Comments
 (0)