Skip to content

Commit

Permalink
Move empty==deduced type parse into type_id(), to allow const/*
Browse files Browse the repository at this point in the history
… with omitted type consistently

Closes #1138
  • Loading branch information
hsutter committed Jul 12, 2024
1 parent 13826c5 commit bd9e0c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion regression-tests/test-results/version
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

cppfront compiler v0.7.0 Build 9712:0926
cppfront compiler v0.7.0 Build 9712:1020
Copyright(c) Herb Sutter All rights reserved

SPDX-License-Identifier: CC-BY-NC-ND-4.0
Expand Down
2 changes: 1 addition & 1 deletion source/build.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"9712:0926"
"9712:1020"
19 changes: 7 additions & 12 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -6546,7 +6546,9 @@ class parser
//G 'const'
//G '*'
//G
auto type_id()
auto type_id(
bool allow_omitting_type_name = false
)
-> std::unique_ptr<type_id_node>
{
auto n = std::make_unique<type_id_node>();
Expand Down Expand Up @@ -6579,7 +6581,7 @@ class parser
n->id = std::move(id);
assert (n->id.index() == type_id_node::unqualified);
}
else {
else if (!allow_omitting_type_name) {
return {};
}
if (curr().type() == lexeme::Multiply) {
Expand Down Expand Up @@ -8524,8 +8526,8 @@ class parser
}
}

// Or just a type-id, declaring a non-pointer object
else if (auto t = type_id())
// Or just a (possibly empty == deduced) type-id
else if (auto t = type_id(true))
{
if (
t->get_token()
Expand All @@ -8545,6 +8547,7 @@ class parser

n->type = std::move(t);
assert (n->is_object());
deduced_type = n->has_wildcard_type();

if (!n->metafunctions.empty()) {
errors.emplace_back(
Expand All @@ -8560,14 +8563,6 @@ class parser
}
}

// Or nothing, declaring an object of deduced type,
// which we'll represent using an empty type-id
else {
n->type = std::make_unique<type_id_node>();
assert (n->is_object());
deduced_type = true;
}

// If we've already validated that this is a function where the parameter
// list is followed by a valid expression-statement, parse that again
// (requiring a semicolon as we validated when determining terse_no_equals)
Expand Down

0 comments on commit bd9e0c3

Please sign in to comment.