@@ -206,7 +206,7 @@ def _compilePattern(self, pattern, nr, varid,
206206 arg2 = ', const int varid'
207207
208208 ret = '// pattern: ' + pattern + '\n '
209- ret += 'static inline bool match' + \
209+ ret += 'MAYBE_UNUSED static inline bool match' + \
210210 str (nr ) + '(' + tokenType + '* tok' + arg2 + ') {\n '
211211 returnStatement = 'return false;\n '
212212
@@ -290,7 +290,7 @@ def _compileFindPattern(self, pattern, findmatchnr, endToken, varId):
290290 more_args += ', int varid'
291291
292292 ret = '// pattern: ' + pattern + '\n '
293- ret += 'template<class T> static inline T * findmatch' + \
293+ ret += 'template<class T> MAYBE_UNUSED static inline T * findmatch' + \
294294 str (findmatchnr ) + '(T * start_tok' + more_args + ') {\n '
295295 ret += ' for (; start_tok' + endCondition + \
296296 '; start_tok = start_tok->next()) {\n '
@@ -373,7 +373,7 @@ def _compileVerifyTokenMatch(
373373 if varId :
374374 more_args = ', const int varid'
375375
376- ret = 'static inline bool match_verify' + \
376+ ret = 'MAYBE_UNUSED static inline bool match_verify' + \
377377 str (verifyNumber ) + '(const Token *tok' + more_args + ') {\n '
378378
379379 origMatchName = 'Match'
@@ -509,7 +509,7 @@ def _compileVerifyTokenFindMatch(
509509 if varId :
510510 more_args += ', const int varid'
511511
512- ret = 'template < class T > static inline T * findmatch_verify' + \
512+ ret = 'template < class T > MAYBE_UNUSED static inline T * findmatch_verify' + \
513513 str (verifyNumber ) + '(T * tok' + more_args + ') {\n '
514514
515515 origFindMatchName = 'findmatch'
@@ -721,13 +721,29 @@ def convertFile(self, srcname, destname, line_directive):
721721 if len (self ._rawMatchFunctions ):
722722 header += '#include "errorlogger.h"\n '
723723 header += '#include "token.h"\n '
724+ header += '#if defined(__clang__)\n '
725+ header += '#include "config.h"\n '
726+ header += '#define MAYBE_UNUSED [[maybe_unused]]\n ' # this attribute is also available in earlier standards
727+ header += 'SUPPRESS_WARNING_CLANG_PUSH("-Wc++17-attribute-extensions")\n ' # suppress waning about using above attribute in earlier standard
728+ header += '#else\n '
729+ header += '#define MAYBE_UNUSED\n '
730+ header += '#endif\n '
731+
732+ footer = ''
733+ if len (self ._rawMatchFunctions ):
734+ footer += '#if defined(__clang__)\n '
735+ footer += 'SUPPRESS_WARNING_CLANG_POP\n '
736+ footer += '#endif\n '
737+ footer += '#undef MAYBE_UNUSED\n '
724738
725739 with io .open (destname , 'wt' , encoding = "utf-8" ) as fout :
726740 if modified or len (self ._rawMatchFunctions ):
727741 fout .write (header )
728742 fout .write (strFunctions )
729743 fout .write (lineno )
730744 fout .write (code )
745+ if modified or len (self ._rawMatchFunctions ):
746+ fout .write (footer )
731747
732748
733749def main ():
0 commit comments