Skip to content

Commit bd9e0c3

Browse files
committed
Move empty==deduced type parse into type_id(), to allow const/* with omitted type consistently
Closes #1138
1 parent 13826c5 commit bd9e0c3

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
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.7.0 Build 9712:0926
2+
cppfront compiler v0.7.0 Build 9712:1020
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-
"9712:0926"
1+
"9712:1020"

source/parse.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6546,7 +6546,9 @@ class parser
65466546
//G 'const'
65476547
//G '*'
65486548
//G
6549-
auto type_id()
6549+
auto type_id(
6550+
bool allow_omitting_type_name = false
6551+
)
65506552
-> std::unique_ptr<type_id_node>
65516553
{
65526554
auto n = std::make_unique<type_id_node>();
@@ -6579,7 +6581,7 @@ class parser
65796581
n->id = std::move(id);
65806582
assert (n->id.index() == type_id_node::unqualified);
65816583
}
6582-
else {
6584+
else if (!allow_omitting_type_name) {
65836585
return {};
65846586
}
65856587
if (curr().type() == lexeme::Multiply) {
@@ -8524,8 +8526,8 @@ class parser
85248526
}
85258527
}
85268528

8527-
// Or just a type-id, declaring a non-pointer object
8528-
else if (auto t = type_id())
8529+
// Or just a (possibly empty == deduced) type-id
8530+
else if (auto t = type_id(true))
85298531
{
85308532
if (
85318533
t->get_token()
@@ -8545,6 +8547,7 @@ class parser
85458547

85468548
n->type = std::move(t);
85478549
assert (n->is_object());
8550+
deduced_type = n->has_wildcard_type();
85488551

85498552
if (!n->metafunctions.empty()) {
85508553
errors.emplace_back(
@@ -8560,14 +8563,6 @@ class parser
85608563
}
85618564
}
85628565

8563-
// Or nothing, declaring an object of deduced type,
8564-
// which we'll represent using an empty type-id
8565-
else {
8566-
n->type = std::make_unique<type_id_node>();
8567-
assert (n->is_object());
8568-
deduced_type = true;
8569-
}
8570-
85718566
// If we've already validated that this is a function where the parameter
85728567
// list is followed by a valid expression-statement, parse that again
85738568
// (requiring a semicolon as we validated when determining terse_no_equals)

0 commit comments

Comments
 (0)