File: cwg16xx.cpp

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (538 lines) | stat: -rw-r--r-- 24,531 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98-14,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,cxx98-14,since-cxx11,cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx14,cxx98-14,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx14,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,cxx11-20,since-cxx14,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx23,since-cxx14,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s -verify=expected,since-cxx23,since-cxx14,since-cxx20,since-cxx17,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors

#if __cplusplus == 199711L
#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
// cxx98-error@-1 {{variadic macros are a C99 feature}}
#endif

#if __cplusplus >= 201103L
namespace std {
  typedef decltype(sizeof(int)) size_t;

  template<typename E> class initializer_list {
    const E *begin;
    size_t size;

  public:
    initializer_list();
  };
} // std
#endif

namespace cwg1601 { // cwg1601: 10
enum E : char { e };
// cxx98-error@-1 {{enumeration types with a fixed underlying type are a C++11 extension}}
void f(char);
void f(int);
void g() {
  f(e);
}
} // namespace cwg1601

namespace cwg1606 { // cwg1606: 3.1
#if __cplusplus >= 201103L
  std::size_t test() {
    int i = 1;
    int j = 1;
    auto f = [=]{ return i + j; };
    return sizeof(f);
  }
#endif
} // namespace cwg1606

namespace cwg1611 { // cwg1611: dup 1658
  struct A { A(int); };
  struct B : virtual A { virtual void f() = 0; };
  struct C : B { C() : A(0) {} void f(); };
  C c;
}

namespace cwg1631 {  // cwg1631: 3.7
#if __cplusplus >= 201103L
  // Incorrect overload resolution for single-element initializer-list

  struct A { int a[1]; };
  struct B { B(int); };
  void f(B, int);
  void f(B, int, int = 0);
  void f(int, A);

  void test() {
    f({0}, {{1}});
    // since-cxx11-warning@-1 {{braces around scalar initializer}}
  }

  namespace with_error {
    void f(B, int);           // TODO: expected- note {{candidate function}}
    void f(int, A);           // #cwg1631-f
    void f(int, A, int = 0);  // #cwg1631-f-int

    void test() {
      f({0}, {{1}});
      // since-cxx11-error@-1 {{call to 'f' is ambiguous}}
      //   since-cxx11-note@#cwg1631-f {{candidate function}}
      //   since-cxx11-note@#cwg1631-f-int {{candidate function}}
    }
  }
#endif
}

namespace cwg1638 { // cwg1638: 3.1
#if __cplusplus >= 201103L
  template<typename T> struct A {
    enum class E; // #cwg1638-E
    enum class F : T; // #cwg1638-F
  };

  template<> enum class A<int>::E;
  template<> enum class A<int>::E {};
  template<> enum class A<int>::F : int;
  template<> enum class A<int>::F : int {};

  template<> enum class A<short>::E : int;
  template<> enum class A<short>::E : int {};

  template<> enum class A<short>::F;
  // since-cxx11-error@-1 {{enumeration redeclared with different underlying type 'int' (was 'short')}}
  //   since-cxx11-note@#cwg1638-F {{previous declaration is here}}
  template<> enum class A<char>::E : char;
  // since-cxx11-error@-1 {{enumeration redeclared with different underlying type 'char' (was 'int')}}
  //   since-cxx11-note@#cwg1638-E {{previous declaration is here}}
  template<> enum class A<char>::F : int;
  // since-cxx11-error@-1 {{enumeration redeclared with different underlying type 'int' (was 'char')}}
  //   since-cxx11-note@#cwg1638-F {{previous declaration is here}}

  enum class A<unsigned>::E;
  // since-cxx11-error@-1 {{template specialization requires 'template<>'}}
  template enum class A<unsigned>::E;
  // since-cxx11-error@-1 {{enumerations cannot be explicitly instantiated}}
  enum class A<unsigned>::E *e;
  // since-cxx11-error@-1 {{reference to enumeration must use 'enum' not 'enum class'}}

  struct B {
    friend enum class A<unsigned>::E;
    // since-cxx11-error@-1 {{reference to enumeration must use 'enum' not 'enum class'}}
    // since-cxx11-error@-2 {{elaborated enum specifier cannot be declared as a friend}}
    // since-cxx11-note@-3 {{remove 'enum class' to befriend an enum}}
  };
#endif
}

namespace cwg1645 { // cwg1645: 3.9
#if __cplusplus >= 201103L
  struct A {
    constexpr A(int, float = 0); // #cwg1645-int-float
    explicit A(int, int = 0); // #cwg1645-int-int
    A(int, int, int = 0) = delete; // #cwg1645-int-int-int
  };

  struct B : A {
    using A::A; // #cwg1645-using
  };

  constexpr B a(0);
  // since-cxx11-error@-1 {{call to constructor of 'const B' is ambiguous}}
  //   since-cxx11-note@#cwg1645-int-float {{candidate inherited constructor}}
  //   since-cxx11-note@#cwg1645-using {{constructor from base class 'A' inherited here}}
  //   since-cxx11-note@#cwg1645-int-int {{candidate inherited constructor}}
  //   since-cxx11-note@#cwg1645-using {{constructor from base class 'A' inherited here}}
  constexpr B b(0, 0);
  // since-cxx11-error@-1 {{call to constructor of 'const B' is ambiguous}}
  //   since-cxx11-note@#cwg1645-int-int {{candidate inherited constructor}}
  //   since-cxx11-note@#cwg1645-using {{constructor from base class 'A' inherited here}}
  //   since-cxx11-note@#cwg1645-int-int-int {{candidate inherited constructor has been explicitly deleted}}
  //   since-cxx11-note@#cwg1645-using {{constructor from base class 'A' inherited here}}
#endif
}

namespace cwg1652 { // cwg1652: 3.6
  int a, b;
  static_assert(&a + 1 == &b, "");
  // expected-error@-1 {{static assertion expression is not an integral constant expression}}
  //   expected-note@-2 {{comparison against pointer '&a + 1' that points past the end of a complete object has unspecified value}}
}

namespace cwg1653 { // cwg1653: 4 c++17
  void f(bool b) {
    ++b;
    // cxx98-14-warning@-1 {{incrementing expression of type bool is deprecated and incompatible with C++17}}
    // since-cxx17-error@-2 {{SO C++17 does not allow incrementing expression of type bool}}
    b++;
    // cxx98-14-warning@-1 {{incrementing expression of type bool is deprecated and incompatible with C++17}}
    // since-cxx17-error@-2 {{SO C++17 does not allow incrementing expression of type bool}}
    --b;
    // expected-error@-1 {{cannot decrement expression of type bool}}
    b--;
    // expected-error@-1 {{cannot decrement expression of type bool}}
    b += 1; // ok
    b -= 1; // ok
  }
}

namespace cwg1658 { // cwg1658: 5
  namespace DefCtor {
    class A { A(); }; // #cwg1658-A1
    class B { ~B(); }; // #cwg1658-B1

    // The stars align! An abstract class does not construct its virtual bases.
    struct C : virtual A { C(); virtual void foo() = 0; };
    C::C() = default; // ok, not deleted
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    struct D : virtual B { D(); virtual void foo() = 0; };
    D::D() = default; // ok, not deleted
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}

    // In all other cases, we are not so lucky.
    struct E : A { E(); virtual void foo() = 0; }; // #cwg1658-E1
    E::E() = default; // #cwg1658-E1-ctor
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@-2 {{base class 'A' has private default constructor}}
    //   cxx98-note@-3 {{in defaulted default constructor for 'cwg1658::DefCtor::E' first required here}}
    //   cxx98-note@#cwg1658-A1 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-E1-ctor {{defaulting this default constructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-E1 {{default constructor of 'E' is implicitly deleted because base class 'A' has an inaccessible default constructor}}
    struct F : virtual A { F(); }; // #cwg1658-F1
    F::F() = default; // #cwg1658-F1-ctor
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@-2 {{inherited virtual base class 'A' has private default constructor}}
    //   cxx98-note@-3 {{in defaulted default constructor for 'cwg1658::DefCtor::F' first required here}}
    //   cxx98-note@#cwg1658-A1 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-F1-ctor {{defaulting this default constructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-F1 {{default constructor of 'F' is implicitly deleted because base class 'A' has an inaccessible default constructor}}

    struct G : B { G(); virtual void foo() = 0; }; // #cwg1658-G1
    G::G() = default; // #cwg1658-G1-ctor
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@#cwg1658-G1 {{base class 'B' has private destructor}}
    //   cxx98-note@#cwg1658-G1-ctor {{in defaulted default constructor for 'cwg1658::DefCtor::G' first required here}}
    //   cxx98-note@#cwg1658-B1 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-G1-ctor {{defaulting this default constructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-G1 {{default constructor of 'G' is implicitly deleted because base class 'B' has an inaccessible destructor}}
    struct H : virtual B { H(); }; // #cwg1658-H1
    H::H() = default; // #cwg1658-H1-ctor
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@#cwg1658-H1 {{base class 'B' has private destructor}}
    //   cxx98-note@#cwg1658-H1-ctor {{in defaulted default constructor for 'cwg1658::DefCtor::H' first required here}}
    //   cxx98-note@#cwg1658-B1 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-H1-ctor {{defaulting this default constructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-H1 {{default constructor of 'H' is implicitly deleted because base class 'B' has an inaccessible destructor}}
  }

  namespace Dtor {
    class B { ~B(); }; // #cwg1658-B2

    struct D : virtual B { ~D(); virtual void foo() = 0; };
    D::~D() = default; // ok, not deleted
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}

    struct G : B { ~G(); virtual void foo() = 0; }; // #cwg1658-G2
    G::~G() = default; // #cwg1658-G2-dtor
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@#cwg1658-G2 {{base class 'B' has private destructor}}
    //   cxx98-note@#cwg1658-G2-dtor {{in defaulted destructor for 'cwg1658::Dtor::G' first required here}}
    //   cxx98-note@#cwg1658-B2 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-G2-dtor {{defaulting this destructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-G2 {{destructor of 'G' is implicitly deleted because base class 'B' has an inaccessible destructor}}
    struct H : virtual B { ~H(); }; // #cwg1658-H2
    H::~H() = default; // #cwg1658-H2-dtor
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@#cwg1658-H2 {{base class 'B' has private destructor}}
    //   cxx98-note@#cwg1658-H2-dtor {{in defaulted destructor for 'cwg1658::Dtor::H' first required here}}
    //   cxx98-note@#cwg1658-B2 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-H2-dtor {{defaulting this destructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-H2 {{destructor of 'H' is implicitly deleted because base class 'B' has an inaccessible destructor}}
  }

  namespace MemInit {
    struct A { A(int); }; // #cwg1658-A3
    struct B : virtual A {
      B() {}
      virtual void f() = 0;
    };
    struct C : virtual A {
      C() {}
      // expected-error@-1 {{constructor for 'cwg1658::MemInit::C' must explicitly initialize the base class 'A' which does not have a default constructor}}
      //   expected-note@#cwg1658-A3 {{'cwg1658::MemInit::A' declared here}}
    };
  }

  namespace CopyCtorParamType {
    struct A { A(A&); };
    struct B : virtual A { virtual void f() = 0; };
    struct C : virtual A { virtual void f(); };
    struct D : A { virtual void f() = 0; }; // since-cxx23-note {{previous declaration is here}}

    struct X {
      friend B::B(const B&) throw();
      friend C::C(C&);
      friend D::D(D&); // since-cxx23-error {{non-constexpr declaration of 'D' follows constexpr declaration}}
    };
  }

  namespace CopyCtor {
    class A { A(const A&); A(A&&); }; // #cwg1658-A5
    // cxx98-error@-1 {{rvalue references are a C++11 extension}}

    struct C : virtual A { C(const C&); C(C&&); virtual void foo() = 0; };
    // cxx98-error@-1 {{rvalue references are a C++11 extension}}
    C::C(const C&) = default;
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    C::C(C&&) = default;
    // cxx98-error@-1 {{rvalue references are a C++11 extension}}
    // cxx98-error@-2 {{defaulted function definitions are a C++11 extension}}

    struct E : A { E(const E&); E(E&&); virtual void foo() = 0; }; // #cwg1658-E5
    // cxx98-error@-1 {{rvalue references are a C++11 extension}}
    E::E(const E&) = default; // #cwg1658-E5-copy-ctor
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@-2 {{base class 'A' has private copy constructor}}
    //   cxx98-note@-3 {{in defaulted copy constructor for 'cwg1658::CopyCtor::E' first required here}}
    //   cxx98-note@#cwg1658-A5 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-E5-copy-ctor {{defaulting this copy constructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-E5 {{copy constructor of 'E' is implicitly deleted because base class 'A' has an inaccessible copy constructor}}
    E::E(E&&) = default; // #cwg1658-E5-move-ctor
    // cxx98-error@-1 {{rvalue references are a C++11 extension}}
    // cxx98-error@-2 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@-3 {{base class 'A' has private move constructor}}
    //   cxx98-note@-4 {{in defaulted move constructor for 'cwg1658::CopyCtor::E' first required here}}
    //   cxx98-note@#cwg1658-A5 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-E5-move-ctor {{defaulting this move constructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-E5 {{move constructor of 'E' is implicitly deleted because base class 'A' has an inaccessible move constructor}}
    struct F : virtual A { F(const F&); F(F&&); }; // #cwg1658-F5
    // cxx98-error@-1 {{rvalue references are a C++11 extension}}
    F::F(const F&) = default; // #cwg1658-F5-copy-ctor
    // cxx98-error@-1 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@-2 {{inherited virtual base class 'A' has private copy constructor}}
    //   cxx98-note@-3 {{in defaulted copy constructor for 'cwg1658::CopyCtor::F' first required here}}
    //   cxx98-note@#cwg1658-A5 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-F5-copy-ctor {{defaulting this copy constructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-F5 {{copy constructor of 'F' is implicitly deleted because base class 'A' has an inaccessible copy constructor}}
    F::F(F&&) = default; // #cwg1658-F5-move-ctor
    // cxx98-error@-1 {{rvalue references are a C++11 extension}}
    // cxx98-error@-2 {{defaulted function definitions are a C++11 extension}}
    // cxx98-error@-3 {{inherited virtual base class 'A' has private move constructor}}
    //   cxx98-note@-4 {{in defaulted move constructor for 'cwg1658::CopyCtor::F' first required here}}
    //   cxx98-note@#cwg1658-A5 {{implicitly declared private here}}
    // since-cxx11-error@#cwg1658-F5-move-ctor {{defaulting this move constructor would delete it after its first declaration}}
    //   since-cxx11-note@#cwg1658-F5 {{move constructor of 'F' is implicitly deleted because base class 'A' has an inaccessible move constructor}}
  }

  // assignment case is superseded by cwg2180
}

namespace cwg1672 { // cwg1672: 7
  struct Empty {};
  struct A : Empty {};
  struct B { Empty e; };
  struct C : A { B b; int n; };
  struct D : A { int n; B b; };

  static_assert(!__is_standard_layout(C), "");
  static_assert(__is_standard_layout(D), "");

  struct E { B b; int n; };
  struct F { int n; B b; };
  union G { B b; int n; };
  union H { int n; B b; };

  struct X {};
  template<typename T> struct Y : X, A { T t; };

  static_assert(!__is_standard_layout(Y<E>), "");
  static_assert(__is_standard_layout(Y<F>), "");
  static_assert(!__is_standard_layout(Y<G>), "");
  static_assert(!__is_standard_layout(Y<H>), "");
  static_assert(!__is_standard_layout(Y<X>), "");
}

namespace cwg1684 { // cwg1684: 3.6
#if __cplusplus >= 201103L
  struct NonLiteral { // #cwg1684-struct
    NonLiteral();
    constexpr int f() { return 0; }
    // cxx11-warning@-1 {{'constexpr' non-static member function will not be implicitly 'const' in C++14; add 'const' to avoid a change in behavior}}
  };
  constexpr int f(NonLiteral &) { return 0; }
  constexpr int f(NonLiteral) { return 0; }
  // cxx11-20-error@-1 {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}}
  //   cxx11-20-note@#cwg1684-struct {{'NonLiteral' is not literal because it is not an aggregate and has no constexpr constructors other than copy or move constructors}}
#endif
}

namespace cwg1687 { // cwg1687: 7
  template<typename T> struct To {
    operator T(); // #cwg1687-op-T
  };

  int *a = To<int*>() + 100.0;
  // expected-error@-1 {{invalid operands to binary expression ('To<int *>' and 'double')}}
  //   expected-note@#cwg1687-op-T {{first operand was implicitly converted to type 'int *'}}
  //   since-cxx20-note@#cwg1687-op-T {{second operand was implicitly converted to type 'cwg1687::E2'}}
  int *b = To<int*>() + To<double>();
  // expected-error@-1 {{invalid operands to binary expression ('To<int *>' and 'To<double>')}}
  //   expected-note@#cwg1687-op-T {{first operand was implicitly converted to type 'int *'}}
  //   expected-note@#cwg1687-op-T {{second operand was implicitly converted to type 'double'}}

#if __cplusplus >= 202002L
  enum E1 {};
  enum E2 {};
  auto c = To<E1>() <=> To<E2>();
  // since-cxx20-error@-1 {{invalid operands to binary expression ('To<E1>' and 'To<E2>')}}
  //   since-cxx20-note@#cwg1687-op-T {{operand was implicitly converted to type 'cwg1687::E}}
#endif
}

namespace cwg1690 { // cwg1690: 9
  // See also the various tests in "CXX/basic/basic.lookup/basic.lookup.argdep".
#if __cplusplus >= 201103L
  namespace N {
    static auto lambda = []() { struct S {} s; return s; };
    void f(decltype(lambda()));
  }

  void test() {
    auto s = N::lambda();
    f(s); // ok
  }
#endif
}

namespace cwg1691 { // cwg1691: 9
#if __cplusplus >= 201103L
  namespace N {
    namespace M {
      enum E : int;
      void f(E);
    }
    enum M::E : int {};
    void g(M::E); // #cwg1691-g
  }
  void test() {
    N::M::E e;
    f(e); // ok
    g(e);
    // since-cxx11-error@-1 {{use of undeclared identifier 'g'; did you mean 'N::g'?}}
    //   since-cxx11-note@#cwg1691-g {{'N::g' declared here}}
  }
#endif
}

namespace cwg1692 { // cwg1692: 9
  namespace N {
    struct A {
      struct B {
        struct C {};
      };
    };
    void f(A::B::C);
  }
  void test() {
    N::A::B::C c;
    f(c); // ok
  }
}

namespace cwg1696 { // cwg1696: 7
  namespace std_examples {
#if __cplusplus >= 201402L
    extern struct A a;
    struct A {
      const A &x = { A{a, a} };
      const A &y = { A{} };
      // since-cxx14-error@-1 {{default member initializer for 'y' needed within definition of enclosing class 'A' outside of member functions}}
      //   since-cxx14-note@-2 {{default member initializer declared here}}
    };
    A a{a, a};
#endif
  }

