@@ -115,13 +115,44 @@ static cmdline_processor::register_flag cmd_cpp1_filename(
115
115
[](std::string const & name) { flag_cpp1_filename = name; }
116
116
);
117
117
118
+ static auto flag_print_colon_errors = false ;
119
+ static cmdline_processor::register_flag cmd_print_colon_errors (
120
+ 2 ,
121
+ " format-colon-errors" ,
122
+ " Emit ':line:col:' format for error messages" ,
123
+ []{ flag_print_colon_errors = true ; }
124
+ );
118
125
119
126
struct text_with_pos {
120
127
std::string text;
121
128
source_position pos;
122
129
text_with_pos (std::string const & t, source_position p) : text{t}, pos{p} { }
123
130
};
124
131
132
+ // Defined out of line so we can use flag_print_colon_errors.
133
+ auto error::print (auto & o, std::string const & file) const -> void {
134
+ o << file ;
135
+ if (where.lineno > 0 ) {
136
+ if (flag_print_colon_errors) {
137
+ o << " :" << (where.lineno );
138
+ if (where.colno >= 0 ) {
139
+ o << " :" << where.colno ;
140
+ }
141
+ }
142
+ else {
143
+ o << " (" << (where.lineno );
144
+ if (where.colno >= 0 ) {
145
+ o << " ," << where.colno ;
146
+ }
147
+ o << " )" ;
148
+ }
149
+ }
150
+ o << " :" ;
151
+ if (internal) {
152
+ o << " internal compiler" ;
153
+ }
154
+ o << " error: " << msg << " \n " ;
155
+ }
125
156
126
157
class positional_printer
127
158
{
@@ -1856,7 +1887,7 @@ class cppfront
1856
1887
assert (i->expr_list );
1857
1888
if (!i->expr_list ->expressions .empty ()) {
1858
1889
local_args.text_chunks = print_to_text_chunks (*i->expr_list );
1859
- }
1890
+ }
1860
1891
1861
1892
flush_args ();
1862
1893
args.emplace (std::move (local_args));
@@ -1958,7 +1989,7 @@ class cppfront
1958
1989
1959
1990
if (i->expr_list ) {
1960
1991
auto text = print_to_text_chunks (*i->expr_list );
1961
- for (auto && e: text) {
1992
+ for (auto && e: text) {
1962
1993
suffix.push_back (e);
1963
1994
}
1964
1995
}
0 commit comments