diff options
author | David Tardon <dtardon@redhat.com> | 2017-07-29 18:57:49 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2017-07-29 19:06:58 +0200 |
commit | 5f9460aa7dddc27cf653f56b8e3498cc9bec1454 (patch) | |
tree | b4b8895f6b41bb6d98c42198385e38d681b8d2c5 | |
parent | ba6cac72b320e566ced20e4bf21bb47f80abd877 (diff) |
suppress GCC7 fallthrough warnings
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | m4/dlp_fallthrough.m4 | 65 | ||||
-rw-r--r-- | src/lib/SW602Cell.cpp | 7 | ||||
-rw-r--r-- | src/lib/SW602Chart.cpp | 1 | ||||
-rw-r--r-- | src/lib/SW602GraphicListener.cpp | 4 | ||||
-rw-r--r-- | src/lib/SW602GraphicShape.cpp | 2 | ||||
-rw-r--r-- | src/lib/SW602PageSpan.cpp | 1 | ||||
-rw-r--r-- | src/lib/SW602SpreadsheetListener.cpp | 8 | ||||
-rw-r--r-- | src/lib/SW602TextListener.cpp | 10 | ||||
-rw-r--r-- | src/lib/libsw602_utils.h | 8 |
10 files changed, 94 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac index dfa4153..07d3568 100644 --- a/configure.ac +++ b/configure.ac @@ -34,6 +34,8 @@ AC_PROG_MAKE_SET LT_INIT([win32-dll disable-static pic-only]) AC_CANONICAL_HOST +DLP_FALLTHROUGH + PKG_PROG_PKG_CONFIG([0.20]) AM_MISSING_PROG([GPERF], [gperf]) diff --git a/m4/dlp_fallthrough.m4 b/m4/dlp_fallthrough.m4 new file mode 100644 index 0000000..99e6be5 --- /dev/null +++ b/m4/dlp_fallthrough.m4 @@ -0,0 +1,65 @@ +# +# SYNOPSIS +# +# DLP_FALLTHROUGH +# +# DESCRIPTION +# +# This macro checks if the compiler supports a fallthrough warning +# suppression attribute in GCC or CLANG style. +# +# If a fallthrough warning suppression attribute is supported define +# HAVE_<STYLE>_ATTRIBUTE_FALLTHROUGH. +# +# The macro caches its result in ax_cv_have_<style>_attribute_fallthrough +# variables. +# +# LICENSE +# +# Copyright (c) 2017 David Tardon <dtardon@redhat.com> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +m4_defun([_DLP_FALLTHROUGH], [ + AS_VAR_PUSHDEF([ac_var], [ax_cv_have_$2_attribute_falltrough]) + + AC_CACHE_CHECK([for $1], [ac_var], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + void foo(int &i) + { + switch (i) + { + case 0: + i += 1; + $1; + default: + i += 1; + } + } + ], []) + ], + dnl GCC doesn't exit with an error if an unknown attribute is + dnl provided but only outputs a warning, so accept the attribute + dnl only if no warning were issued. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([ac_var], [no])], + [AS_VAR_SET([ac_var], [yes])])], + [AS_VAR_SET([ac_var], [no])]) + ]) + + AS_IF([test yes = AS_VAR_GET([ac_var])], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$3_ATTRIBUTE_FALLTHROUGH), 1, + [Define to 1 if the system has the $4-style `fallthrough' attribute])], []) + + AS_VAR_POPDEF([ac_var]) +]) + +AC_DEFUN([DLP_FALLTHROUGH], [ + _DLP_FALLTHROUGH([[__attribute__((fallthrough))]], [gcc], [GCC], [GNU]) + _DLP_FALLTHROUGH([[[[clang:fallthrough]]]], [clang], [CLANG], [clang]) +]) diff --git a/src/lib/SW602Cell.cpp b/src/lib/SW602Cell.cpp index 10ef0b2..3a0e5c8 100644 --- a/src/lib/SW602Cell.cpp +++ b/src/lib/SW602Cell.cpp @@ -171,12 +171,14 @@ bool SW602Cell::Format::convertDTFormat(std::string const &dtFormat, librevenge: { case 'Y': list.insert("number:style", "long"); + SW602_FALLTHROUGH; case 'y': list.insert("librevenge:value-type", "year"); propVect.append(list); break; case 'B': list.insert("number:style", "long"); + SW602_FALLTHROUGH; case 'b': case 'h': list.insert("librevenge:value-type", "month"); @@ -189,13 +191,14 @@ bool SW602Cell::Format::convertDTFormat(std::string const &dtFormat, librevenge: break; case 'e': list.insert("number:style", "long"); - // fall-through intended + SW602_FALLTHROUGH; case 'd': list.insert("librevenge:value-type", "day"); propVect.append(list); break; case 'A': list.insert("number:style", "long"); + SW602_FALLTHROUGH; case 'a': list.insert("librevenge:value-type", "day-of-week"); propVect.append(list); @@ -203,7 +206,7 @@ bool SW602Cell::Format::convertDTFormat(std::string const &dtFormat, librevenge: case 'H': list.insert("number:style", "long"); - // fall-through intended + SW602_FALLTHROUGH; case 'I': list.insert("librevenge:value-type", "hours"); propVect.append(list); diff --git a/src/lib/SW602Chart.cpp b/src/lib/SW602Chart.cpp index 8e7cf98..164f138 100644 --- a/src/lib/SW602Chart.cpp +++ b/src/lib/SW602Chart.cpp @@ -620,6 +620,7 @@ std::ostream &operator<<(std::ostream &o, SW602Chart::TextZone const &zone) { case SW602Chart::TextZone::T_SubTitle: o << "sub"; + SW602_FALLTHROUGH; case SW602Chart::TextZone::T_Title: o << "title"; if (zone.m_contentType==SW602Chart::TextZone::C_Cell) diff --git a/src/lib/SW602GraphicListener.cpp b/src/lib/SW602GraphicListener.cpp index 8a4930f..92dd406 100644 --- a/src/lib/SW602GraphicListener.cpp +++ b/src/lib/SW602GraphicListener.cpp @@ -1506,7 +1506,7 @@ void SW602GraphicListener::_handleFrameParameters(librevenge::RVNGPropertyList & { case SW602Position::YFull: list.insert("svg:height", double(h), unit); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::YTop: if (origin[1] < 0.0 || origin[1] > 0.0) { @@ -1550,7 +1550,7 @@ void SW602GraphicListener::_handleFrameParameters(librevenge::RVNGPropertyList & { case SW602Position::XFull: list.insert("svg:width", double(w), unit); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::XLeft: if (origin[0] < 0.0 || origin[0] > 0.0) { diff --git a/src/lib/SW602GraphicShape.cpp b/src/lib/SW602GraphicShape.cpp index 0dee0b1..6adbf69 100644 --- a/src/lib/SW602GraphicShape.cpp +++ b/src/lib/SW602GraphicShape.cpp @@ -544,7 +544,7 @@ std::vector<SW602GraphicShape::PathData> SW602GraphicShape::getPath() const { case Measure: SW602_DEBUG_MSG(("SW602GraphicShape::getPath: called on a measure, transform it in line\n")); - // fall through expected + SW602_FALLTHROUGH; case Line: case Polygon: { diff --git a/src/lib/SW602PageSpan.cpp b/src/lib/SW602PageSpan.cpp index fae0fe9..c94b558 100644 --- a/src/lib/SW602PageSpan.cpp +++ b/src/lib/SW602PageSpan.cpp @@ -207,6 +207,7 @@ void SW602PageSpan::setHeaderFooter(SW602HeaderFooter const &hF) { case SW602HeaderFooter::NEVER: removeHeaderFooter(type, SW602HeaderFooter::ALL); + SW602_FALLTHROUGH; case SW602HeaderFooter::ALL: removeHeaderFooter(type, SW602HeaderFooter::ODD); removeHeaderFooter(type, SW602HeaderFooter::EVEN); diff --git a/src/lib/SW602SpreadsheetListener.cpp b/src/lib/SW602SpreadsheetListener.cpp index dcdfac3..3932926 100644 --- a/src/lib/SW602SpreadsheetListener.cpp +++ b/src/lib/SW602SpreadsheetListener.cpp @@ -1040,7 +1040,7 @@ void SW602SpreadsheetListener::insertShape case SW602Position::Unknown: default: SW602_DEBUG_MSG(("SW602SpreadsheetListener::insertShape: UNKNOWN position, insert as char position\n")); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::CharBaseLine: case SW602Position::Char: if (m_ps->m_isSpanOpened) @@ -1158,7 +1158,7 @@ bool SW602SpreadsheetListener::openFrame(SW602Position const &pos, SW602GraphicS break; case SW602Position::Unknown: SW602_DEBUG_MSG(("SW602SpreadsheetListener::openFrame: UNKNOWN position, insert as char position\n")); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::CharBaseLine: case SW602Position::Char: if (m_ps->m_isSpanOpened) @@ -1347,7 +1347,7 @@ void SW602SpreadsheetListener::_handleFrameParameters { case SW602Position::YFull: propList.insert("svg:height", double(h), unit); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::YTop: if (origin[1] < 0.0 || origin[1] > 0.0) { @@ -1391,7 +1391,7 @@ void SW602SpreadsheetListener::_handleFrameParameters { case SW602Position::XFull: propList.insert("svg:width", double(w), unit); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::XLeft: if (origin[0] < 0.0 || origin[0] > 0.0) { diff --git a/src/lib/SW602TextListener.cpp b/src/lib/SW602TextListener.cpp index 4af4582..4d62d25 100644 --- a/src/lib/SW602TextListener.cpp +++ b/src/lib/SW602TextListener.cpp @@ -1125,7 +1125,7 @@ void SW602TextListener::insertShape case SW602Position::Unknown: default: SW602_DEBUG_MSG(("SW602TextListener::insertShape: UNKNOWN position, insert as char position\n")); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::CharBaseLine: case SW602Position::Char: if (m_ps->m_isSpanOpened) @@ -1246,7 +1246,7 @@ bool SW602TextListener::openFrame(SW602Position const &pos, SW602GraphicStyle co break; case SW602Position::Unknown: SW602_DEBUG_MSG(("SW602TextListener::openFrame: UNKNOWN position, insert as char position\n")); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::CharBaseLine: case SW602Position::Char: if (m_ps->m_isSpanOpened) @@ -1334,7 +1334,7 @@ bool SW602TextListener::openGroup(SW602Position const &pos) case SW602Position::Unknown: default: SW602_DEBUG_MSG(("SW602TextListener::openGroup: UNKNOWN position, insert as char position\n")); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::CharBaseLine: case SW602Position::Char: if (m_ps->m_isSpanOpened) @@ -1497,7 +1497,7 @@ void SW602TextListener::_handleFrameParameters { case SW602Position::YFull: propList.insert("svg:height", double(h), unit); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::YTop: if (origin[1] < 0.0 || origin[1] > 0.0) { @@ -1541,7 +1541,7 @@ void SW602TextListener::_handleFrameParameters { case SW602Position::XFull: propList.insert("svg:width", double(w), unit); - // fallthrough intended + SW602_FALLTHROUGH; case SW602Position::XLeft: if (origin[0] < 0.0 || origin[0] > 0.0) { diff --git a/src/lib/libsw602_utils.h b/src/lib/libsw602_utils.h index 380f08b..0d726d7 100644 --- a/src/lib/libsw602_utils.h +++ b/src/lib/libsw602_utils.h @@ -19,6 +19,14 @@ #include <librevenge-stream/librevenge-stream.h> #include <librevenge/librevenge.h> +#if defined(HAVE_CLANG_ATTRIBUTE_FALLTHROUGH) +# define SW602_FALLTHROUGH [[clang::fallthrough]] +#elif defined(HAVE_GCC_ATTRIBUTE_FALLTHROUGH) +# define SW602_FALLTHROUGH __attribute__((fallthrough)) +#else +# define SW602_FALLTHROUGH ((void) 0) +#endif + namespace libsw602 { } |