[Sema] Fix volatile check when testing if a return object can be implicitly moved
authorYang Fan <nullptr.cpp@gmail.com>
Tue, 10 Nov 2020 20:09:06 +0000 (15:09 -0500)
committerArthur O'Dwyer <arthur.j.odwyer@gmail.com>
Tue, 10 Nov 2020 20:11:07 +0000 (15:11 -0500)
commit703038b35a864d06e1926237c1568a430417b0b4
treec25377f1126e847d4dc7e3105d01aa049f9be91a
parent6cb1c0cae0dfcdeabb7d764b1cb3be637a227717
[Sema] Fix volatile check when testing if a return object can be implicitly moved

In C++11 standard, to become implicitly movable, the expression in return
statement should be a non-volatile automatic object. CWG1579 changed the rule
to require that the expression only needs to be an automatic object. C++14
standard and C++17 standard kept this rule unchanged. C++20 standard changed
the rule back to require the expression be a non-volatile automatic object.
This should be a typo in standards, and VD should be non-volatile.

Differential Revision: https://reviews.llvm.org/D88295
clang/lib/Sema/SemaStmt.cpp
clang/test/CXX/class/class.init/class.copy.elision/p1.cpp [new file with mode: 0644]