nullptr.cpp updated this revision to Diff 294485.
nullptr.cpp added a comment.
Add test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88295/new/
https://reviews.llvm.org/D88295
Files:
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/implicitly-movable.cpp
Index: clang/test/SemaCXX/implicitly-movable.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/implicitly-movable.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify %s
+// expected-no-diagnostics
+
+class A {
+public:
+ A() {}
+ ~A() {}
+ A(A &&);
+ A(const volatile A &);
+
+private:
+ A(const A &);
+ A(volatile A &&);
+};
+
+A test_volatile() {
+ volatile A a_copy;
+ return a_copy;
+}
+
+A test_normal() {
+ A a_move;
+ return a_move;
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaStmt.cpp
===================================================================
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3056,12 +3056,13 @@
// variable will no longer be used.
if (VD->hasAttr<BlocksAttr>()) return false;
+ // ...non-volatile...
+ if (VD->getType().isVolatileQualified())
+ return false;
+
if (CESK & CES_AllowDifferentTypes)
return true;
- // ...non-volatile...
- if (VD->getType().isVolatileQualified()) return false;
-
// Variables with higher required alignment than their type's ABI
// alignment cannot use NRVO.
if (!VD->getType()->isDependentType() && VD->hasAttr<AlignedAttr>() &&
Index: clang/test/SemaCXX/implicitly-movable.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/implicitly-movable.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify %s
+// expected-no-diagnostics
+
+class A {
+public:
+ A() {}
+ ~A() {}
+ A(A &&);
+ A(const volatile A &);
+
+private:
+ A(const A &);
+ A(volatile A &&);
+};
+
+A test_volatile() {
+ volatile A a_copy;
+ return a_copy;
+}
+
+A test_normal() {
+ A a_move;
+ return a_move;
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaStmt.cpp
===================================================================
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3056,12 +3056,13 @@
// variable will no longer be used.
if (VD->hasAttr<BlocksAttr>()) return false;
+ // ...non-volatile...
+ if (VD->getType().isVolatileQualified())
+ return false;
+
if (CESK & CES_AllowDifferentTypes)
return true;
- // ...non-volatile...
- if (VD->getType().isVolatileQualified()) return false;
-
// Variables with higher required alignment than their type's ABI
// alignment cannot use NRVO.
if (!VD->getType()->isDependentType() && VD->hasAttr<AlignedAttr>() &&
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits