[PATCH] D11670: [libcxx] Disable -Wnon-virtual-dtor warning in <locale>

David Blaikie dblaikie at gmail.com
Thu Jul 30 20:16:36 PDT 2015


On Thu, Jul 30, 2015 at 6:43 PM, Eric Fiselier <eric at efcs.ca> wrote:

> EricWF created this revision.
> EricWF added a reviewer: mclow.lists.
> EricWF added a subscriber: cfe-commits.
>
> Normally people won't see warnings in libc++ headers, but if they compile
> with "-Wsystem-headers -Wnon-virtual-dtor" they will likely see issues in
> <locale>.
>
> The struct `time_get` is specified as having a non-virtual protected
> destructor but in the libc++ implementation `time_get` also has a
> non-virtual base class with virtual methods.


If the base class has a protected non-virtual dtor and the derived class is
marked final, this warning will not fire (because that interface will
ensure no polymorphic destruction occurs). Would that be sufficient for
your needs?


> I don't believe this is a bug but instead a false positive.
>
>
> http://reviews.llvm.org/D11670
>
> Files:
>   include/__config
>   include/locale
>
> Index: include/locale
> ===================================================================
> --- include/locale
> +++ include/locale
> @@ -1875,6 +1875,11 @@
>      enum dateorder {no_order, dmy, mdy, ymd, ydm};
>  };
>
> +#if __has_warning("-Wnon-virtual-dtor")
> +#pragma clang diagnostic push
> +#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
> +#endif
> +
>  template <class _CharT>
>  class _LIBCPP_TYPE_VIS_ONLY __time_get_c_storage
>  {
> @@ -1890,6 +1895,10 @@
>      virtual const string_type& __X() const;
>  };
>
> +#if __has_warning("-Wnon-virtual-dtor")
> +#pragma clang diagnostic pop
> +#endif
> +
>  template <class _CharT, class _InputIterator =
> istreambuf_iterator<_CharT> >
>  class _LIBCPP_TYPE_VIS_ONLY time_get
>      : public locale::facet,
> Index: include/__config
> ===================================================================
> --- include/__config
> +++ include/__config
> @@ -45,6 +45,9 @@
>  #ifndef __is_identifier
>  #define __is_identifier(__x) 1
>  #endif
> +#ifndef __has_warning
> +#define __has_warning(__x) 0
> +#endif
>
>
>  #ifdef __LITTLE_ENDIAN__
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150730/25d18744/attachment.html>


More information about the cfe-commits mailing list