[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Julius via Phabricator via cfe-commits
ningvin added a comment.

In D133354#3790064 , @hans wrote:

> Ah, thanks for letting me know. I've committed on your behalf as 
> https://github.com/llvm/llvm-project/commit/49e7ef2c09facd722a29a5ad96a7f8f16e362b28

Sweet, thanks a lot :-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D133354#3789212 , @ningvin wrote:

> @hans just to clarify as I do not have commit access: do I still need to 
> perform some action?

Ah, thanks for letting me know. I've committed on your behalf as 
https://github.com/llvm/llvm-project/commit/49e7ef2c09facd722a29a5ad96a7f8f16e362b28


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49e7ef2c09fa: [Clang]: Diagnose deprecated copy operations 
also in MSVC compatibility mode (authored by ningvin, committed by hans).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
  clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
  clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
  clang/test/SemaCXX/deprecated-copy.cpp
  clang/test/SemaCXX/deprecated.cpp


Index: clang/test/SemaCXX/deprecated.cpp
===
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -1,10 +1,16 @@
 // RUN: %clang_cc1 -std=c++98 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++98 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++11 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++17 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++17 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++2a %s -Wno-parentheses -Wdeprecated 
-verify=expected,cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++2a %s -Wno-parentheses -Wdeprecated 
-verify=expected,cxx20 -triple x86_64-linux-gnu -fms-compatibility
 
 // RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -Wno-deprecated-register 
-DNO_DEPRECATED_FLAGS
+// RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -Wno-deprecated-register 
-DNO_DEPRECATED_FLAGS -fms-compatibility
 
 #include "Inputs/register.h"
 
Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- clang/test/SemaCXX/deprecated-copy.cpp
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify -fms-compatibility
 
 struct A {
 A& operator=(const A&) = default; // expected-warning {{definition of 
implicit copy constructor for 'A' is deprecated because it has a user-declared 
copy assignment operator}}
Index: clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify -fms-compatibility
 
 struct A {
   ~A(); // expected-warning {{definition of implicit copy constructor for 'A' 
is deprecated because it has a user-provided destructor}}
Index: clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify -fms-compatibility
 
 struct A {
   A =(const A &); // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-provided copy 
assignment operator}}
Index: clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
@@ -1,6 +1,9 @@
 // RUN: 

[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Julius via Phabricator via cfe-commits
ningvin added a comment.

@hans just to clarify as I do not have commit access: do I still need to 
perform some action?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-12 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm

Maybe give Richard another day or two in case he wants to take a look, but 
otherwise landing this and seeing if there are any problems we didn't know 
about sounds good to me.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-10 Thread Julius via Phabricator via cfe-commits
ningvin updated this revision to Diff 459277.
ningvin added a comment.

I added the respective RUN lines to the different test cases, did not seem to 
break anything on my end.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
  clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
  clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
  clang/test/SemaCXX/deprecated-copy.cpp
  clang/test/SemaCXX/deprecated.cpp


Index: clang/test/SemaCXX/deprecated.cpp
===
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -1,10 +1,16 @@
 // RUN: %clang_cc1 -std=c++98 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++98 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++11 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++17 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++17 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++2a %s -Wno-parentheses -Wdeprecated 
-verify=expected,cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++2a %s -Wno-parentheses -Wdeprecated 
-verify=expected,cxx20 -triple x86_64-linux-gnu -fms-compatibility
 
 // RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -Wno-deprecated-register 
-DNO_DEPRECATED_FLAGS
+// RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -Wno-deprecated-register 
-DNO_DEPRECATED_FLAGS -fms-compatibility
 
 #include "Inputs/register.h"
 
Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- clang/test/SemaCXX/deprecated-copy.cpp
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify -fms-compatibility
 
 struct A {
 A& operator=(const A&) = default; // expected-warning {{definition of 
implicit copy constructor for 'A' is deprecated because it has a user-declared 
copy assignment operator}}
Index: clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify -fms-compatibility
 
 struct A {
   ~A(); // expected-warning {{definition of implicit copy constructor for 'A' 
is deprecated because it has a user-provided destructor}}
Index: clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify -fms-compatibility
 
 struct A {
   A =(const A &); // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-provided copy 
assignment operator}}
Index: clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated 

