Skip to content

Commit

Permalink
Silence -Wswitch-enum from bison generated file (#4886)
Browse files Browse the repository at this point in the history
p4parsers.ypp generates a .hpp file that contains an empty switch
statement with just a default case when generating the user destructor.
This switch prevents builds with -Werror=switch-enum. Silence this
warning if the flag is present.

Signed-off-by: Chris Dodd <cdodd@nvidia.com>
Co-authored-by: Emre Orbay <eorbay@nvidia.com>
  • Loading branch information
ChrisDodd and Emre Orbay committed Sep 3, 2024
1 parent acef8db commit f7c29aa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frontends/parsers/p4/p4parser.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ limitations under the License.

// Ignore a warning caused by autogenerated code.
// The #if pragma is a little awkward because some preprocessors do not like ||
#pragma GCC diagnostic push
#if defined(__has_warning)
#if __has_warning("-Wunused-but-set-variable")
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#if __has_warning("-Wswitch-enum")
#pragma GCC diagnostic ignored "-Wswitch-enum"
#endif
#else
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#pragma GCC diagnostic ignored "-Wswitch-enum"
#endif

namespace P4 {
Expand Down Expand Up @@ -1713,3 +1718,5 @@ void P4Parser::error(const Util::SourceInfo& location,
}

} // namespace P4

#pragma GCC diagnostic pop

0 comments on commit f7c29aa

Please sign in to comment.