mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Fix -Wmisleading-indentation warning when using gcc >= 6. (#779)
This happens whenever in a macro you use some "if" block, and don't use curly braces {}, as the macro is expanded on a single line, not on several lines. So just add the missing curly braces to please gcc. In file included from /remote/users/mlamesch/CloneFromPlatinum/yamlcpp/osp/Yamlcpp/18-0-0-5/include/yaml-cpp/yaml.h:18, from src/TestYaml.cpp:2: /remote/users/mlamesch/CloneFromPlatinum/yamlcpp/osp/Yamlcpp/18-0-0-5/include/yaml-cpp/node/convert.h: In static member function static bool YAML::convert<int>::decode(const YAML::Node&, int&): /remote/users/mlamesch/CloneFromPlatinum/yamlcpp/osp/Yamlcpp/18-0-0-5/include/yaml-cpp/node/convert.h:139:1: error: this if clause does not guard... [-Werror=misleading-indentation] YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(int); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This commit is contained in:

committed by
Jesse Beder

parent
f531f8a8c3
commit
14c87258cd
@@ -88,43 +88,45 @@ struct convert<_Null> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
|
#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
|
||||||
template <> \
|
template <> \
|
||||||
struct convert<type> { \
|
struct convert<type> { \
|
||||||
static Node encode(const type& rhs) { \
|
static Node encode(const type& rhs) { \
|
||||||
std::stringstream stream; \
|
std::stringstream stream; \
|
||||||
stream.precision(std::numeric_limits<type>::max_digits10); \
|
stream.precision(std::numeric_limits<type>::max_digits10); \
|
||||||
stream << rhs; \
|
stream << rhs; \
|
||||||
return Node(stream.str()); \
|
return Node(stream.str()); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static bool decode(const Node& node, type& rhs) { \
|
static bool decode(const Node& node, type& rhs) { \
|
||||||
if (node.Type() != NodeType::Scalar) \
|
if (node.Type() != NodeType::Scalar) { \
|
||||||
return false; \
|
return false; \
|
||||||
const std::string& input = node.Scalar(); \
|
} \
|
||||||
std::stringstream stream(input); \
|
const std::string& input = node.Scalar(); \
|
||||||
stream.unsetf(std::ios::dec); \
|
std::stringstream stream(input); \
|
||||||
if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) \
|
stream.unsetf(std::ios::dec); \
|
||||||
return true; \
|
if ((stream >> std::noskipws >> rhs) && (stream >> std::ws).eof()) { \
|
||||||
if (std::numeric_limits<type>::has_infinity) { \
|
return true; \
|
||||||
if (conversion::IsInfinity(input)) { \
|
} \
|
||||||
rhs = std::numeric_limits<type>::infinity(); \
|
if (std::numeric_limits<type>::has_infinity) { \
|
||||||
return true; \
|
if (conversion::IsInfinity(input)) { \
|
||||||
} else if (conversion::IsNegativeInfinity(input)) { \
|
rhs = std::numeric_limits<type>::infinity(); \
|
||||||
rhs = negative_op std::numeric_limits<type>::infinity(); \
|
return true; \
|
||||||
return true; \
|
} else if (conversion::IsNegativeInfinity(input)) { \
|
||||||
} \
|
rhs = negative_op std::numeric_limits<type>::infinity(); \
|
||||||
} \
|
return true; \
|
||||||
\
|
} \
|
||||||
if (std::numeric_limits<type>::has_quiet_NaN) { \
|
} \
|
||||||
if (conversion::IsNaN(input)) { \
|
\
|
||||||
rhs = std::numeric_limits<type>::quiet_NaN(); \
|
if (std::numeric_limits<type>::has_quiet_NaN) { \
|
||||||
return true; \
|
if (conversion::IsNaN(input)) { \
|
||||||
} \
|
rhs = std::numeric_limits<type>::quiet_NaN(); \
|
||||||
} \
|
return true; \
|
||||||
\
|
} \
|
||||||
return false; \
|
} \
|
||||||
} \
|
\
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \
|
#define YAML_DEFINE_CONVERT_STREAMABLE_SIGNED(type) \
|
||||||
|
Reference in New Issue
Block a user