|
@@ -288,7 +288,7 @@ class CommandLineInterface::ErrorPrinter
|
|
|
public DescriptorPool::ErrorCollector {
|
|
|
public:
|
|
|
ErrorPrinter(ErrorFormat format, DiskSourceTree* tree = NULL)
|
|
|
- : format_(format), tree_(tree), found_errors_(false) {}
|
|
|
+ : format_(format), tree_(tree), found_errors_(false), found_warnings_(false) {}
|
|
|
~ErrorPrinter() {}
|
|
|
|
|
|
// implements MultiFileErrorCollector ------------------------------
|
|
@@ -300,6 +300,7 @@ class CommandLineInterface::ErrorPrinter
|
|
|
|
|
|
void AddWarning(const std::string& filename, int line, int column,
|
|
|
const std::string& message) {
|
|
|
+ found_warnings_ = true;
|
|
|
AddErrorOrWarning(filename, line, column, message, "warning", std::clog);
|
|
|
}
|
|
|
|
|
@@ -327,6 +328,8 @@ class CommandLineInterface::ErrorPrinter
|
|
|
|
|
|
bool FoundErrors() const { return found_errors_; }
|
|
|
|
|
|
+ bool FoundWarnings() const { return found_warnings_; }
|
|
|
+
|
|
|
private:
|
|
|
void AddErrorOrWarning(const std::string& filename, int line, int column,
|
|
|
const std::string& message, const std::string& type,
|
|
@@ -365,6 +368,7 @@ class CommandLineInterface::ErrorPrinter
|
|
|
const ErrorFormat format_;
|
|
|
DiskSourceTree* tree_;
|
|
|
bool found_errors_;
|
|
|
+ bool found_warnings_;
|
|
|
};
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
@@ -1117,7 +1121,8 @@ int CommandLineInterface::Run(int argc, const char* const argv[]) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (error_collector->FoundErrors()) {
|
|
|
+ if (error_collector->FoundErrors() ||
|
|
|
+ (fatal_warnings_ && error_collector->FoundWarnings())) {
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
@@ -1630,7 +1635,8 @@ bool CommandLineInterface::ParseArgument(const char* arg, std::string* name,
|
|
|
*name == "--version" || *name == "--decode_raw" ||
|
|
|
*name == "--print_free_field_numbers" ||
|
|
|
*name == "--experimental_allow_proto3_optional" ||
|
|
|
- *name == "--deterministic_output") {
|
|
|
+ *name == "--deterministic_output" ||
|
|
|
+ *name == "--fatal_warnings") {
|
|
|
// HACK: These are the only flags that don't take a value.
|
|
|
// They probably should not be hard-coded like this but for now it's
|
|
|
// not worth doing better.
|
|
@@ -1883,6 +1889,12 @@ CommandLineInterface::InterpretArgument(const std::string& name,
|
|
|
return PARSE_ARGUMENT_FAIL;
|
|
|
}
|
|
|
|
|
|
+ } else if (name == "--fatal_warnings") {
|
|
|
+ if (fatal_warnings_) {
|
|
|
+ std::cerr << name << " may only be passed once." << std::endl;
|
|
|
+ return PARSE_ARGUMENT_FAIL;
|
|
|
+ }
|
|
|
+ fatal_warnings_ = true;
|
|
|
} else if (name == "--plugin") {
|
|
|
if (plugin_prefix_.empty()) {
|
|
|
std::cerr << "This compiler does not support plugins." << std::endl;
|