Small patch to handle -Wfloat-equal warnings
https://groups.google.com/d/msg/protobuf/H8_D1hfg3p4/A2oPHdfUAgAJ
This commit is contained in:
parent
27228494c3
commit
97e7ddc015
@ -177,6 +177,10 @@ bool EmitFieldNonDefaultCondition(io::Printer* printer,
|
||||
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {
|
||||
// Message fields still have has_$name$() methods.
|
||||
format("if ($prefix$has_$name$()) {\n");
|
||||
} else if (field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE
|
||||
|| field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT) {
|
||||
// Handle float comparison to prevent -Wfloat-equal warnings
|
||||
format("if (!($prefix$$name$() <= 0 && $prefix$$name$() >= 0)) {\n");
|
||||
} else {
|
||||
format("if ($prefix$$name$() != 0) {\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user