Skip to content

Commit 5bc091c

Browse files
committed
Don't cpp2::-qualify qualified/selected names
And remove the helpful "did you mean `new<>`" to allow more uses of `new` as an ordinary identifier
1 parent f06c673 commit 5bc091c

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

include/cpp2util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ struct String
388388
#define CPP2_MESSAGE_PARAM char const*
389389
#define CPP2_CONTRACT_MSG cpp2::message_to_cstr_adapter
390390

391-
auto message_to_cstr_adapter( CPP2_MESSAGE_PARAM msg ) -> CPP2_MESSAGE_PARAM { return msg ? msg : ""; }
392-
auto message_to_cstr_adapter( std::string const& msg ) -> CPP2_MESSAGE_PARAM { return msg.c_str(); }
391+
inline auto message_to_cstr_adapter( CPP2_MESSAGE_PARAM msg ) -> CPP2_MESSAGE_PARAM { return msg ? msg : ""; }
392+
inline auto message_to_cstr_adapter( std::string const& msg ) -> CPP2_MESSAGE_PARAM { return msg.c_str(); }
393393

394394
class contract_group {
395395
public:

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 9116:1001
2+
cppfront compiler v0.3.0 Build 9116:1317
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-
"9116:1001"
1+
"9116:1317"

source/lex.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,8 @@ auto lex_line(
817817
// If the last three tokens are "unique/shared" "." "new", add "cpp2::"
818818

819819
if (
820-
i >= 2
820+
i >= 3
821+
&& (tokens[i-3] != "::" && tokens[i-3] != ".")
821822
&& (tokens[i-2] == "unique" || tokens[i-2] == "shared")
822823
&& tokens[i-1] == "."
823824
&& tokens[i] == "new"

source/parse.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6591,11 +6591,7 @@ class parser
65916591
}
65926592

65936593
else {
6594-
if (*n->identifier == "new") {
6595-
error( "use 'new<" + curr().to_string() + ">', not 'new " + curr().to_string() + "'", false);
6596-
return {};
6597-
}
6598-
if (*n->identifier == "co_await" || *n->identifier == "co_yield") {
6594+
if (*n->identifier == "co_await" || *n->identifier == "co_yield") {
65996595
error( "(temporary alpha limitation) coroutines are not yet supported in Cpp2", false);
66006596
return {};
66016597
}

0 commit comments

Comments
 (0)