  struct A { A(); ~A(); };
#if __cplusplus >= 201103L
  struct B {
    A &&a; // #cwg1696-a
    B() : a{} {}
    // since-cxx11-error@-1 {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
    //   since-cxx11-note@#cwg1696-a {{reference member declared here}}
  } b;
#endif

  struct C {
    C();
    const A &a; // #cwg1696-C-a
  };
  C::C() : a(A()) {}
  // expected-error@-1 {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
  //   expected-note@#cwg1696-C-a {{reference member declared here}}

#if __cplusplus >= 201103L
  // This is OK in C++14 onwards, per CWG1815, though we don't support that yet:
  //   D1 d1 = {};
  // is equivalent to
  //   D1 d1 = {A()};
  // ... which lifetime-extends the A temporary.
  struct D1 {
  // cxx11-error@-1 {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
  //   cxx11-note@#cwg1696-d1 {{in implicit default constructor for 'cwg1696::D1' first required here}}
  //   cxx11-note@#cwg1696-D1-a {{initializing field 'a' with default member initializer}}
    const A &a = A(); // #cwg1696-D1-a
  };
  D1 d1 = {}; // #cwg1696-d1
  // since-cxx14-warning@-1 {{lifetime extension of temporary created by aggregate initialization using a default member initializer is not yet supported; lifetime of temporary will end at the end of the full-expression}}
  //   since-cxx14-note@#cwg1696-D1-a {{initializing field 'a' with default member initializer}}

  struct D2 {
    const A &a = A(); // #cwg1696-D2-a
    D2() {}
    // since-cxx11-error@-1 {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
    //   since-cxx11-note@#cwg1696-D2-a {{initializing field 'a' with default member initializer}}
  };

  struct D3 {
  // since-cxx11-error@-1 {{reference member 'a' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
  //   since-cxx11-note@#cwg1696-d3 {{in implicit default constructor for 'cwg1696::D3' first required here}}
  //   since-cxx11-note@#cwg1696-D3-a {{initializing field 'a' with default member initializer}}
    const A &a = A(); // #cwg1696-D3-a
  };
  D3 d3; // #cwg1696-d3

  struct haslist1 {
    std::initializer_list<int> il; // #cwg1696-il-1
    haslist1(int i) : il{i, 2, 3} {}
    // since-cxx11-error@-1 {{backing array for 'std::initializer_list' member 'il' is a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
    //   since-cxx11-note@#cwg1696-il-1 {{'std::initializer_list' member declared here}}
  };

  struct haslist2 {
    std::initializer_list<int> il; // #cwg1696-il-2
    haslist2();
  };
  haslist2::haslist2() : il{1, 2} {}
  // since-cxx11-error@-1 {{backing array for 'std::initializer_list' member 'il' is a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
  //   since-cxx11-note@#cwg1696-il-2 {{'std::initializer_list' member declared here}}

  struct haslist3 {
    std::initializer_list<int> il = {1, 2, 3};
  };

  struct haslist4 {
  // since-cxx11-error@-1 {{backing array for 'std::initializer_list' member 'il' is a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
  //   since-cxx11-note@#cwg1696-hl4 {{in implicit default constructor for 'cwg1696::haslist4' first required here}}
  //   since-cxx11-note@#cwg1696-il-4 {{initializing field 'il' with default member initializer}}
    std::initializer_list<int> il = {1, 2, 3}; // #cwg1696-il-4
  };
  haslist4 hl4; // #cwg1696-hl4

  struct haslist5 {
    std::initializer_list<int> il = {1, 2, 3}; // #cwg1696-il-5
    haslist5() {}
    // since-cxx11-error@-1 {{backing array for 'std::initializer_list' member 'il' is a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
    //   since-cxx11-note@#cwg1696-il-5 {{nitializing field 'il' with default member initializer}}
  };
#endif
}