r374135 - [c++20] P1152R4: warn on any simple-assignment to a volatile lvalue

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 08:48:30 PDT 2019


On Thu, 17 Oct 2019, 05:17 Stephan Bergmann via cfe-commits, <
cfe-commits at lists.llvm.org> wrote:

> On 09/10/2019 04:04, Richard Smith via cfe-commits wrote:
> > Author: rsmith
> > Date: Tue Oct  8 19:04:54 2019
> > New Revision: 374135
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=374135&view=rev
> > Log:
> > [c++20] P1152R4: warn on any simple-assignment to a volatile lvalue
> > whose value is not ignored.
> >
> > We don't warn on all the cases that are deprecated: specifically, we
> > choose to not warn for now if there are parentheses around the
> > assignment but its value is not actually used. This seems like a more
> > defensible rule, particularly for cases like sizeof(v = a), where the
> > parens are part of the operand rather than the sizeof syntax.
> >
> > Modified:
> >      cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> >      cfe/trunk/include/clang/Sema/Sema.h
> >      cfe/trunk/lib/Sema/SemaExpr.cpp
> >      cfe/trunk/lib/Sema/SemaExprCXX.cpp
> >      cfe/trunk/test/SemaCXX/deprecated.cpp
> >      cfe/trunk/www/cxx_status.html
>
> Oh, I should probably have commented here on the mailing list rather
> than at
> <
> https://github.com/llvm/llvm-project/commit/4a6861a7e5b59be24a09b8b9782255d028e7aade#commitcomment-35540755
> >:
>
> I assume the scenario at
> <https://gitlab.gnome.org/GNOME/glib/merge_requests/1170> "Avoid C++20
> deprecated assignment to volatile",
>
>    (void) (0 ? *(location) = (result) : 0);
>
> where *(location) is of (non-class) volatile type, is a true positive
> that we indeed want to warn about?
>

Yes, that case is deprecated in C++20.

_______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191017/e2adb089/attachment.html>


More information about the cfe-commits mailing list