@@ -82,13 +82,21 @@ CompileError::CompileError(Location location, std::string&& message, std::vector
8282: location(location), message(std::move(message)), notes(std::move(notes)) {}
8383
8484void CompileError::report () const {
85- if (message.empty ()) return ; // This is a "silent" error, resulting from a previous, reported error.
85+ if (message.empty ()) return ;
8686
8787 StringFormatter s;
8888 s << message;
8989 reportError (location, s, notes);
9090}
9191
92+ void CompileError::reportAsWarning () const {
93+ if (message.empty ()) return ;
94+
95+ StringFormatter s;
96+ s << message;
97+ reportWarning (location, s, notes);
98+ }
99+
92100std::optional<std::string> cx::findExternalCCompiler () {
93101#ifdef _WIN32
94102 auto compilers = {" cl.exe" , " clang-cl.exe" };
@@ -128,12 +136,16 @@ void cx::reportError(Location location, StringFormatter& message, llvm::ArrayRef
128136 }
129137}
130138
131- void cx::reportWarning (Location location, StringFormatter& message) {
139+ void cx::reportWarning (Location location, StringFormatter& message, llvm::ArrayRef<Note> notes ) {
132140 if (disableWarnings) return ;
133141
134142 if (warningsAsErrors) {
135- reportError (location, message);
143+ reportError (location, message, notes );
136144 } else {
137145 printDiagnostic (location, " warning" , llvm::raw_ostream::YELLOW, message.str ());
146+
147+ for (auto & note : notes) {
148+ printDiagnostic (note.location , " note" , llvm::raw_ostream::BLACK, note.message );
149+ }
138150 }
139151}
0 commit comments