comparison libinterp/parse-tree/lex.ll @ 21023:ec532a439c6f

rework method of disabling warnings from GCC * configure.ac: Check for GCC's #pragma GCC diagnostic feature. * libinterp/module.mk, libinterp/corefcn/module.mk, libinterp/parse-tree/module.mk: Eliminate separate libraries for TeX and Octave parsers. * oct-tex-lexer.in.ll, oct-tex-parser.in.yy, lex.ll, oct-parse.in.yy: Use GCC #pragma GCC diagnostic feature to more selectively disable warnings in generated code. * libgui/module.mk (rcc-command): Use GCC #pragma GCC diagnostic feature to more selectively disable warnings in generated code.
author John W. Eaton <jwe@octave.org>
date Thu, 31 Dec 2015 17:06:36 -0500
parents 9db35d2042be
children 5e00ed38a58b
comparison
equal deleted inserted replaced
21022:ebc439187d29 21023:ec532a439c6f
29 interactive parser is waiting for input, for example) if you take 29 interactive parser is waiting for input, for example) if you take
30 care to properly save and restore (typically with an unwind_protect 30 care to properly save and restore (typically with an unwind_protect
31 object) relevant global values before and after the nested call. 31 object) relevant global values before and after the nested call.
32 */ 32 */
33 33
34 %top {
35 #ifdef HAVE_CONFIG_H
36 #include <config.h>
37 #endif
38
39 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
40 // This one needs to be global.
41 #pragma GCC diagnostic ignored "-Wunused-function"
42
43 // Disable this warning for code that is generated by flex, including
44 // pattern rules. Push the current state so we can restore the warning
45 // state prior to functions we define at the bottom of the file.
46 #pragma GCC diagnostic push
47 #pragma GCC diagnostic ignored "-Wold-style-cast"
48 #endif
49
50 }
51
34 %option prefix = "octave_" 52 %option prefix = "octave_"
35 %option noyywrap 53 %option noyywrap
36 %option reentrant 54 %option reentrant
37 %option bison-bridge 55 %option bison-bridge
38 56
39 %option noyyalloc 57 %option noyyalloc
40 %option noyyrealloc 58 %option noyyrealloc
41 %option noyyfree 59 %option noyyfree
42
43 %top {
44 #ifdef HAVE_CONFIG_H
45 #include <config.h>
46 #endif
47
48 }
49 60
50 %x COMMAND_START 61 %x COMMAND_START
51 %s MATRIX_START 62 %s MATRIX_START
52 63
53 %x INPUT_FILE_START 64 %x INPUT_FILE_START
1721 1732
1722 return LEXICAL_ERROR; 1733 return LEXICAL_ERROR;
1723 } 1734 }
1724 } 1735 }
1725 1736
1737 %{
1738 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
1739 // Disable this warning for code that is generated by flex.
1740 #pragma GCC diagnostic push
1741 #pragma GCC diagnostic ignored "-Wold-style-cast"
1742 #endif
1743 %}
1744
1745 %{
1746 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
1747 // Also disable this warning for functions that is generated by flex
1748 // after the pattern rules.
1749 #pragma GCC diagnostic ignored "-Wunused-parameter"
1750 #endif
1751 %}
1752
1726 %% 1753 %%
1754
1755 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
1756 // Restore prevailing warning state for remainder of the file.
1757 #pragma GCC diagnostic pop
1758 #endif
1727 1759
1728 void * 1760 void *
1729 octave_alloc (yy_size_t size, yyscan_t) 1761 octave_alloc (yy_size_t size, yyscan_t)
1730 { 1762 {
1731 return malloc (size); 1763 return malloc (size);
2709 } 2741 }
2710 else if (looks_like_bin (tmptxt, strlen (tmptxt))) 2742 else if (looks_like_bin (tmptxt, strlen (tmptxt)))
2711 { 2743 {
2712 uint64_t ivalue = 0; 2744 uint64_t ivalue = 0;
2713 2745
2714 for (int i = 0; i < strlen (tmptxt); i++) 2746 for (size_t i = 0; i < strlen (tmptxt); i++)
2715 { 2747 {
2716 ivalue <<= 1; 2748 ivalue <<= 1;
2717 ivalue += static_cast<uint64_t> (tmptxt[i] == '1'); 2749 ivalue += static_cast<uint64_t> (tmptxt[i] == '1');
2718 } 2750 }
2719 2751