On 06/15/2017 05:54 AM, Philipp Stephani wrote: > I've considered a couple of options. I think the simplest and most > portable one would be to compile as C++, which has destructors built > into the language. That would require some autoconf and makefile hacking, but it would work. That is, if modules are enabled, and __attribute__ ((cleanup)) is not available but a C++ compiler is available, then the build process could use the C++ compiler. Admittedly this is low priority. > How about using #pragma clang diagnostic push/pop/ignore to ignore the > warnings in the specific statements where they arise and we know that > they are false positives? I'd much prefer that over disabling them > globally in configure, because most of the time the warnings are useful. Although many warnings are useful, in my experience these particular warnings are not useful for Emacs. That is, the hassle they cause by false alarms costs more than the benefits of actual bugs that they fix. It's OK to disable such warnings globally. > > And I'm still puzzled as to why you're getting the Clang warnings > but I > am not. Are you using an older Clang? Are you passing it extra warning > options? > > > I'm using the Apple fork on macOS. It's mostly identical to upstream > Clang and compiles Emacs just fine, but it is a fork and not 100% > identical. I also get some of the warnings only when building with -O3 > (haven't checked other optimization levels). I just now applied the attached patch, configured with: ./configure --enable-gcc-warnings CC=clang CFLAGS='-O3' and had no problems on Fedora 25. If you have a problem with this patch, can you please send relevant output from 'clang --version' and 'make V=1'? Here's the output for me: clang version 3.9.1 (tags/RELEASE_391/final) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin make -C lib all make[1]: Entering directory '/home/eggert/src/gnu/emacs/static-checking/lib' clang -c -MMD -MF deps/strftime.d -MP -fno-common -W -Wabi -Waddress -Wall -Wattributes -Wbuiltin-macro-redefined -Wchar-subscripts -Wcomment -Wcomments -Wdangling-else -Wdate-time -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wduplicate-decl-specifier -Wempty-body -Wendif-labels -Wenum-compare -Wexpansion-to-defined -Wextra -Wformat-extra-args -Wformat-security -Wformat-y2k -Wformat-zero-length -Wignored-attributes -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wincompatible-pointer-types -Winit-self -Wint-conversion -Wint-to-pointer-cast -Winvalid-pch -Wlogical-not-parentheses -Wmain -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wmultichar -Wnarrowing -Wnested-externs -Wnonnull -Wnull-dereference -Wodr -Wold-style-definition -Woverflow -Wpacked -Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast -Wpragmas -Wreturn-type -Wsequence-point -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value -Wsizeof-array-argument -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-prototypes -Wswitch-bool -Wtautological-compare -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-result -Wunused-value -Wunused-variable -Wvarargs -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wno-missing-field-initializers -Wredundant-decls -Wno-missing-field-initializers -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-format-nonliteral -Wno-missing-braces -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Werror -O3 -I. -I../src -I. -I./../src strftime.c [no warnings] ... clang -fno-common -W -Wabi -Waddress -Wall -Wattributes -Wbuiltin-macro-redefined -Wchar-subscripts -Wcomment -Wcomments -Wdangling-else -Wdate-time -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wduplicate-decl-specifier -Wempty-body -Wendif-labels -Wenum-compare -Wexpansion-to-defined -Wextra -Wformat-extra-args -Wformat-security -Wformat-y2k -Wformat-zero-length -Wignored-attributes -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wincompatible-pointer-types -Winit-self -Wint-conversion -Wint-to-pointer-cast -Winvalid-pch -Wlogical-not-parentheses -Wmain -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wmultichar -Wnarrowing -Wnested-externs -Wnonnull -Wnull-dereference -Wodr -Wold-style-definition -Woverflow -Wpacked -Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast -Wpragmas -Wreturn-type -Wsequence-point -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value -Wsizeof-array-argument -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-prototypes -Wswitch-bool -Wtautological-compare -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-result -Wunused-value -Wunused-variable -Wvarargs -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wno-missing-field-initializers -Wredundant-decls -Wno-missing-field-initializers -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-format-nonliteral -Wno-missing-braces -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -Werror -I. -I../src -I../lib -I. -I./../src -I./../lib -O3 make-docfile.c ../lib/libgnu.a -o make-docfile [no warnings] ... make[1]: Leaving directory '/home/eggert/src/gnu/emacs/static-checking/lib-src' make -C src VCSWITNESS='$(srcdir)/../.git/logs/HEAD' all make[1]: Entering directory '/home/eggert/src/gnu/emacs/static-checking/src' ... clang -c -Demacs -I. -I. -I../lib -I../lib -pthread -isystem /usr/include/gtk-3.0 -isystem /usr/include/at-spi2-atk/2.0 -isystem /usr/include/at-spi-2.0 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -isystem /usr/include/gtk-3.0 -isystem /usr/include/gio-unix-2.0/ -isystem /usr/include/cairo -isystem /usr/include/pango-1.0 -isystem /usr/include/harfbuzz -isystem /usr/include/pango-1.0 -isystem /usr/include/atk-1.0 -isystem /usr/include/cairo -isystem /usr/include/pixman-1 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/freetype2 -isystem /usr/include/libdrm -isystem /usr/include/libpng16 -isystem /usr/include/gdk-pixbuf-2.0 -isystem /usr/include/libpng16 -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/alsa -pthread -isystem /usr/include/librsvg-2.0 -isystem /usr/include/gdk-pixbuf-2.0 -isystem /usr/include/libpng16 -isystem /usr/include/cairo -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/pixman-1 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/freetype2 -isystem /usr/include/libdrm -isystem /usr/include/libpng16 -isystem /usr/include/libpng16 -isystem /usr/include/libxml2 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -pthread -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -pthread -isystem /usr/include/gconf/2 -isystem /usr/include/dbus-1.0 -isystem /usr/lib64/dbus-1.0/include -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -isystem /usr/include/freetype2 -isystem /usr/include/libpng16 -MMD -MF deps/emacs.d -MP -isystem /usr/include/p11-kit-1 -Werror -fno-common -W -Wabi -Waddress -Wall -Wattributes -Wbuiltin-macro-redefined -Wchar-subscripts -Wcomment -Wcomments -Wdangling-else -Wdate-time -Wdeprecated -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wduplicate-decl-specifier -Wempty-body -Wendif-labels -Wenum-compare -Wexpansion-to-defined -Wextra -Wformat-extra-args -Wformat-security -Wformat-y2k -Wformat-zero-length -Wignored-attributes -Wignored-qualifiers -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wincompatible-pointer-types -Winit-self -Wint-conversion -Wint-to-pointer-cast -Winvalid-pch -Wlogical-not-parentheses -Wmain -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wmultichar -Wnarrowing -Wnested-externs -Wnonnull -Wnull-dereference -Wodr -Wold-style-definition -Woverflow -Wpacked -Wparentheses -Wpointer-arith -Wpointer-sign -Wpointer-to-int-cast -Wpragmas -Wreturn-type -Wsequence-point -Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value -Wsizeof-array-argument -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-prototypes -Wswitch-bool -Wtautological-compare -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-result -Wunused-value -Wunused-variable -Wvarargs -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wno-missing-field-initializers -Wredundant-decls -Wno-missing-field-initializers -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-format-nonliteral -Wno-missing-braces -Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare -O3 emacs.c [no warnings] ...