Skip to content

Commit 5fe3edf

Browse files
committed
fix(cpp1): recognize alias to _qualified-id_
1 parent 1f9637e commit 5fe3edf

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

regression-tests/pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ f: <T, V: T::value_type> (x: T::value_type) -> T::value_type = {
2626
_ = :w::value_type = x;
2727
v: type == w;
2828
_ = :v::value_type = x;
29+
a: type == T::type;
30+
_ = :a::value_type = x;
2931

3032
{
3133
// Test that there's no prefixed `typename` to....

regression-tests/test-results/pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#include "cpp2util.h"
88

99

10-
#line 44 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
10+
#line 46 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
1111
template<typename T> class t;
1212

1313

14-
#line 89 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
14+
#line 91 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
1515
template<typename T> class v;
1616

1717

@@ -23,14 +23,14 @@ template<typename T> using identity = T;
2323
template<typename T, T::value_type V> [[nodiscard]] auto f(cpp2::in<typename T::value_type> x) -> T::value_type;
2424

2525

26-
#line 44 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
26+
#line 46 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
2727
template<typename T> class t {
2828
struct u_x_as_base { T::value_type x; };
2929

30-
#line 45 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
30+
#line 47 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
3131
public: class u: public u_x_as_base, public T::type {
3232

33-
#line 48 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
33+
#line 50 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
3434
};
3535
public: T::value_type x {0};
3636
};
@@ -45,15 +45,15 @@ template<typename T> auto id(cpp2::in<std::integral_constant<cpp2::i32,T::value>
4545
auto main() -> int;
4646

4747

48-
#line 89 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
48+
#line 91 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
4949
template<typename T> class v {
5050
public: explicit v(T const& x);
51-
#line 90 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
51+
#line 92 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
5252
public: auto operator=(T const& x) -> v& ;
5353

5454
public: v(v const&) = delete; /* No 'that' constructor, suppress copy */
5555
public: auto operator=(v const&) -> void = delete;
56-
#line 91 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
56+
#line 93 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
5757
};
5858

5959

@@ -65,7 +65,7 @@ template<typename T, T::value_type V> [[nodiscard]] auto f(cpp2::in<typename T::
6565
cpp2::Default.expects(cpp2::is<typename T::value_type>(x), "");
6666
cpp2::deferred_init<typename T::value_type> y;
6767
y.construct(x);
68-
using z = typename T::value_type;
68+
using z = T::value_type;
6969
return { typename T::value_type{x} };
7070

7171
// Dependent *template-id*s.
@@ -87,6 +87,8 @@ template<typename T, T::value_type V> [[nodiscard]] auto f(cpp2::in<typename T::
8787
(void) typename w::value_type{x};
8888
using v = w;
8989
(void) typename v::value_type{x};
90+
using a = T::type;
91+
(void) typename a::value_type{x};
9092

9193
{
9294
// Test that there's no prefixed `typename` to....
@@ -102,7 +104,7 @@ template<typename T, T::value_type V> [[nodiscard]] auto f(cpp2::in<typename T::
102104
}
103105
}
104106

105-
#line 54 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
107+
#line 56 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
106108
template<typename T> auto init(cpp2::out<std::integral_constant<cpp2::i32,T::value>> x) -> void{x.construct(); }
107109
template<typename T> auto init(cpp2::out<std::integral_constant<cpp2::i32,T::value>> x, T const& _) -> void{x.construct(); }
108110
template<typename T> [[nodiscard]] auto id(cpp2::in<std::integral_constant<cpp2::i32,T::value>> x) -> auto&& { return x; }
@@ -138,11 +140,11 @@ auto main() -> int{
138140
(void) []<typename T>(cpp2::in<typename T::value_type> x) -> void{(void) []() -> void{(void) []() -> void{(void) []() -> void{}; }; }; };
139141
}
140142

141-
#line 90 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
143+
#line 92 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
142144
template <typename T> v<T>::v(T const& x){}
143-
#line 90 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
145+
#line 92 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
144146
template <typename T> auto v<T>::operator=(T const& x) -> v& {
145147
return *this;
146-
#line 90 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
148+
#line 92 "pure2-bugfix-for-dependent-types-and-deducible-parameters.cpp2"
147149
}
148150

source/cppfront.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,13 +1794,11 @@ class cppfront
17941794
auto is_dependent(const type_id_node& n)
17951795
-> bool
17961796
{
1797-
// Its value is an _unqualified-id_
1798-
if (n.id.index() == type_id_node::unqualified) {
1799-
auto& id = *get_if<type_id_node::unqualified>(&n.id);
1800-
if (id->open_angle == source_position{}) {
1801-
// that is dependent.
1802-
return is_dependent(*id);
1803-
}
1797+
if (auto qual = get_if<id_expression_node::qualified>(&n.id)) {
1798+
return is_dependent(**qual);
1799+
}
1800+
else if (auto unqual = get_if<id_expression_node::unqualified>(&n.id)) {
1801+
return is_dependent(**unqual);
18041802
}
18051803
return false;
18061804
}
@@ -5069,7 +5067,7 @@ class cppfront
50695067
"using "
50705068
+ print_to_string(*n.identifier)
50715069
+ " = "
5072-
+ print_to_string( *std::get<alias_node::a_type>(a->initializer) )
5070+
+ print_to_string( *std::get<alias_node::a_type>(a->initializer), true )
50735071
+ ";\n",
50745072
n.position()
50755073
);

0 commit comments

Comments
 (0)