[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; Endilll wrote: We are documenting that our constant evaluator doesn't consider this UB. https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); Endilll wrote: > It also mentions in the body of member function Yeah, that is worth adding. I'll prepare a PR. https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); Endilll wrote: It's not going to fail for static member initializers because of (I suspect) subsequent changes that were made to the wording: http://eel.is/c++draft/class.mem.general#8.5 https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); shafik wrote: It also mentions in the body of member function https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; shafik wrote: So the DR says it is "unspecified" so are we documenting here that this will always be the behavior? Maybe worth a comment? https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); shafik wrote: I think it might be worth it to see that this fails for a `static member` since the DR specifically says `non-static` so we should cover both. https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/shafik edited https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/shafik commented: LGTM w/ a few nitpicks https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/Endilll closed https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/92113 >From 1ae4b4e9c6b76269b7e279f798057900b5d39a0c Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 14 May 2024 15:45:30 +0300 Subject: [PATCH 1/6] [clang] Add tests for CWG issues regarding completeness of types --- clang/test/CXX/drs/cwg11xx.cpp | 15 clang/test/CXX/drs/cwg13xx.cpp | 31 +++ clang/test/CXX/drs/cwg14xx.cpp | 17 + clang/test/CXX/drs/cwg18xx.cpp | 28 - clang/test/CXX/drs/cwg23xx.cpp | 45 -- clang/test/CXX/drs/cwg24xx.cpp | 6 + clang/test/CXX/drs/cwg25xx.cpp | 15 +--- clang/test/CXX/drs/cwg26xx.cpp | 2 ++ clang/test/CXX/drs/cwg27xx.cpp | 14 --- clang/test/CXX/drs/cwg28xx.cpp | 25 --- clang/test/CXX/drs/cwg9xx.cpp | 7 ++ clang/www/cxx_dr_status.html | 26 ++-- 12 files changed, 205 insertions(+), 26 deletions(-) diff --git a/clang/test/CXX/drs/cwg11xx.cpp b/clang/test/CXX/drs/cwg11xx.cpp index 46a0e526be390..8d187041400a6 100644 --- a/clang/test/CXX/drs/cwg11xx.cpp +++ b/clang/test/CXX/drs/cwg11xx.cpp @@ -4,6 +4,21 @@ // RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2a %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +namespace cwg1110 { // cwg1110: 3.1 +#if __cplusplus >= 201103L +template +T return_T(); + +struct A; + +template +struct B; + +decltype(return_T())* a; +decltype(return_T>())* b; +#endif +} // namespace cwg1110 + namespace cwg { // cwg: 3.2 namespace example1 { template struct set; // #cwg-struct-set diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index a334b6d01acf5..50f984fa6e7d8 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -306,6 +306,18 @@ namespace cwg1330 { // cwg1330: 4 c++11 // cwg1334: sup 1719 +namespace cwg1340 { // cwg1340: 2.9 +struct A; +struct B; + +void f(B* a, A B::* p) { + (*a).*p; + // expected-warning@-1 {{expression result unused}} + a->*p; + // expected-warning@-1 {{expression result unused}} +} +} // namespace cwg1340 + namespace cwg1341 { // cwg1341: sup P0683R1 #if __cplusplus >= 202002L int a; @@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); +#endif + void f(int b = sizeof(A)); +}; + +template +struct B { +#if __cplusplus >= 201103L + int a = sizeof(B) + sizeof(T); +#endif + void f(int b = sizeof(B) + sizeof(T)); +}; + +template class B; +} // namespace cwg1352 + namespace cwg1358 { // cwg1358: 3.1 #if __cplusplus >= 201103L struct Lit { constexpr operator int() const { return 0; } }; diff --git a/clang/test/CXX/drs/cwg14xx.cpp b/clang/test/CXX/drs/cwg14xx.cpp index 9ff9a68dc13c3..f01d96ad47f3e 100644 --- a/clang/test/CXX/drs/cwg14xx.cpp +++ b/clang/test/CXX/drs/cwg14xx.cpp @@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; +} + +struct A { + int operator&(); +}; +#endif +} // namespace cwg1458 + namespace cwg1460 { // cwg1460: 3.5 #if __cplusplus >= 201103L namespace DRExample { diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp index 9eb749153e57a..89adc28384904 100644 --- a/clang/test/CXX/drs/cwg18xx.cpp +++ b/clang/test/CXX/drs/cwg18xx.cpp @@ -206,7 +206,7 @@ namespace cwg1814 { // cwg1814: yes #endif } -namespace cwg1815 { // cwg1815: yes +namespace cwg1815 { // cwg1815: 19 #if __cplusplus >= 201402L struct A { int &&r = 0; }; A a = {}; @@ -303,6 +303,32 @@ namespace cwg1822 { // cwg1822: yes #endif } +namespace cwg1824 { // cwg1824: 2.7 +template +struct A { + T t; +}; + +struct S { + A f() { return A(); } +}; +} // namespace cwg1824 + +namespace cwg1832 { // cwg1832: 3.0 +enum E { // #cwg1832-E + a = static_cast(static_cast(0)) + // expected-error@-1 {{'E' is an incomplete type}} + // expected-note@#cwg1832-E {{definition of 'cwg1832::E' is not complete until the closing '}'}} +}; + +#if __cplusplus >= 201103L +enum E2: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E2'}} +enum class E3: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E3'}} +#endif +} // namespace cwg1832 + namespace cwg1837 { // cwg1837: 3.3 #if __cplusplus >= 201103L template diff --git a/clang/test/CXX/drs/cwg23xx.cpp b/clang/test/CXX/drs/cwg23xx.cpp index db5b7c3cd3c9a..c671a770f3b28 100644 --- a/clang/test/CXX/drs/cwg23xx.cpp +++ b/clang/test/CXX/drs/cwg23xx.cpp @@ -1,6 +1,6 @@ // RUN
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/92113 >From 1ae4b4e9c6b76269b7e279f798057900b5d39a0c Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 14 May 2024 15:45:30 +0300 Subject: [PATCH 1/5] [clang] Add tests for CWG issues regarding completeness of types --- clang/test/CXX/drs/cwg11xx.cpp | 15 clang/test/CXX/drs/cwg13xx.cpp | 31 +++ clang/test/CXX/drs/cwg14xx.cpp | 17 + clang/test/CXX/drs/cwg18xx.cpp | 28 - clang/test/CXX/drs/cwg23xx.cpp | 45 -- clang/test/CXX/drs/cwg24xx.cpp | 6 + clang/test/CXX/drs/cwg25xx.cpp | 15 +--- clang/test/CXX/drs/cwg26xx.cpp | 2 ++ clang/test/CXX/drs/cwg27xx.cpp | 14 --- clang/test/CXX/drs/cwg28xx.cpp | 25 --- clang/test/CXX/drs/cwg9xx.cpp | 7 ++ clang/www/cxx_dr_status.html | 26 ++-- 12 files changed, 205 insertions(+), 26 deletions(-) diff --git a/clang/test/CXX/drs/cwg11xx.cpp b/clang/test/CXX/drs/cwg11xx.cpp index 46a0e526be390..8d187041400a6 100644 --- a/clang/test/CXX/drs/cwg11xx.cpp +++ b/clang/test/CXX/drs/cwg11xx.cpp @@ -4,6 +4,21 @@ // RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2a %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +namespace cwg1110 { // cwg1110: 3.1 +#if __cplusplus >= 201103L +template +T return_T(); + +struct A; + +template +struct B; + +decltype(return_T())* a; +decltype(return_T>())* b; +#endif +} // namespace cwg1110 + namespace cwg { // cwg: 3.2 namespace example1 { template struct set; // #cwg-struct-set diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index a334b6d01acf5..50f984fa6e7d8 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -306,6 +306,18 @@ namespace cwg1330 { // cwg1330: 4 c++11 // cwg1334: sup 1719 +namespace cwg1340 { // cwg1340: 2.9 +struct A; +struct B; + +void f(B* a, A B::* p) { + (*a).*p; + // expected-warning@-1 {{expression result unused}} + a->*p; + // expected-warning@-1 {{expression result unused}} +} +} // namespace cwg1340 + namespace cwg1341 { // cwg1341: sup P0683R1 #if __cplusplus >= 202002L int a; @@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); +#endif + void f(int b = sizeof(A)); +}; + +template +struct B { +#if __cplusplus >= 201103L + int a = sizeof(B) + sizeof(T); +#endif + void f(int b = sizeof(B) + sizeof(T)); +}; + +template class B; +} // namespace cwg1352 + namespace cwg1358 { // cwg1358: 3.1 #if __cplusplus >= 201103L struct Lit { constexpr operator int() const { return 0; } }; diff --git a/clang/test/CXX/drs/cwg14xx.cpp b/clang/test/CXX/drs/cwg14xx.cpp index 9ff9a68dc13c3..f01d96ad47f3e 100644 --- a/clang/test/CXX/drs/cwg14xx.cpp +++ b/clang/test/CXX/drs/cwg14xx.cpp @@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; +} + +struct A { + int operator&(); +}; +#endif +} // namespace cwg1458 + namespace cwg1460 { // cwg1460: 3.5 #if __cplusplus >= 201103L namespace DRExample { diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp index 9eb749153e57a..89adc28384904 100644 --- a/clang/test/CXX/drs/cwg18xx.cpp +++ b/clang/test/CXX/drs/cwg18xx.cpp @@ -206,7 +206,7 @@ namespace cwg1814 { // cwg1814: yes #endif } -namespace cwg1815 { // cwg1815: yes +namespace cwg1815 { // cwg1815: 19 #if __cplusplus >= 201402L struct A { int &&r = 0; }; A a = {}; @@ -303,6 +303,32 @@ namespace cwg1822 { // cwg1822: yes #endif } +namespace cwg1824 { // cwg1824: 2.7 +template +struct A { + T t; +}; + +struct S { + A f() { return A(); } +}; +} // namespace cwg1824 + +namespace cwg1832 { // cwg1832: 3.0 +enum E { // #cwg1832-E + a = static_cast(static_cast(0)) + // expected-error@-1 {{'E' is an incomplete type}} + // expected-note@#cwg1832-E {{definition of 'cwg1832::E' is not complete until the closing '}'}} +}; + +#if __cplusplus >= 201103L +enum E2: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E2'}} +enum class E3: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E3'}} +#endif +} // namespace cwg1832 + namespace cwg1837 { // cwg1837: 3.3 #if __cplusplus >= 201103L template diff --git a/clang/test/CXX/drs/cwg23xx.cpp b/clang/test/CXX/drs/cwg23xx.cpp index db5b7c3cd3c9a..c671a770f3b28 100644 --- a/clang/test/CXX/drs/cwg23xx.cpp +++ b/clang/test/CXX/drs/cwg23xx.cpp @@ -1,6 +1,6 @@ // RUN
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/cor3ntin approved this pull request. LGTM, thanks https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -67,6 +63,27 @@ void B::g() requires true; } // namespace cwg2847 +namespace cwg2857 { // cwg2857: 2.7 +struct A {}; +struct B { + int operator+(A); +}; +template +struct D; + +void f(A* a, D* d) { + *d + *a; Endilll wrote: Thank you! I used one of your tests instead, and stopped claiming that CWG2857 is available. https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/92113 >From 1ae4b4e9c6b76269b7e279f798057900b5d39a0c Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 14 May 2024 15:45:30 +0300 Subject: [PATCH 1/4] [clang] Add tests for CWG issues regarding completeness of types --- clang/test/CXX/drs/cwg11xx.cpp | 15 clang/test/CXX/drs/cwg13xx.cpp | 31 +++ clang/test/CXX/drs/cwg14xx.cpp | 17 + clang/test/CXX/drs/cwg18xx.cpp | 28 - clang/test/CXX/drs/cwg23xx.cpp | 45 -- clang/test/CXX/drs/cwg24xx.cpp | 6 + clang/test/CXX/drs/cwg25xx.cpp | 15 +--- clang/test/CXX/drs/cwg26xx.cpp | 2 ++ clang/test/CXX/drs/cwg27xx.cpp | 14 --- clang/test/CXX/drs/cwg28xx.cpp | 25 --- clang/test/CXX/drs/cwg9xx.cpp | 7 ++ clang/www/cxx_dr_status.html | 26 ++-- 12 files changed, 205 insertions(+), 26 deletions(-) diff --git a/clang/test/CXX/drs/cwg11xx.cpp b/clang/test/CXX/drs/cwg11xx.cpp index 46a0e526be390..8d187041400a6 100644 --- a/clang/test/CXX/drs/cwg11xx.cpp +++ b/clang/test/CXX/drs/cwg11xx.cpp @@ -4,6 +4,21 @@ // RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2a %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +namespace cwg1110 { // cwg1110: 3.1 +#if __cplusplus >= 201103L +template +T return_T(); + +struct A; + +template +struct B; + +decltype(return_T())* a; +decltype(return_T>())* b; +#endif +} // namespace cwg1110 + namespace cwg { // cwg: 3.2 namespace example1 { template struct set; // #cwg-struct-set diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index a334b6d01acf5..50f984fa6e7d8 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -306,6 +306,18 @@ namespace cwg1330 { // cwg1330: 4 c++11 // cwg1334: sup 1719 +namespace cwg1340 { // cwg1340: 2.9 +struct A; +struct B; + +void f(B* a, A B::* p) { + (*a).*p; + // expected-warning@-1 {{expression result unused}} + a->*p; + // expected-warning@-1 {{expression result unused}} +} +} // namespace cwg1340 + namespace cwg1341 { // cwg1341: sup P0683R1 #if __cplusplus >= 202002L int a; @@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); +#endif + void f(int b = sizeof(A)); +}; + +template +struct B { +#if __cplusplus >= 201103L + int a = sizeof(B) + sizeof(T); +#endif + void f(int b = sizeof(B) + sizeof(T)); +}; + +template class B; +} // namespace cwg1352 + namespace cwg1358 { // cwg1358: 3.1 #if __cplusplus >= 201103L struct Lit { constexpr operator int() const { return 0; } }; diff --git a/clang/test/CXX/drs/cwg14xx.cpp b/clang/test/CXX/drs/cwg14xx.cpp index 9ff9a68dc13c3..f01d96ad47f3e 100644 --- a/clang/test/CXX/drs/cwg14xx.cpp +++ b/clang/test/CXX/drs/cwg14xx.cpp @@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; +} + +struct A { + int operator&(); +}; +#endif +} // namespace cwg1458 + namespace cwg1460 { // cwg1460: 3.5 #if __cplusplus >= 201103L namespace DRExample { diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp index 9eb749153e57a..89adc28384904 100644 --- a/clang/test/CXX/drs/cwg18xx.cpp +++ b/clang/test/CXX/drs/cwg18xx.cpp @@ -206,7 +206,7 @@ namespace cwg1814 { // cwg1814: yes #endif } -namespace cwg1815 { // cwg1815: yes +namespace cwg1815 { // cwg1815: 19 #if __cplusplus >= 201402L struct A { int &&r = 0; }; A a = {}; @@ -303,6 +303,32 @@ namespace cwg1822 { // cwg1822: yes #endif } +namespace cwg1824 { // cwg1824: 2.7 +template +struct A { + T t; +}; + +struct S { + A f() { return A(); } +}; +} // namespace cwg1824 + +namespace cwg1832 { // cwg1832: 3.0 +enum E { // #cwg1832-E + a = static_cast(static_cast(0)) + // expected-error@-1 {{'E' is an incomplete type}} + // expected-note@#cwg1832-E {{definition of 'cwg1832::E' is not complete until the closing '}'}} +}; + +#if __cplusplus >= 201103L +enum E2: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E2'}} +enum class E3: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E3'}} +#endif +} // namespace cwg1832 + namespace cwg1837 { // cwg1837: 3.3 #if __cplusplus >= 201103L template diff --git a/clang/test/CXX/drs/cwg23xx.cpp b/clang/test/CXX/drs/cwg23xx.cpp index db5b7c3cd3c9a..c671a770f3b28 100644 --- a/clang/test/CXX/drs/cwg23xx.cpp +++ b/clang/test/CXX/drs/cwg23xx.cpp @@ -1,6 +1,6 @@ // RUN
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/MitalAshok edited https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/MitalAshok edited https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
@@ -67,6 +63,27 @@ void B::g() requires true; } // namespace cwg2847 +namespace cwg2857 { // cwg2857: 2.7 +struct A {}; +struct B { + int operator+(A); +}; +template +struct D; + +void f(A* a, D* d) { + *d + *a; MitalAshok wrote: This wouldn't be an ADL lookup since member functions can't be found via ADL. It looks like clang doesn't actually implement CWG2857: https://godbolt.org/z/5xdYj7a35 / https://godbolt.org/z/7oqfE5WKW https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/92113 >From 1ae4b4e9c6b76269b7e279f798057900b5d39a0c Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 14 May 2024 15:45:30 +0300 Subject: [PATCH 1/3] [clang] Add tests for CWG issues regarding completeness of types --- clang/test/CXX/drs/cwg11xx.cpp | 15 clang/test/CXX/drs/cwg13xx.cpp | 31 +++ clang/test/CXX/drs/cwg14xx.cpp | 17 + clang/test/CXX/drs/cwg18xx.cpp | 28 - clang/test/CXX/drs/cwg23xx.cpp | 45 -- clang/test/CXX/drs/cwg24xx.cpp | 6 + clang/test/CXX/drs/cwg25xx.cpp | 15 +--- clang/test/CXX/drs/cwg26xx.cpp | 2 ++ clang/test/CXX/drs/cwg27xx.cpp | 14 --- clang/test/CXX/drs/cwg28xx.cpp | 25 --- clang/test/CXX/drs/cwg9xx.cpp | 7 ++ clang/www/cxx_dr_status.html | 26 ++-- 12 files changed, 205 insertions(+), 26 deletions(-) diff --git a/clang/test/CXX/drs/cwg11xx.cpp b/clang/test/CXX/drs/cwg11xx.cpp index 46a0e526be390..8d187041400a6 100644 --- a/clang/test/CXX/drs/cwg11xx.cpp +++ b/clang/test/CXX/drs/cwg11xx.cpp @@ -4,6 +4,21 @@ // RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2a %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +namespace cwg1110 { // cwg1110: 3.1 +#if __cplusplus >= 201103L +template +T return_T(); + +struct A; + +template +struct B; + +decltype(return_T())* a; +decltype(return_T>())* b; +#endif +} // namespace cwg1110 + namespace cwg { // cwg: 3.2 namespace example1 { template struct set; // #cwg-struct-set diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index a334b6d01acf5..50f984fa6e7d8 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -306,6 +306,18 @@ namespace cwg1330 { // cwg1330: 4 c++11 // cwg1334: sup 1719 +namespace cwg1340 { // cwg1340: 2.9 +struct A; +struct B; + +void f(B* a, A B::* p) { + (*a).*p; + // expected-warning@-1 {{expression result unused}} + a->*p; + // expected-warning@-1 {{expression result unused}} +} +} // namespace cwg1340 + namespace cwg1341 { // cwg1341: sup P0683R1 #if __cplusplus >= 202002L int a; @@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); +#endif + void f(int b = sizeof(A)); +}; + +template +struct B { +#if __cplusplus >= 201103L + int a = sizeof(B) + sizeof(T); +#endif + void f(int b = sizeof(B) + sizeof(T)); +}; + +template class B; +} // namespace cwg1352 + namespace cwg1358 { // cwg1358: 3.1 #if __cplusplus >= 201103L struct Lit { constexpr operator int() const { return 0; } }; diff --git a/clang/test/CXX/drs/cwg14xx.cpp b/clang/test/CXX/drs/cwg14xx.cpp index 9ff9a68dc13c3..f01d96ad47f3e 100644 --- a/clang/test/CXX/drs/cwg14xx.cpp +++ b/clang/test/CXX/drs/cwg14xx.cpp @@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot initialize a variable of type 'const int' with an rvalue of type 'A *'}} + constexpr A *p2 = &*a; +} + +struct A { + int operator&(); +}; +#endif +} // namespace cwg1458 + namespace cwg1460 { // cwg1460: 3.5 #if __cplusplus >= 201103L namespace DRExample { diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp index 9eb749153e57a..89adc28384904 100644 --- a/clang/test/CXX/drs/cwg18xx.cpp +++ b/clang/test/CXX/drs/cwg18xx.cpp @@ -206,7 +206,7 @@ namespace cwg1814 { // cwg1814: yes #endif } -namespace cwg1815 { // cwg1815: yes +namespace cwg1815 { // cwg1815: 19 #if __cplusplus >= 201402L struct A { int &&r = 0; }; A a = {}; @@ -303,6 +303,32 @@ namespace cwg1822 { // cwg1822: yes #endif } +namespace cwg1824 { // cwg1824: 2.7 +template +struct A { + T t; +}; + +struct S { + A f() { return A(); } +}; +} // namespace cwg1824 + +namespace cwg1832 { // cwg1832: 3.0 +enum E { // #cwg1832-E + a = static_cast(static_cast(0)) + // expected-error@-1 {{'E' is an incomplete type}} + // expected-note@#cwg1832-E {{definition of 'cwg1832::E' is not complete until the closing '}'}} +}; + +#if __cplusplus >= 201103L +enum E2: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E2'}} +enum class E3: decltype(static_cast(0), 0) {}; +// expected-error@-1 {{unknown type name 'E3'}} +#endif +} // namespace cwg1832 + namespace cwg1837 { // cwg1837: 3.3 #if __cplusplus >= 201103L template diff --git a/clang/test/CXX/drs/cwg23xx.cpp b/clang/test/CXX/drs/cwg23xx.cpp index db5b7c3cd3c9a..c671a770f3b28 100644 --- a/clang/test/CXX/drs/cwg23xx.cpp +++ b/clang/test/CXX/drs/cwg23xx.cpp @@ -1,6 +1,6 @@ // RUN
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/cor3ntin commented: Looks great. My only question is about cwg2630 https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/yronglin approved this pull request. Thanks! LGTM! 🤩 https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/Sirraide approved this pull request. https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/sdkrystian approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/92113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vlad Serebrennikov (Endilll) Changes This patch covers the following Core issues: [CWG930](https://cplusplus.github.io/CWG/issues/930.html) "`alignof` with incomplete array type" [CWG1110](https://cplusplus.github.io/CWG/issues/1110.html) "Incomplete return type should be allowed in `decltype` operand" [CWG1340](https://cplusplus.github.io/CWG/issues/1340.html) "Complete type in member pointer expressions" [CWG1352](https://cplusplus.github.io/CWG/issues/1352.html) "Inconsistent class scope and completeness rules" [CWG1458](https://cplusplus.github.io/CWG/issues/1458.html) "Address of incomplete type vs `operator&()`" [CWG1824](https://cplusplus.github.io/CWG/issues/1824.html) "Completeness of return type vs point of instantiation" [CWG1832](https://cplusplus.github.io/CWG/issues/1832.html) "Casting to incomplete enumeration" [CWG2304](https://cplusplus.github.io/CWG/issues/2304.html) "Incomplete type vs overload resolution" [CWG2310](https://cplusplus.github.io/CWG/issues/2310.html) "Type completeness and derived-to-base pointer conversions" [CWG2430](https://cplusplus.github.io/CWG/issues/2430.html) "Completeness of return and parameter types of member functions" [CWG2512](https://cplusplus.github.io/CWG/issues/2512.html) "`typeid` and incomplete class types" [CWG2630](https://cplusplus.github.io/CWG/issues/2630.html) "Syntactic specification of class completeness" [CWG2718](https://cplusplus.github.io/CWG/issues/2718.html) "Type completeness for derived-to-base conversions" [CWG2857](https://cplusplus.github.io/CWG/issues/2857.html) "Argument-dependent lookup with incomplete class types" Current wording for CWG1110 came from [P0135R1](https://wg21.link/p0135R1) "Wording for guaranteed copy elision through simplified value categories". As a drive-by fix, I fixed incorrect status of CWG1815, test for which was added in #87933. CC @yronglin --- Full diff: https://github.com/llvm/llvm-project/pull/92113.diff 12 Files Affected: - (modified) clang/test/CXX/drs/cwg11xx.cpp (+15) - (modified) clang/test/CXX/drs/cwg13xx.cpp (+31) - (modified) clang/test/CXX/drs/cwg14xx.cpp (+17) - (modified) clang/test/CXX/drs/cwg18xx.cpp (+27-1) - (modified) clang/test/CXX/drs/cwg23xx.cpp (+43-2) - (modified) clang/test/CXX/drs/cwg24xx.cpp (+6) - (modified) clang/test/CXX/drs/cwg25xx.cpp (+12-3) - (modified) clang/test/CXX/drs/cwg26xx.cpp (+2) - (modified) clang/test/CXX/drs/cwg27xx.cpp (+11-3) - (modified) clang/test/CXX/drs/cwg28xx.cpp (+21-4) - (modified) clang/test/CXX/drs/cwg9xx.cpp (+7) - (modified) clang/www/cxx_dr_status.html (+14-14) ``diff diff --git a/clang/test/CXX/drs/cwg11xx.cpp b/clang/test/CXX/drs/cwg11xx.cpp index 46a0e526be390..8d187041400a6 100644 --- a/clang/test/CXX/drs/cwg11xx.cpp +++ b/clang/test/CXX/drs/cwg11xx.cpp @@ -4,6 +4,21 @@ // RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2a %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +namespace cwg1110 { // cwg1110: 3.1 +#if __cplusplus >= 201103L +template +T return_T(); + +struct A; + +template +struct B; + +decltype(return_T())* a; +decltype(return_T>())* b; +#endif +} // namespace cwg1110 + namespace cwg { // cwg: 3.2 namespace example1 { template struct set; // #cwg-struct-set diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index a334b6d01acf5..416de7c536b1a 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -306,6 +306,18 @@ namespace cwg1330 { // cwg1330: 4 c++11 // cwg1334: sup 1719 +namespace cwg1340 { // cwg1340: 2.9 +struct A; +struct B; + +void f(B* a, A B::* p) { + (*a).*p; + // expected-warning@-1 {{expression result unused}} + a->*p; + // expected-warning@-1 {{expression result unused}} +} +} // namespace cwg1340 + namespace cwg1341 { // cwg1341: sup P0683R1 #if __cplusplus >= 202002L int a; @@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // cwg1352: 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); +#endif + void f(int b = sizeof(A)); +}; + +template +struct B { +#if __cplusplus >= 201103L + int a = sizeof(B) + sizeof(T); +#endif + void f(int b = sizeof(B) + sizeof(T)); +}; + +template class B; +} // namespace cwg1352 + namespace cwg1358 { // cwg1358: 3.1 #if __cplusplus >= 201103L struct Lit { constexpr operator int() const { return 0; } }; diff --git a/clang/test/CXX/drs/cwg14xx.cpp b/clang/test/CXX/drs/cwg14xx.cpp index 9ff9a68dc13c3..f01d96ad47f3e 100644 --- a/clang/test/CXX/drs/cwg14xx.cpp +++ b/clang/test/CXX/drs/cwg14xx.cpp @@ -86,6 +86,23 @@ struct A { }; } +namespace cwg1458 { // cwg1458: 3.1 +#if __cplusplus >= 201103L +struct A; + +void f() { + constexpr A* a = nullptr; + constexpr int p = &*a; + // expected-error@-1 {{cannot i
[clang] [clang] Add tests for CWG issues regarding completeness of types (PR #92113)
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/92113 This patch covers the following Core issues: [CWG930](https://cplusplus.github.io/CWG/issues/930.html) "`alignof` with incomplete array type" [CWG1110](https://cplusplus.github.io/CWG/issues/1110.html) "Incomplete return type should be allowed in `decltype` operand" [CWG1340](https://cplusplus.github.io/CWG/issues/1340.html) "Complete type in member pointer expressions" [CWG1352](https://cplusplus.github.io/CWG/issues/1352.html) "Inconsistent class scope and completeness rules" [CWG1458](https://cplusplus.github.io/CWG/issues/1458.html) "Address of incomplete type vs `operator&()`" [CWG1824](https://cplusplus.github.io/CWG/issues/1824.html) "Completeness of return type vs point of instantiation" [CWG1832](https://cplusplus.github.io/CWG/issues/1832.html) "Casting to incomplete enumeration" [CWG2304](https://cplusplus.github.io/CWG/issues/2304.html) "Incomplete type vs overload resolution" [CWG2310](https://cplusplus.github.io/CWG/issues/2310.html) "Type completeness and derived-to-base pointer conversions" [CWG2430](https://cplusplus.github.io/CWG/issues/2430.html) "Completeness of return and parameter types of member functions" [CWG2512](https://cplusplus.github.io/CWG/issues/2512.html) "`typeid` and incomplete class types" [CWG2630](https://cplusplus.github.io/CWG/issues/2630.html) "Syntactic specification of class completeness" [CWG2718](https://cplusplus.github.io/CWG/issues/2718.html) "Type completeness for derived-to-base conversions" [CWG2857](https://cplusplus.github.io/CWG/issues/2857.html) "Argument-dependent lookup with incomplete class types" Current wording for CWG1110 came from [P0135R1](https://wg21.link/p0135R1) "Wording for guaranteed copy elision through simplified value categories". As a drive-by fix, I fixed incorrect status of CWG1815, test for which was added in #87933. CC @yronglin >From 1ae4b4e9c6b76269b7e279f798057900b5d39a0c Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov Date: Tue, 14 May 2024 15:45:30 +0300 Subject: [PATCH 1/2] [clang] Add tests for CWG issues regarding completeness of types --- clang/test/CXX/drs/cwg11xx.cpp | 15 clang/test/CXX/drs/cwg13xx.cpp | 31 +++ clang/test/CXX/drs/cwg14xx.cpp | 17 + clang/test/CXX/drs/cwg18xx.cpp | 28 - clang/test/CXX/drs/cwg23xx.cpp | 45 -- clang/test/CXX/drs/cwg24xx.cpp | 6 + clang/test/CXX/drs/cwg25xx.cpp | 15 +--- clang/test/CXX/drs/cwg26xx.cpp | 2 ++ clang/test/CXX/drs/cwg27xx.cpp | 14 --- clang/test/CXX/drs/cwg28xx.cpp | 25 --- clang/test/CXX/drs/cwg9xx.cpp | 7 ++ clang/www/cxx_dr_status.html | 26 ++-- 12 files changed, 205 insertions(+), 26 deletions(-) diff --git a/clang/test/CXX/drs/cwg11xx.cpp b/clang/test/CXX/drs/cwg11xx.cpp index 46a0e526be390..8d187041400a6 100644 --- a/clang/test/CXX/drs/cwg11xx.cpp +++ b/clang/test/CXX/drs/cwg11xx.cpp @@ -4,6 +4,21 @@ // RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors // RUN: %clang_cc1 -std=c++2a %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors +namespace cwg1110 { // cwg1110: 3.1 +#if __cplusplus >= 201103L +template +T return_T(); + +struct A; + +template +struct B; + +decltype(return_T())* a; +decltype(return_T>())* b; +#endif +} // namespace cwg1110 + namespace cwg { // cwg: 3.2 namespace example1 { template struct set; // #cwg-struct-set diff --git a/clang/test/CXX/drs/cwg13xx.cpp b/clang/test/CXX/drs/cwg13xx.cpp index a334b6d01acf5..50f984fa6e7d8 100644 --- a/clang/test/CXX/drs/cwg13xx.cpp +++ b/clang/test/CXX/drs/cwg13xx.cpp @@ -306,6 +306,18 @@ namespace cwg1330 { // cwg1330: 4 c++11 // cwg1334: sup 1719 +namespace cwg1340 { // cwg1340: 2.9 +struct A; +struct B; + +void f(B* a, A B::* p) { + (*a).*p; + // expected-warning@-1 {{expression result unused}} + a->*p; + // expected-warning@-1 {{expression result unused}} +} +} // namespace cwg1340 + namespace cwg1341 { // cwg1341: sup P0683R1 #if __cplusplus >= 202002L int a; @@ -451,6 +463,25 @@ static_assert(!__is_nothrow_constructible(D4, int), ""); #endif } // namespace cwg1350 +namespace cwg1352 { // 3.0 +struct A { +#if __cplusplus >= 201103L + int a = sizeof(A); +#endif + void f(int b = sizeof(A)); +}; + +template +struct B { +#if __cplusplus >= 201103L + int a = sizeof(B) + sizeof(T); +#endif + void f(int b = sizeof(B) + sizeof(T)); +}; + +template class B; +} // namespace cwg1352 + namespace cwg1358 { // cwg1358: 3.1 #if __cplusplus >= 201103L struct Lit { constexpr operator int() const { return 0; } }; diff --git a/clang/test/CXX/drs/cwg14xx.cpp b/clang/test/CXX/drs/cwg14xx.cpp index 9ff9a68dc13c3..f01d96ad47f3e 100644 --- a/clang/test/CXX/drs/cwg14xx.cpp +++ b/clang/test/CXX/drs/cwg14xx.cpp @@ -86,6 +86,23 @@ struct A { }; } +namesp