Preprocesser: do not add file body if there's nothing there
Before this if a file only defined constants and was then included, the root unit set would still have an empty PP_USE unit. We should only have that if there's something there past preprocessing. Hence, do not add empty bodies to the unit list.
This commit is contained in:
@@ -154,11 +154,12 @@ namespace Preprocesser
|
|||||||
std::vector<Unit> body_units;
|
std::vector<Unit> body_units;
|
||||||
Err *err = preprocess(body, body_units, new_token_bag, const_map,
|
Err *err = preprocess(body, body_units, new_token_bag, const_map,
|
||||||
file_map, depth + 1);
|
file_map, depth + 1);
|
||||||
// TODO: Introduce stack traces for this error (this error occurs in
|
|
||||||
// outside file that has use site in current file).
|
|
||||||
if (err)
|
if (err)
|
||||||
return new Err{ET::IN_ERROR, token, err};
|
return new Err{ET::IN_ERROR, token, err};
|
||||||
units.push_back(Unit{token, body_units});
|
|
||||||
|
// Compile away empty bodies
|
||||||
|
if (body_units.size() != 0)
|
||||||
|
units.push_back(Unit{token, body_units});
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
// Otherwise file must be part of the source tree already, so skip this
|
// Otherwise file must be part of the source tree already, so skip this
|
||||||
|
|||||||
Reference in New Issue
Block a user