File tree Expand file tree Collapse file tree 4 files changed +44
-16
lines changed
regression-tests/test-results Expand file tree Collapse file tree 4 files changed +44
-16
lines changed Original file line number Diff line number Diff line change 1
1
2
- cppfront compiler v0.3.0 Build 9115:1948
2
+ cppfront compiler v0.3.0 Build 9116:1001
3
3
Copyright(c) Herb Sutter All rights reserved
4
4
5
5
SPDX-License-Identifier: CC-BY-NC-ND-4.0
Original file line number Diff line number Diff line change 1
- "9115:1948 "
1
+ "9116:1001 "
Original file line number Diff line number Diff line change @@ -810,6 +810,46 @@ auto lex_line(
810
810
};
811
811
812
812
813
+ auto qualify_cpp2_special_names = [&]
814
+ {
815
+ auto i = std::ssize (tokens)-1 ;
816
+
817
+ // If the last three tokens are "unique/shared" "." "new", add "cpp2::"
818
+
819
+ if (
820
+ i >= 2
821
+ && (tokens[i-2 ] == " unique" || tokens[i-2 ] == " shared" )
822
+ && tokens[i-1 ] == " ."
823
+ && tokens[i] == " new"
824
+ )
825
+ {
826
+ auto pos = tokens[i-2 ].position ();
827
+
828
+ generated_text.push_back ( " cpp2" );
829
+ tokens.insert (
830
+ tokens.end ()-3 ,
831
+ token{
832
+ &generated_text.back ()[0 ],
833
+ std::ssize (generated_text.back ()),
834
+ pos,
835
+ lexeme::Identifier
836
+ }
837
+ );
838
+
839
+ generated_text.push_back ( " ::" );
840
+ tokens.insert (
841
+ tokens.end ()-3 ,
842
+ token{
843
+ &generated_text.back ()[0 ],
844
+ std::ssize (generated_text.back ()),
845
+ pos,
846
+ lexeme::Scope
847
+ }
848
+ );
849
+ }
850
+ };
851
+
852
+
813
853
// Local helper functions for readability
814
854
//
815
855
auto peek = [&](int num) {
@@ -831,6 +871,7 @@ auto lex_line(
831
871
832
872
merge_cpp1_multi_token_fundamental_type_names ();
833
873
merge_operator_function_names ();
874
+ qualify_cpp2_special_names ();
834
875
};
835
876
836
877
Original file line number Diff line number Diff line change @@ -1743,6 +1743,7 @@ class cppfront
1743
1743
)
1744
1744
-> void
1745
1745
{ STACKINSTR
1746
+ assert ( n.identifier );
1746
1747
auto last_use = is_definite_last_use (n.identifier );
1747
1748
1748
1749
bool add_forward =
@@ -1862,20 +1863,6 @@ class cppfront
1862
1863
return ;
1863
1864
}
1864
1865
1865
- // Implicit "cpp2::" qualification of "unique.new" and "shared.new"
1866
- if (
1867
- n.ids .size () == 2
1868
- && (
1869
- *n.ids [0 ].id ->identifier == " unique"
1870
- || *n.ids [0 ].id ->identifier == " shared"
1871
- )
1872
- && *n.ids [1 ].scope_op == " ."
1873
- && *n.ids [1 ].id ->identifier == " new"
1874
- )
1875
- {
1876
- printer.print_cpp2 (" cpp2::" , n.position ());
1877
- }
1878
-
1879
1866
auto ident = std::string{};
1880
1867
printer.emit_to_string (&ident);
1881
1868
You can’t perform that action at this time.
0 commit comments