[libc] [clang-tools-extra] [flang] [libcxx] [lld] [compiler-rt] [libunwind] [llvm] [libclc] [lldb] [clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-10 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/77444

>From 1cbf8eec15112cd6871fcfb69425c62f08c8f681 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Jan 2024 14:17:21 +0300
Subject: [PATCH 1/3] [clang] Add tests for DRs about complete-class context
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the 
older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the 
unrestricted forward lookup in complete-class contexts (despite current 
implementation behavior for non-templates).
Wording: The declaration set is the result of a single search in the scope of C 
for N from immediately after the class-specifier of C if P is in a 
complete-class context of C or from P otherwise. [Drafting note: The plan for 
CWG2335 is to describe forbidden dependency cycles among the complete-class 
contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] 
[p7](http://eel.is/c++draft/class#mem.general-7) and 
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests 
only for CWG issues that fall under current definition of complete-class 
context, because I'm not sure how CWG1255 and CWG287 are going to work. That's 
why I skip over them, but mark CWG1308 as superseded by CWG1330.
---
 clang/test/CXX/drs/dr13xx.cpp |  2 ++
 clang/test/CXX/drs/dr16xx.cpp | 22 
 clang/test/CXX/drs/dr18xx.cpp | 38 +++
 clang/test/CXX/drs/dr2335.cpp | 48 +++
 clang/www/cxx_dr_status.html  |  8 +++---
 5 files changed, 109 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CXX/drs/dr2335.cpp

diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 359c04b3e0f3d4..81a8a8a361700a 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -40,6 +40,8 @@ void caller() {
 #endif // __cplusplus >= 201103L
 } // namespace dr1307
 
+// dr1308: sup 1330
+
 namespace dr1310 { // dr1310: 5
   struct S {} * sp = new S::S;
   // expected-error@-1 {{qualified reference to 'S' is a constructor name 
rather than a type in this context}}
diff --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp
index 3f074c4d57354a..342240cdc7a43d 100644
--- a/clang/test/CXX/drs/dr16xx.cpp
+++ b/clang/test/CXX/drs/dr16xx.cpp
@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.
+#if __cplusplus >= 201103L
+namespace ex1 {
+template  struct C {
+  template  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+};
+template struct C;
+} // namespace ex1
+
+namespace ex2 {
+struct C {
+  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+  // expected-error@-1 {{in-class initializer for static data member is not a 
constant expression}}
+};
+C c;
+} // namespace ex2
+#endif
+} // namespace dr1626
+
 namespace dr1631 {  // dr1631: 3.7
 #if __cplusplus >= 201103L
   // Incorrect overload resolution for single-element initializer-list
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..0a0213c28595fd 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx14,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins 

[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-10 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll edited 
https://github.com/llvm/llvm-project/pull/77444
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-10 Thread Vlad Serebrennikov via cfe-commits


@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.

Endilll wrote:

Intent expressed in P1787 in PR description seems rather clear to me, as well 
as its application to CWG1626, but I don't insist.

https://github.com/llvm/llvm-project/pull/77444
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-09 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM modulo comment

https://github.com/llvm/llvm-project/pull/77444
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-09 Thread via cfe-commits


@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.

cor3ntin wrote:

It is not clear from 
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1626 what the 
intent for that is.

The minutes are very terse
```
- I agree with you, would be happy to mark as NAD
- Will mark as P1
```


https://github.com/llvm/llvm-project/pull/77444
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-09 Thread via cfe-commits

https://github.com/cor3ntin edited 
https://github.com/llvm/llvm-project/pull/77444
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll edited 
https://github.com/llvm/llvm-project/pull/77444
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-09 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

This PR has been migrated from https://reviews.llvm.org/D148433.
I made non-functional changes to `expected` directives to match the rest of the 
DR test suite.
I also moved CWG2335 test in a dedicated file in order to avoid issues with 
test isolation. Clang can stop instantiating templates if an error occurred 
earlier in a TU, which leads to less diagnostics emitted. Test for CWG2335 runs 
into this issue.

https://github.com/llvm/llvm-project/pull/77444
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the 
older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the 
unrestricted forward lookup in complete-class contexts (despite current 
implementation behavior for non-templates).
Wording: The declaration set is the result of a single search in the scope of C 
for N from immediately after the class-specifier of C if P is in a 
complete-class context of C or from P otherwise. [Drafting note: The plan for 
CWG2335 is to describe forbidden dependency cycles among the complete-class 
contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] 
[p7](http://eel.is/c++draft/class#mem.general-7) and 
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests 
only for CWG issues that fall under current definition of complete-class 
context, because I'm not sure how CWG1255 and CWG287 are going to work. That's 
why I skip over them, but mark CWG1308 as superseded by CWG1330.

---
Full diff: https://github.com/llvm/llvm-project/pull/77444.diff


5 Files Affected:

- (modified) clang/test/CXX/drs/dr13xx.cpp (+2) 
- (modified) clang/test/CXX/drs/dr16xx.cpp (+22) 
- (modified) clang/test/CXX/drs/dr18xx.cpp (+33-5) 
- (added) clang/test/CXX/drs/dr2335.cpp (+48) 
- (modified) clang/www/cxx_dr_status.html (+4-4) 


``diff
diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 359c04b3e0f3d4..81a8a8a361700a 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -40,6 +40,8 @@ void caller() {
 #endif // __cplusplus >= 201103L
 } // namespace dr1307
 
+// dr1308: sup 1330
+
 namespace dr1310 { // dr1310: 5
   struct S {} * sp = new S::S;
   // expected-error@-1 {{qualified reference to 'S' is a constructor name 
rather than a type in this context}}
diff --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp
index 3f074c4d57354a..342240cdc7a43d 100644
--- a/clang/test/CXX/drs/dr16xx.cpp
+++ b/clang/test/CXX/drs/dr16xx.cpp
@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.
+#if __cplusplus >= 201103L
+namespace ex1 {
+template  struct C {
+  template  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+};
+template struct C;
+} // namespace ex1
+
+namespace ex2 {
+struct C {
+  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+  // expected-error@-1 {{in-class initializer for static data member is not a 
constant expression}}
+};
+C c;
+} // namespace ex2
+#endif
+} // namespace dr1626
+
 namespace dr1631 {  // dr1631: 3.7
 #if __cplusplus >= 201103L
   // Incorrect overload resolution for single-element initializer-list
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..0a0213c28595fd 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx14,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx14,cxx11-17,since-cxx11,since-cxx14 -fexceptions 
-Wno-deprecated-builtins -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 

[clang] [clang] Add tests for DRs about complete-class context (PR #77444)

2024-01-09 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/77444

[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the 
older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the 
unrestricted forward lookup in complete-class contexts (despite current 
implementation behavior for non-templates).
Wording: The declaration set is the result of a single search in the scope of C 
for N from immediately after the class-specifier of C if P is in a 
complete-class context of C or from P otherwise. [Drafting note: The plan for 
CWG2335 is to describe forbidden dependency cycles among the complete-class 
contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] 
[p7](http://eel.is/c++draft/class#mem.general-7) and 
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests 
only for CWG issues that fall under current definition of complete-class 
context, because I'm not sure how CWG1255 and CWG287 are going to work. That's 
why I skip over them, but mark CWG1308 as superseded by CWG1330.

>From 1cbf8eec15112cd6871fcfb69425c62f08c8f681 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Jan 2024 14:17:21 +0300
Subject: [PATCH] [clang] Add tests for DRs about complete-class context
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[P1787](https://wg21.link/p1787): The intent for CWG2335 (contra those of the 
older CWG1890, CWG1626, CWG1255, and CWG287) is supported by retaining the 
unrestricted forward lookup in complete-class contexts (despite current 
implementation behavior for non-templates).
Wording: The declaration set is the result of a single search in the scope of C 
for N from immediately after the class-specifier of C if P is in a 
complete-class context of C or from P otherwise. [Drafting note: The plan for 
CWG2335 is to describe forbidden dependency cycles among the complete-class 
contexts of a class. — end drafting note] ([class.member.lookup]/4)

Complete-class context is described in [class.mem.general] 
[p7](http://eel.is/c++draft/class#mem.general-7) and 
[p8](http://eel.is/c++draft/class#mem.general-8). In this patch I add tests 
only for CWG issues that fall under current definition of complete-class 
context, because I'm not sure how CWG1255 and CWG287 are going to work. That's 
why I skip over them, but mark CWG1308 as superseded by CWG1330.
---
 clang/test/CXX/drs/dr13xx.cpp |  2 ++
 clang/test/CXX/drs/dr16xx.cpp | 22 
 clang/test/CXX/drs/dr18xx.cpp | 38 +++
 clang/test/CXX/drs/dr2335.cpp | 48 +++
 clang/www/cxx_dr_status.html  |  8 +++---
 5 files changed, 109 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/CXX/drs/dr2335.cpp

diff --git a/clang/test/CXX/drs/dr13xx.cpp b/clang/test/CXX/drs/dr13xx.cpp
index 359c04b3e0f3d4..81a8a8a361700a 100644
--- a/clang/test/CXX/drs/dr13xx.cpp
+++ b/clang/test/CXX/drs/dr13xx.cpp
@@ -40,6 +40,8 @@ void caller() {
 #endif // __cplusplus >= 201103L
 } // namespace dr1307
 
+// dr1308: sup 1330
+
 namespace dr1310 { // dr1310: 5
   struct S {} * sp = new S::S;
   // expected-error@-1 {{qualified reference to 'S' is a constructor name 
rather than a type in this context}}
diff --git a/clang/test/CXX/drs/dr16xx.cpp b/clang/test/CXX/drs/dr16xx.cpp
index 3f074c4d57354a..342240cdc7a43d 100644
--- a/clang/test/CXX/drs/dr16xx.cpp
+++ b/clang/test/CXX/drs/dr16xx.cpp
@@ -42,6 +42,28 @@ namespace dr1611 { // dr1611: dup 1658
   C c;
 }
 
+namespace dr1626 { // dr1626: no open
+// FIXME: current consensus for CWG2335 is that the examples are well-formed.
+#if __cplusplus >= 201103L
+namespace ex1 {
+template  struct C {
+  template  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+};
+template struct C;
+} // namespace ex1
+
+namespace ex2 {
+struct C {
+  static constexpr bool _S_chk() { return false; }
+  static const bool __value = _S_chk();
+  // expected-error@-1 {{in-class initializer for static data member is not a 
constant expression}}
+};
+C c;
+} // namespace ex2
+#endif
+} // namespace dr1626
+
 namespace dr1631 {  // dr1631: 3.7
 #if __cplusplus >= 201103L
   // Incorrect overload resolution for single-element initializer-list
diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp
index fbe67bd0c2f6db..0a0213c28595fd 100644
--- a/clang/test/CXX/drs/dr18xx.cpp
+++ b/clang/test/CXX/drs/dr18xx.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -Wno-deprecated-builtins -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx11-17,since-cxx11 -fexceptions -Wno-deprecated-builtins 
-fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s