Skip to content

Commit 7eba6dc

Browse files
hsutterzaucy
authored andcommitted
Local object aliases should also be constexpr
See hsutter#731
1 parent 137b135 commit 7eba6dc

File tree

6 files changed

+13
-11
lines changed

6 files changed

+13
-11
lines changed

regression-tests/pure2-type-and-namespace-aliases.cpp2

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ N3: namespace == ::std::literals;
1717
myfunc: () = {
1818
v: N1::pmr_vec<myclass::str> = ("xyzzy", "plugh");
1919

20-
v2 :== v;
21-
20+
(v2 := v)
2221
for v2 do (s)
2322
std::cout << "(s)$\n";
2423
}

regression-tests/test-results/pure2-print.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ requires ((std::is_convertible_v<CPP2_TYPEOF(x), int> && ...))
170170

171171
using type_alias = std::array<int,10>;
172172

173-
cpp2::i8 const& object_alias_1 = 42;
174-
auto const& object_alias_2 = 42;
173+
cpp2::i8 constexpr object_alias_1 = 42;
174+
auto constexpr object_alias_2 = 42;
175175

176176
#line 75 "pure2-print.cpp2"
177177
::outer::mytype var {};

regression-tests/test-results/pure2-type-and-namespace-aliases.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace N3 = ::std::literals;
4343
auto myfunc() -> void;
4444

4545

46-
#line 26 "pure2-type-and-namespace-aliases.cpp2"
46+
#line 25 "pure2-type-and-namespace-aliases.cpp2"
4747
auto main() -> int;
4848

4949

@@ -58,18 +58,21 @@ namespace N {
5858
#line 17 "pure2-type-and-namespace-aliases.cpp2"
5959
auto myfunc() -> void{
6060
N1::pmr_vec<myclass::str> v {"xyzzy", "plugh"};
61+
{
62+
auto const& v2 = std::move(v);
6163

62-
auto const& v2 = std::move(v);
63-
64+
#line 21 "pure2-type-and-namespace-aliases.cpp2"
6465
for ( auto const& s : v2 )
6566
std::cout << cpp2::to_string(s) + "\n";
6667
}
68+
#line 23 "pure2-type-and-namespace-aliases.cpp2"
69+
}
6770

6871
auto main() -> int{
6972
using view = std::string_view;
7073
namespace N4 = std::literals;
7174

72-
auto const& myfunc2 = myfunc;
75+
auto constexpr myfunc2 = myfunc;
7376
myfunc2();
7477
}
7578

regression-tests/test-results/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
cppfront compiler v0.2.1 Build 8A09:0922
2+
cppfront compiler v0.2.1 Build 8A09:1000
33
Copyright(c) Herb Sutter All rights reserved
44

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

source/build.info

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"8A09:0922"
1+
"8A09:1000"

source/cppfront.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5192,7 +5192,7 @@ class cppfront
51925192
{
51935193
auto intro = std::string{};
51945194
if (n.parent_is_function()) {
5195-
intro = "const&";
5195+
intro = "constexpr";
51965196
}
51975197
else if (n.parent_is_namespace()) {
51985198
intro = "inline constexpr";

0 commit comments

Comments
 (0)