- D = PSI_DataExchange(&C->data[count], PSI_DATA(P));
-
- if (D->defs) {
- size_t i;
-
- for (i = 0; i < D->defs->count; ++i) {
- if (validate_decl_typedef(PSI_DATA(C), D->defs->list[i])) {
- C->defs = add_decl_typedef(C->defs, D->defs->list[i]);
+ D = psi_data_exchange(&C->data[count], PSI_DATA(P));
+
+#define REVALIDATE(what) do { \
+ if (check_round && check_ ##what) { \
+ free(check_ ##what->list); \
+ free(check_ ##what); \
+ } \
+ check_ ##what = recheck_ ##what; \
+} while (0)
+#define CHECK_TOTAL (CHECK_COUNT(defs) + CHECK_COUNT(structs) + CHECK_COUNT(enums))
+#define CHECK_COUNT(of) (check_ ##of ? check_ ##of->count : 0)
+
+ if (!(flags & PSI_PARSER_SILENT)) {
+ /* no warnings on first round */
+ C->flags |= PSI_PARSER_SILENT;
+ }
+ for (check_round = 0, check_count = 0; CHECK_TOTAL && check_count != CHECK_TOTAL; ++check_round) {
+ decl_typedefs *recheck_defs = NULL;
+ decl_structs *recheck_structs = NULL;
+ decl_unions *recheck_unions = NULL;
+ decl_enums *recheck_enums = NULL;
+
+ check_count = CHECK_TOTAL;
+
+ for (i = 0; i < CHECK_COUNT(defs); ++i) {
+ if (validate_decl_typedef(PSI_DATA(C), check_defs->list[i])) {
+ C->defs = add_decl_typedef(C->defs, check_defs->list[i]);
+ } else {
+ recheck_defs = add_decl_typedef(recheck_defs, check_defs->list[i]);