Skip to content

Commit 1351aab

Browse files
authored
[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]
1 parent 5cd2804 commit 1351aab

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

clang/test/CXX/drs/cwg18xx.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,53 @@ namespace cwg1815 { // cwg1815: no
222222
#endif
223223
}
224224

225+
namespace cwg1820 { // cwg1820: 3.5
226+
typedef int A;
227+
typedef int cwg1820::A;
228+
// expected-warning@-1 {{extra qualification on member 'A'}}
229+
// expected-error@-2 {{typedef declarator cannot be qualified}}
230+
231+
namespace B {
232+
typedef int cwg1820::A;
233+
// expected-error@-1 {{cannot define or redeclare 'A' here because namespace 'B' does not enclose namespace 'cwg1820'}}
234+
// expected-error@-2 {{typedef declarator cannot be qualified}}
235+
}
236+
237+
class C1 {
238+
typedef int cwg1820::A;
239+
// expected-error@-1 {{non-friend class member 'A' cannot have a qualified name}}
240+
// expected-error@-2 {{typedef declarator cannot be qualified}}
241+
};
242+
243+
template <typename>
244+
class C2 {
245+
typedef int cwg1820::A;
246+
// expected-error@-1 {{non-friend class member 'A' cannot have a qualified name}}
247+
// expected-error@-2 {{typedef declarator cannot be qualified}}
248+
};
249+
250+
void d1() {
251+
typedef int cwg1820::A;
252+
// expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
253+
// expected-error@-2 {{typedef declarator cannot be qualified}}
254+
}
255+
256+
template<typename>
257+
void d2() {
258+
typedef int cwg1820::A;
259+
// expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
260+
// expected-error@-2 {{typedef declarator cannot be qualified}}
261+
}
262+
263+
#if __cplusplus >= 201103L
264+
auto e = [] {
265+
typedef int cwg1820::A;
266+
// expected-error@-1 {{definition or redeclaration of 'A' not allowed inside a function}}
267+
// expected-error@-2 {{typedef declarator cannot be qualified}}
268+
};
269+
#endif
270+
} // namespace cwg1820
271+
225272
namespace cwg1821 { // cwg1821: 2.9
226273
struct A {
227274
template <typename> struct B {

clang/www/cxx_dr_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10728,7 +10728,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1072810728
<td><a href="https://cplusplus.github.io/CWG/issues/1820.html">1820</a></td>
1072910729
<td>CD6</td>
1073010730
<td>Qualified typedef names</td>
10731-
<td class="unknown" align="center">Unknown</td>
10731+
<td class="full" align="center">Clang 3.5</td>
1073210732
</tr>
1073310733
<tr id="1821">
1073410734
<td><a href="https://cplusplus.github.io/CWG/issues/1821.html">1821</a></td>

0 commit comments

Comments
 (0)