[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-09 Thread Julius via Phabricator via cfe-commits
ningvin added a comment.

That is indeed a better option than to simply copy the test case. I did some 
more digging and found the following test cases which reference the deprecated 
copy warning (all located under clang/test/CXX/):

- deprecated.cpp 

- deprecated-copy.cpp 

- deprecated-copy-with-dtor.cpp 

- deprecated-copy-with-user-provided-copy.cpp 

- deprecated-copy-with-user-provided-dtor.cpp 


I suppose adding the respective RUN lines with `-fms-compatibility` to all of 
them is the way to go. I will try that tomorrow to see if something breaks and 
then update this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/test/SemaCXX/deprecated-copy-msvc.cpp:1
+// RUN: %clang_cc1 %s -std=c++11 %s -Wdeprecated-copy -verify 
-fms-compatibility
+

Can we just add a RUN line with -fms-compatibility to 
clang/test/SemaCXX/deprecated-copy.cpp ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D133354#3779882 , @ningvin wrote:

> In D133354#3779123 , @dblaikie 
> wrote:
>
>> That works, you can also take the hash with the `rG` prefix and use that: 
>> rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad 
>>  and 
>> that works too.
>
> Didn't know that, thanks!
>
> In D133354#3779765 , @hans wrote:
>
>> For more context, this was initially raised in 
>> https://discourse.llvm.org/t/why-is-the-deprecated-copy-warning-suppressed-in-msvc-compatibility-mode/65085/1
>
> Oh yes sorry, I should have linked to that.

ah, *thumbs up* then, though I'll probably leave it to @hansw to review so he's 
aware of when this goes in/will have context in case any fallout is observed on 
the Windows side of things


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-09 Thread Julius via Phabricator via cfe-commits
ningvin added a comment.

In D133354#3779123 , @dblaikie wrote:

> That works, you can also take the hash with the `rG` prefix and use that: 
> rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad 
>  and 
> that works too.

Didn't know that, thanks!

In D133354#3779765 , @hans wrote:

> For more context, this was initially raised in 
> https://discourse.llvm.org/t/why-is-the-deprecated-copy-warning-suppressed-in-msvc-compatibility-mode/65085/1

Oh yes sorry, I should have linked to that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-09 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

For more context, this was initially raised in 
https://discourse.llvm.org/t/why-is-the-deprecated-copy-warning-suppressed-in-msvc-compatibility-mode/65085/1

I'm not aware of any reason for the special microsoft mode case, but it's very 
possible that I'm missing something.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D133354#3778281 , @ningvin wrote:

> In D133354#3778237 , @dblaikie 
> wrote:
>
>> Got any pointers to the commits/authors that added this functionality in the 
>> first place? (would be good to have any review history, etc, to check 
>> against the change here)
>
> That would be @rsmith if I am not mistaken

Ah, indeed - thanks for the context. (I almost thought it wasn't in that patch, 
because there was no mention of "MSVC" there - but I see now it was 
"MicrosoftMode" back then)

> with https://reviews.llvm.org/rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad (not 
> sure how to best link to commits/changes in phabricator).

That works, you can also take the hash with the `rG` prefix and use that: 
rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad 
 and that 
works too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-08 Thread Julius via Phabricator via cfe-commits
ningvin added a comment.

In D133354#3778237 , @dblaikie wrote:

> Got any pointers to the commits/authors that added this functionality in the 
> first place? (would be good to have any review history, etc, to check against 
> the change here)

That would be @rsmith if I am not mistaken with 
https://reviews.llvm.org/rGd577fbbd1c9d6dab193d530fcd807efc3b3bc9ad (not sure 
how to best link to commits/changes in phabricator).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added subscribers: hansw, dblaikie.
dblaikie added a comment.

Got any pointers to the commits/authors that added this functionality in the 
first place? (would be good to have any review history, etc, to check against 
the change here)

@hansw for windows compatibility discussions


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133354/new/

https://reviews.llvm.org/D133354

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-06 Thread Julius via Phabricator via cfe-commits
ningvin created this revision.
ningvin added a reviewer: rsmith.
ningvin added a project: clang.
Herald added a project: All.
ningvin requested review of this revision.
Herald added a subscriber: cfe-commits.

When running in MSVC compatibility mode, previously no deprecated copy 
operation warnings (enabled by `-Wdeprecated-copy`) were raised. This 
restriction was already in place when the deprecated copy warning was first 
introduced 
.

This patch removes said restriction so that deprecated copy warnings, if 
enabled, are also raised in MSVC compatibility mode. The reasoning here being 
that these warnings are still useful when running in MSVC compatibility mode 
and also have to be semi-explicitly enabled in the first place (using 
`-Wdeprecated-copy`, `-Wdeprecated` or `-Wextra`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133354

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy-msvc.cpp


Index: clang/test/SemaCXX/deprecated-copy-msvc.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy-msvc.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -std=c++11 %s -Wdeprecated-copy -verify 
-fms-compatibility
+
+struct A {
+  A& operator=(const A&) = default; // expected-warning {{definition of 
implicit copy constructor for 'A' is deprecated because it has a user-declared 
copy assignment operator}}
+};
+
+struct B {
+  B& operator=(const B&) = delete; // expected-warning {{definition of 
implicit copy constructor for 'B' is deprecated because it has a user-declared 
copy assignment operator}}
+};
+
+void test() {
+  A a1;
+  A a2(a1); // expected-note {{implicit copy constructor for 'A' first 
required here}}
+
+  B b1;
+  B b2(b1); // expected-note {{implicit copy constructor for 'B' first 
required here}}
+}
+
+// PR45634
+struct S {
+  int i;
+  S& operator=(const S&) = delete; // expected-warning {{definition of 
implicit copy constructor for 'S' is deprecated because it has a user-declared 
copy assignment operator}}
+};
+
+S test(const S ) { return S(s); } // expected-note {{implicit copy 
constructor for 'S' first required here}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -14429,13 +14429,10 @@
   CXXRecordDecl *RD = CopyOp->getParent();
   CXXMethodDecl *UserDeclaredOperation = nullptr;
 
-  // In Microsoft mode, assignment operations don't affect constructors and
-  // vice versa.
   if (RD->hasUserDeclaredDestructor()) {
 UserDeclaredOperation = RD->getDestructor();
   } else if (!isa(CopyOp) &&
- RD->hasUserDeclaredCopyConstructor() &&
- !S.getLangOpts().MSVCCompat) {
+ RD->hasUserDeclaredCopyConstructor()) {
 // Find any user-declared copy constructor.
 for (auto *I : RD->ctors()) {
   if (I->isCopyConstructor()) {
@@ -14445,8 +14442,7 @@
 }
 assert(UserDeclaredOperation);
   } else if (isa(CopyOp) &&
- RD->hasUserDeclaredCopyAssignment() &&
- !S.getLangOpts().MSVCCompat) {
+ RD->hasUserDeclaredCopyAssignment()) {
 // Find any user-declared move assignment operator.
 for (auto *I : RD->methods()) {
   if (I->isCopyAssignmentOperator()) {


Index: clang/test/SemaCXX/deprecated-copy-msvc.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy-msvc.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -std=c++11 %s -Wdeprecated-copy -verify -fms-compatibility
+
+struct A {
+  A& operator=(const A&) = default; // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-declared copy assignment operator}}
+};
+
+struct B {
+  B& operator=(const B&) = delete; // expected-warning {{definition of implicit copy constructor for 'B' is deprecated because it has a user-declared copy assignment operator}}
+};
+
+void test() {
+  A a1;
+  A a2(a1); // expected-note {{implicit copy constructor for 'A' first required here}}
+
+  B b1;
+  B b2(b1); // expected-note {{implicit copy constructor for 'B' first required here}}
+}
+
+// PR45634
+struct S {
+  int i;
+  S& operator=(const S&) = delete; // expected-warning {{definition of implicit copy constructor for 'S' is deprecated because it has a user-declared copy assignment operator}}
+};
+
+S test(const S ) { return S(s); } // expected-note {{implicit copy constructor for 'S' first required here}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -14429,13 +14429,10 @@
   CXXRecordDecl *RD = CopyOp->getParent();
   CXXMethodDecl *UserDeclaredOperation = nullptr;
 
-  // In Microsoft mode, assignment