Commit 127508ee authored by Sang Ik Lee's avatar Sang Ik Lee Committed by Scott Cyphers

Workaround for #pragma GCC diagnostic error. (Another version) (#2945)

* Don't use
pragma GCC diagnostic error "-Wswitch"
pragma GCC diagnostic error "-Wswitch-enum"
for GCC 4.8.X

* Fix typo.

* Style.
parent 94f4dfec
...@@ -53,9 +53,11 @@ vector<string> op::Constant::get_value_strings() const ...@@ -53,9 +53,11 @@ vector<string> op::Constant::get_value_strings() const
{ {
vector<string> rc; vector<string> rc;
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum" #pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (get_element_type().get_type_enum()) switch (get_element_type().get_type_enum())
{ {
case element::Type_t::boolean: case element::Type_t::boolean:
...@@ -139,7 +141,9 @@ vector<string> op::Constant::get_value_strings() const ...@@ -139,7 +141,9 @@ vector<string> op::Constant::get_value_strings() const
case element::Type_t::undefined: throw runtime_error("unsupported type"); case element::Type_t::undefined: throw runtime_error("unsupported type");
case element::Type_t::dynamic: throw runtime_error("unsupported type"); case element::Type_t::dynamic: throw runtime_error("unsupported type");
} }
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
return rc; return rc;
} }
......
...@@ -259,9 +259,11 @@ namespace ngraph ...@@ -259,9 +259,11 @@ namespace ngraph
{ {
throw std::runtime_error("Constant initializer does not match shape"); throw std::runtime_error("Constant initializer does not match shape");
} }
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum" #pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (target_type.get_type_enum()) switch (target_type.get_type_enum())
{ {
case element::Type_t::boolean: case element::Type_t::boolean:
...@@ -306,7 +308,9 @@ namespace ngraph ...@@ -306,7 +308,9 @@ namespace ngraph
case element::Type_t::undefined: throw std::runtime_error("unsupported type"); case element::Type_t::undefined: throw std::runtime_error("unsupported type");
case element::Type_t::dynamic: throw std::runtime_error("unsupported type"); case element::Type_t::dynamic: throw std::runtime_error("unsupported type");
} }
#if !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
} }
static constexpr size_t host_alignment() { return 64; } static constexpr size_t host_alignment() { return 64; }
......
...@@ -194,10 +194,12 @@ private: ...@@ -194,10 +194,12 @@ private:
// We want to check that every OP_TYPEID enumeration is included in the list. // We want to check that every OP_TYPEID enumeration is included in the list.
// These GCC flags enable compile-time checking so that if an enumeration // These GCC flags enable compile-time checking so that if an enumeration
// is not in the list an error is generated. // is not in the list an error is generated.
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum" #pragma GCC diagnostic error "-Wswitch-enum"
// #pragma GCC diagnostic error "-Wcovered-switch-default" // #pragma GCC diagnostic error "-Wcovered-switch-default"
#endif
switch (node_wrapper.get_typeid()) switch (node_wrapper.get_typeid())
{ {
case OP_TYPEID::Abs: case OP_TYPEID::Abs:
...@@ -1374,7 +1376,9 @@ private: ...@@ -1374,7 +1376,9 @@ private:
break; break;
} }
default: throw unsupported_op("Unsupported op '" + node.description() + "'"); default: throw unsupported_op("Unsupported op '" + node.description() + "'");
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
} }
} }
}; };
...@@ -455,9 +455,11 @@ shared_ptr<runtime::Executable> ...@@ -455,9 +455,11 @@ shared_ptr<runtime::Executable>
// We want to check that every OP_TYPEID enumeration is included in the list. // We want to check that every OP_TYPEID enumeration is included in the list.
// These GCC flags enable compile-time checking so that if an enumeration // These GCC flags enable compile-time checking so that if an enumeration
// is not in the list an error is generated. // is not in the list an error is generated.
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum" #pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (op_type_id) switch (op_type_id)
{ {
case OP_TYPEID::Parameter: case OP_TYPEID::Parameter:
...@@ -2087,7 +2089,9 @@ shared_ptr<runtime::Executable> ...@@ -2087,7 +2089,9 @@ shared_ptr<runtime::Executable>
throw unsupported_op("Unsupported op '" + op->description() + throw unsupported_op("Unsupported op '" + op->description() +
"' in IntelGPU back end."); "' in IntelGPU back end.");
} }
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
} }
} }
......
...@@ -199,10 +199,12 @@ private: ...@@ -199,10 +199,12 @@ private:
// We want to check that every OP_TYPEID enumeration is included in the list. // We want to check that every OP_TYPEID enumeration is included in the list.
// These GCC flags enable compile-time checking so that if an enumeration // These GCC flags enable compile-time checking so that if an enumeration
// is not in the list an error is generated. // is not in the list an error is generated.
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum" #pragma GCC diagnostic error "-Wswitch-enum"
// #pragma GCC diagnostic error "-Wcovered-switch-default" // #pragma GCC diagnostic error "-Wcovered-switch-default"
#endif
switch (node_wrapper.get_typeid()) switch (node_wrapper.get_typeid())
{ {
case OP_TYPEID::Abs: case OP_TYPEID::Abs:
...@@ -1425,7 +1427,9 @@ private: ...@@ -1425,7 +1427,9 @@ private:
case OP_TYPEID::DynPad: case OP_TYPEID::DynPad:
case OP_TYPEID::Tile: case OP_TYPEID::Tile:
default: throw unsupported_op("Unsupported op '" + node.description() + "'"); default: throw unsupported_op("Unsupported op '" + node.description() + "'");
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
} }
} }
}; };
...@@ -501,10 +501,12 @@ static shared_ptr<ngraph::Function> ...@@ -501,10 +501,12 @@ static shared_ptr<ngraph::Function>
{ {
args.push_back(node_map.at(name)); args.push_back(node_map.at(name));
} }
#if !(defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum" #pragma GCC diagnostic error "-Wswitch-enum"
// #pragma GCC diagnostic error "-Wimplicit-fallthrough" // #pragma GCC diagnostic error "-Wimplicit-fallthrough"
#endif
switch (get_typeid(node_op)) switch (get_typeid(node_op))
{ {
case OP_TYPEID::Abs: case OP_TYPEID::Abs:
...@@ -1520,7 +1522,9 @@ static shared_ptr<ngraph::Function> ...@@ -1520,7 +1522,9 @@ static shared_ptr<ngraph::Function>
throw runtime_error(ss.str()); throw runtime_error(ss.str());
} }
} }
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
for (const string& name : control_deps_inputs) for (const string& name : control_deps_inputs)
{ {
...@@ -1637,10 +1641,12 @@ static json write(const Node& n, bool binary_constant_data) ...@@ -1637,10 +1641,12 @@ static json write(const Node& n, bool binary_constant_data)
} }
string node_op = n.description(); string node_op = n.description();
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch" #pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum" #pragma GCC diagnostic error "-Wswitch-enum"
// #pragma GCC diagnostic error "-Wimplicit-fallthrough" // #pragma GCC diagnostic error "-Wimplicit-fallthrough"
#endif
switch (get_typeid(node_op)) switch (get_typeid(node_op))
{ {
case OP_TYPEID::Abs: { break; case OP_TYPEID::Abs: { break;
...@@ -2246,7 +2252,9 @@ static json write(const Node& n, bool binary_constant_data) ...@@ -2246,7 +2252,9 @@ static json write(const Node& n, bool binary_constant_data)
case OP_TYPEID::UnknownOp: { break; case OP_TYPEID::UnknownOp: { break;
} }
} }
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
return node; return node;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment