[clang] aa7aedd - [clang] Add test for CWG1837
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 11 12:15:18 PDT 2023
Author: Vlad Serebrennikov
Date: 2023-04-11T22:15:11+03:00
New Revision: aa7aedd8ea3f75ddfb3004b81f09c5f653bc8fec
URL: https://github.com/llvm/llvm-project/commit/aa7aedd8ea3f75ddfb3004b81f09c5f653bc8fec
DIFF: https://github.com/llvm/llvm-project/commit/aa7aedd8ea3f75ddfb3004b81f09c5f653bc8fec.diff
LOG: [clang] Add test for CWG1837
[[https://wg21.link/p1787 | P1787]]: CWG1837 is resolved by restricting `this` to referring to the innermost enclosing class.
Wording: see changes to [expr.prim.this] and [expr.prim.lambda].
Reviewed By: #clang-language-wg, erichkeane
Differential Revision: https://reviews.llvm.org/D148035
Added:
Modified:
clang/test/CXX/drs/dr18xx.cpp
clang/www/cxx_dr_status.html
Removed:
################################################################################
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index 55f79295934c..02739cd2c000 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -2,7 +2,8 @@
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2a -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify -fexceptions -Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
#if __cplusplus < 201103L
// expected-error at +1 {{variadic macro}}
@@ -59,6 +60,43 @@ namespace dr1822 { // dr1822: yes
#endif
}
+namespace dr1837 { // dr1837: 3.3
+#if __cplusplus >= 201103L
+ template <typename T>
+ struct Fish { static const bool value = true; };
+
+ struct Other {
+ int p();
+ auto q() -> decltype(p()) *;
+ };
+
+ class Outer {
+ friend auto Other::q() -> decltype(this->p()) *; // expected-error {{invalid use of 'this'}}
+ int g();
+ int f() {
+ extern void f(decltype(this->g()) *);
+ struct Inner {
+ static_assert(Fish<decltype(this->g())>::value, ""); // expected-error {{invalid use of 'this'}}
+ enum { X = Fish<decltype(this->f())>::value }; // expected-error {{invalid use of 'this'}}
+ struct Inner2 : Fish<decltype(this->g())> { }; // expected-error {{invalid use of 'this'}}
+ friend void f(decltype(this->g()) *); // expected-error {{invalid use of 'this'}}
+ friend auto Other::q() -> decltype(this->p()) *; // expected-error {{invalid use of 'this'}}
+ };
+ return 0;
+ }
+ };
+
+ struct A {
+ int f();
+ bool b = [] {
+ struct Local {
+ static_assert(sizeof(this->f()) == sizeof(int), "");
+ };
+ };
+ };
+#endif
+}
+
namespace dr1872 { // dr1872: 9
#if __cplusplus >= 201103L
template<typename T> struct A : T {
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 67350fa35938..bac8a52c2d5b 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -10829,7 +10829,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://wg21.link/cwg1837">1837</a></td>
<td>CD6</td>
<td>Use of <TT>this</TT> in <TT>friend</TT> and local class declarations</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Clang 3.3</td>
</tr>
<tr id="1838">
<td><a href="https://wg21.link/cwg1838">1838</a></td>
More information about the cfe-commits
mailing list