Skip to content

Commit 937383f

Browse files
committed
Emit access-specifiers only in lowering phase 1
1 parent 45fb75e commit 937383f

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

source/cppfront.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4457,20 +4457,20 @@ class cppfront
44574457
}
44584458
}
44594459

4460-
if (n.access) {
4461-
assert (is_in_type);
4462-
printer.print_cpp2(n.access->to_string(true) + ": ", n.access->position());
4463-
}
4464-
else if (
4465-
is_in_type
4466-
&& printer.get_phase() == printer.phase1_type_defs_func_decls
4467-
)
4468-
{
4469-
if (n.is_object()) {
4470-
printer.print_cpp2("private: ", n.position());
4471-
}
4472-
else {
4473-
printer.print_cpp2("public: ", n.position());
4460+
// In class definitions, emit the explicit access specifier if there
4461+
// is one, or default to private for data and public for functions
4462+
if (printer.get_phase() == printer.phase1_type_defs_func_decls) {
4463+
if (n.access) {
4464+
assert (is_in_type);
4465+
printer.print_cpp2(n.access->to_string(true) + ": ", n.access->position());
4466+
}
4467+
else if (is_in_type) {
4468+
if (n.is_object()) {
4469+
printer.print_cpp2("private: ", n.position());
4470+
}
4471+
else {
4472+
printer.print_cpp2("public: ", n.position());
4473+
}
44744474
}
44754475
}
44764476

0 commit comments

Comments
 (0)