Skip to content

Commit e31c17f

Browse files
committed
[C++] Fail on fatal diagnostic
Signed-off-by: AeroStun <[email protected]>
1 parent fc0e43c commit e31c17f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arduino-prelude.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,19 @@ int main(int argc, char** argv) {
117117
return EXIT_FAILURE;
118118
}
119119

120+
{
121+
const auto num_diag = ::clang_getNumDiagnostics(unit);
122+
for (unsigned i = 0; i < num_diag; ++i) {
123+
struct UniqueDiagnostic {
124+
::CXDiagnostic m;
125+
~UniqueDiagnostic() { ::clang_disposeDiagnostic(m); }
126+
} diag{::clang_getDiagnostic(unit, i)};
127+
128+
if (::clang_getDiagnosticSeverity(diag.m) == ::CXDiagnostic_Fatal)
129+
return EXIT_FAILURE;
130+
}
131+
}
132+
120133
auto cursor = ::clang_getTranslationUnitCursor(unit);
121134

122135
state.ppp = ::clang_getCursorPrintingPolicy(cursor);

0 commit comments

Comments
 (0)