summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Serebrennikov <serebrennikov.vladislav@gmail.com>2024-05-11 10:20:27 +0400
committerGitHub <noreply@github.com>2024-05-11 10:20:27 +0400
commit1351aabf542b25e3ff1d36f4f2abe6727d0f19aa (patch)
treea0a0e194e9183e773e06340724bef033f325e31b
parent5cd280433e8e063bf3c2390eaf152e726db5b0fb (diff)
downloadllvm-libc-1351aabf542b25e3ff1d36f4f2abe6727d0f19aa.tar.gz
[clang] Add test for CWG1820 "Qualified typedef names" (#91765)
[P1787R6](https://wg21.link/p1787r6): > [CWG1820](https://cplusplus.github.io/CWG/issues/1820.html) is resolved by requiring that a qualified declarator-id declare an entity. P1787R6 changes wording of [dcl.pre]/9. Quote from the current draft ([[dcl.pre]/5](https://eel.is/c++draft/dcl.pre#5)): > If a [declarator-id](https://eel.is/c++draft/dcl.decl.general#nt:declarator-id) is a name, the [init-declarator](https://eel.is/c++draft/dcl.decl.general#nt:init-declarator) and (hence) the declaration introduce that name[.](https://eel.is/c++draft/dcl.pre#5.sentence-1) > [Note [3](https://eel.is/c++draft/dcl.pre#note-3): Otherwise, the [declarator-id](https://eel.is/c++draft/dcl.decl.general#nt:declarator-id) is a [qualified-id](https://eel.is/c++draft/expr.prim.id.qual#nt:qualified-id) or names a destructor or its [unqualified-id](https://eel.is/c++draft/expr.prim.id.unqual#nt:unqualified-id) is a [template-id](https://eel.is/c++draft/temp.names#nt:template-id) and no name is introduced[.](https://eel.is/c++draft/dcl.pre#5.sentence-2) — end note]
-rw-r--r--clang/test/CXX/drs/cwg18xx.cpp47
-rwxr-xr-xclang/www/cxx_dr_status.html2
2 files changed, 48 insertions, 1 deletions
diff --git a/clang/test/CXX/drs/cwg18xx.cpp b/clang/test/CXX/drs/cwg18xx.cpp
index 3a2248a1af55..ea322ff4c8be 100644
--- a/clang/test/CXX/drs/cwg18xx.cpp
+++ b/clang/test/CXX/drs/cwg18xx.cpp
@@ -222,6 +222,53 @@ namespace cwg1815 { // cwg1815: no
#endif
}
+namespace cwg1820 { // cwg1820: 3.5
+typedef int A;
+typedef int cwg1820::A;
+// expected-warning@-1 {{extra qualification on member 'A'}}
+// expected-error@-2 {{typedef declarator cannot be qualified}}
+
+namespace B {
+typedef int cwg1820::A;
+// expected-error@-1 {{cannot define or redeclare 'A' here because namespace 'B' does not enclose namespace 'cwg1820'}}
+// expected-error@-2 {{typedef declarator cannot be qualified}}
+}
+
+class C1 {
+ typedef int cwg1820::A;
+ // expected-error@-1 {{non-friend class member 'A' cannot have a qualified name}}
+ // expected-error@-2 {{typedef declarator cannot be qualified}}
+};
+
+template <typename>
+class C2 {
+ typedef int cwg1820::A;
+ // expected-error@-1 {{non-friend class member 'A' cannot have a qualified name}}
+ // expected-error@-2 {{typedef declarator cannot be qualified}}
+};
+
+void d1() {
+ typedef int cwg1820::A;
+ // expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
+ // expected-error@-2 {{typedef declarator cannot be qualified}}
+}
+
+template<typename>
+void d2() {
+ typedef int cwg1820::A;
+ // expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
+ // expected-error@-2 {{typedef declarator cannot be qualified}}
+}
+
+#if __cplusplus >= 201103L
+auto e = [] {
+ typedef int cwg1820::A;
+ // expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
+ // expected-error@-2 {{typedef declarator cannot be qualified}}
+};
+#endif
+} // namespace cwg1820
+
namespace cwg1821 { // cwg1821: 2.9
struct A {
template <typename> struct B {
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 992dc61d65e4..12ab59224e82 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -10728,7 +10728,7 @@ and <I>POD class</I></td>
<td><a href="https://cplusplus.github.io/CWG/issues/1820.html">1820</a></td>
<td>CD6</td>
<td>Qualified typedef names</td>
- <td class="unknown" align="center">Unknown</td>
+ <td class="full" align="center">Clang 3.5</td>
</tr>
<tr id="1821">
<td><a href="https://cplusplus.github.io/CWG/issues/1821.html">1821</a></td>