Skip to content

Commit d608eb5

Browse files
committed
Fix unqualified_id handling of empty template arguments, closes #819
A fully empty `<>` list is allowed, but `unqualified_id_node::to_string` didn't handle empty `<>` correctly and included the `>`. Now it doesn't include it. A nonempty `<>` list shouldn't have an empty argument in the list.
1 parent c840548 commit d608eb5

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

regression-tests/test-results/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.3.0 Build 8B10:1325
2+
cppfront compiler v0.3.0 Build 8B13:1628
33
Copyright(c) Herb Sutter All rights reserved
44

55
SPDX-License-Identifier: CC-BY-NC-ND-4.0

source/build.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"8B10:1325"
1+
"8B13:1628"

source/parse.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,9 @@ auto unqualified_id_node::to_string() const
12941294
}
12951295
separator = ",";
12961296
}
1297-
ret += ">";
1297+
if (std::ssize(template_args) > 0) {
1298+
ret += ">";
1299+
}
12981300
}
12991301
return ret;
13001302
}
@@ -6237,6 +6239,14 @@ class parser
62376239
term.arg = std::move(i);
62386240
}
62396241

6242+
// Else if we already got at least one template-argument, this is a
6243+
// ',' followed by something that isn't a valid template-arg
6244+
else if (std::ssize(n->template_args) > 0) {
6245+
error( "expected a template argument after ','", false);
6246+
return {};
6247+
}
6248+
6249+
// Else this is an empty '<>' list which is okay
62406250
else {
62416251
break;
62426252
}
@@ -7873,7 +7883,7 @@ class parser
78737883
next();
78747884
auto idx = id_expression();
78757885
if (!idx) {
7876-
error("'@' must be followed by a a metafunction name", false);
7886+
error("'@' must be followed by a metafunction name", false);
78777887
return {};
78787888
}
78797889
n->metafunctions.push_back( std::move(idx) );

0 commit comments

Comments
 (0)