File: cwg1xx.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 (1337 lines) | stat: -rw-r--r-- 44,995 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
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify=expected,cxx98,cxx98-11,cxx98-14,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,cxx98-11,cxx98-14,cxx98-17,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,cxx98-14,cxx98-17,cxx11-14 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -fexceptions -fcxx-exceptions -pedantic-errors
// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify=expected,since-cxx11,since-cxx17 -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 == 199711L
#define __enable_constant_folding(x) (__builtin_constant_p(x) ? (x) : (x))
#else
#define __enable_constant_folding
#endif

namespace cwg100 { // cwg100: yes
  template<const char (*)[4]> struct A {}; // #cwg100-A
  template<const char (&)[4]> struct B {}; // #cwg100-B
  template<const char *> struct C {}; // #cwg100-C
  template<const char &> struct D {}; // #cwg100-D
  A<&"foo"> a; // #cwg100-a
  // cxx98-14-error@#cwg100-a {{non-type template argument does not refer to any declaration}}
  //   cxx98-14-note@#cwg100-A {{template parameter is declared here}}
  // since-cxx17-error@#cwg100-a {{pointer to string literal is not allowed in a template argument}}
  B<"bar"> b; // #cwg100-b
  // cxx98-14-error@#cwg100-b {{non-type template argument does not refer to any declaration}}
  //   cxx98-14-note@#cwg100-B {{template parameter is declared here}}
  // since-cxx17-error@#cwg100-b {{reference to string literal is not allowed in a template argument}}
  C<"baz"> c; // #cwg100-c
  // cxx98-14-error@#cwg100-c {{non-type template argument does not refer to any declaration}}
  //   cxx98-14-note@#cwg100-C {{template parameter is declared here}}
  // since-cxx17-error@#cwg100-c {{pointer to subobject of string literal is not allowed in a template argument}}
  D<*"quux"> d; // #cwg100-d
  // cxx98-14-error@#cwg100-d {{non-type template argument does not refer to any declaration}}
  //   cxx98-14-note@#cwg100-D {{template parameter is declared here}}
  // since-cxx17-error@#cwg100-d {{reference to subobject of string literal is not allowed in a template argument}}
}

namespace cwg101 { // cwg101: 3.5
  extern "C" void cwg101_f();
  typedef unsigned size_t;
  namespace X {
    extern "C" void cwg101_f();
    typedef unsigned size_t;
  }
  using X::cwg101_f;
  using X::size_t;
  extern "C" void cwg101_f();
  typedef unsigned size_t;
}

namespace cwg102 { // cwg102: yes
  namespace A {
    template<typename T> T f(T a, T b) { return a + b; }
    // expected-error@-1 {{call to function 'operator+' that is neither visible in the template definition nor found by argument-dependent lookup}}
    //   expected-note@#cwg102-instantiation {{in instantiation of function template specialization 'cwg102::A::f<cwg102::B::S>' requested here}}
    //   expected-note@#cwg102-operator-plus {{'operator+' should be declared prior to the call site or in namespace 'cwg102::B'}}
  }
  namespace B {
    struct S {};
  }
  B::S operator+(B::S, B::S); // #cwg102-operator-plus
  template B::S A::f(B::S, B::S); // #cwg102-instantiation
}

// cwg103: na
// cwg104: na lib
// cwg105: na

namespace cwg106 { // cwg106: sup 540
  typedef int &r1;
  typedef r1 &r1;
  typedef const r1 r1;
  // expected-warning@-1 {{'const' qualifier on reference type 'r1' (aka 'int &') has no effect}}
  typedef const r1 &r1;
  // expected-warning@-1 {{'const' qualifier on reference type 'r1' (aka 'int &') has no effect}}

  typedef const int &r2;
  typedef r2 &r2;
  typedef const r2 r2;
  // expected-warning@-1 {{'const' qualifier on reference type 'r2' (aka 'const int &') has no effect}}
  typedef const r2 &r2;
  // expected-warning@-1 {{'const' qualifier on reference type 'r2' (aka 'const int &') has no effect}}
}

namespace cwg107 { // cwg107: yes
  struct S {};
  extern "C" S operator+(S, S) { return S(); }
}

namespace cwg108 { // cwg108: 2.9
  template<typename T> struct A {
    struct B { typedef int X; };
    B::X x;
    // cxx98-17-error@-1 {{missing 'typename' prior to dependent type name B::X; implicit 'typename' is a C++20 extension}}
    struct C : B { X x; };
    // expected-error@-1 {{unknown type name 'X'}}
  };
  template<> struct A<int>::B { int X; };
}

namespace cwg109 { // cwg109: yes
  struct A { template<typename T> void f(T); };
  template<typename T> struct B : T {
    using T::template f;
    // expected-error@-1 {{'template' keyword not permitted here}}
    using T::template f<int>;
    // expected-error@-1 {{'template' keyword not permitted here}}
    // expected-error@-2 {{using declaration cannot refer to a template specialization}}
    // FIXME: We shouldn't suggest using the 'template' keyword in a location where it's not valid.
    using T::f<int>;
    // expected-error@-1 {{use 'template' keyword to treat 'f' as a dependent template name}}
    // expected-error@-2 {{using declaration cannot refer to a template specialization}}
    void g() { this->f<int>(123); }
    // expected-error@-1 {{use 'template' keyword to treat 'f' as a dependent template name}}
  };
}

namespace cwg111 { // cwg111: dup 535
  struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); };
  struct B : A { B(); }; // #cwg111-B
  const B b1;
  B b2(b1);
  // expected-error@-1 {{no matching constructor for initialization of 'B'}}
  //   expected-note@#cwg111-B {{candidate constructor (the implicit copy constructor) not viable: 1st argument ('const B') would lose const qualifier}}
  //   expected-note@#cwg111-B {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
}

namespace cwg112 { // cwg112: yes
  struct T { int n; };
  typedef T Arr[1];

  const T a1[1] = {}; // #cwg112-a1
  volatile T a2[1] = {};
  const Arr a3 = {}; // #cwg112-a3
  volatile Arr a4 = {};
  template<const volatile T*> struct X {};
  // FIXME: Test this somehow in C++11 and on.
  X<a1> x1;
  // cxx98-error@-1 {{non-type template argument referring to object 'a1' with internal linkage is a C++11 extension}}
  //   cxx98-note@#cwg112-a1 {{non-type template argument refers to object here}}
  X<a2> x2;
  X<a3> x3;
  // cxx98-error@-1 {{non-type template argument referring to object 'a3' with internal linkage is a C++11 extension}}
  //   cxx98-note@#cwg112-a3 {{non-type template argument refers to object here}}
  X<a4> x4;
}

namespace cwg113 { // cwg113: yes
  extern void (*p)();
  void f() {
    no_such_function();
    // expected-error@-1 {{use of undeclared identifier 'no_such_function'}}
    p();
  }
  void g();
  void (*p)() = &g;
}

namespace cwg114 { // cwg114: yes
  struct A {
    virtual void f(int) = 0; // #cwg114-A-f
  };
  struct B : A {
    template<typename T> void f(T);
    void g() { f(0); }
  } b;
  // expected-error@-1 {{variable type 'struct B' is an abstract class}}
  //   expected-note@#cwg114-A-f {{unimplemented pure virtual method 'f' in 'B'}}
}

namespace cwg115 { // cwg115: 3.0
  template<typename T> int f(T); // #cwg115-f
  template<typename T> int g(T); // #cwg115-g
  template<typename T> int g(T, int); // #cwg115-g-int

  int k1 = f(&f);
  // expected-error@-1 {{no matching function for call to 'f'}}
  //   expected-note@#cwg115-f {{candidate template ignored: couldn't infer template argument 'T'}}
  int k2 = f(&f<int>);
  int k3 = f(&g<int>);
  // expected-error@-1 {{no matching function for call to 'f'}}
  //   expected-note@#cwg115-f {{candidate template ignored: couldn't infer template argument 'T'}}

  void h() {
    (void)&f;
    // expected-error@-1 {{address of overloaded function 'f' cannot be cast to type 'void'}}
    //   expected-note@#cwg115-f {{candidate function template}}
    (void)&f<int>;
    (void)&g<int>;
    // expected-error@-1 {{address of overloaded function 'g' cannot be cast to type 'void'}}
    //   expected-note@#cwg115-g-int {{candidate function template}}
    //   expected-note@#cwg115-g {{candidate function template}}

    &f;
    // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}}
    //   expected-note@#cwg115-f {{possible target for call}}
    &f<int>;
    // expected-warning@-1 {{expression result unused}}
    &g<int>;
    // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}}
    //   expected-note@#cwg115-g-int {{possible target for call}}
    //   expected-note@#cwg115-g {{possible target for call}}
  }

  struct S {
    template<typename T> static int f(T);
    template<typename T> static int g(T);
    template<typename T> static int g(T, int);
  } s;

  int k4 = f(&s.f);
  // expected-error@-1 {{cannot create a non-constant pointer to member function}}
  int k5 = f(&s.f<int>);
  int k6 = f(&s.g<int>);
  // expected-error@-1 {{cannot create a non-constant pointer to member function}}

  void i() {
    (void)&s.f;
    // expected-error@-1 {{cannot create a non-constant pointer to member function}}
    (void)&s.f<int>;
    (void)&s.g<int>;
    // expected-error@-1 {{cannot create a non-constant pointer to member function}}

    &s.f;
    // expected-error@-1 {{cannot create a non-constant pointer to member function}}
    &s.f<int>;
    // expected-warning@-1 {{expression result unused}}
    &s.g<int>;
    // expected-error@-1 {{cannot create a non-constant pointer to member function}}
  }

  struct T {
    template<typename T> int f(T);
    template<typename T> int g(T);
    template<typename T> int g(T, int);
  } t;

  int k7 = f(&s.f);
  // expected-error@-1 {{cannot create a non-constant pointer to member function}}
  int k8 = f(&s.f<int>);
  int k9 = f(&s.g<int>);
  // expected-error@-1 {{cannot create a non-constant pointer to member function}}

  void j() {
    (void)&s.f;
    // expected-error@-1 {{cannot create a non-constant pointer to member function}}
    (void)&s.f<int>;
    (void)&s.g<int>;
    // expected-error@-1 {{cannot create a non-constant pointer to member function}}

    &s.f;
    // expected-error@-1 {{cannot create a non-constant pointer to member function}}
    &s.f<int>;
    // expected-warning@-1 {{expression result unused}}
    &s.g<int>;
    // expected-error@-1 {{cannot create a non-constant pointer to member function}}
  }

#if __cplusplus >= 201103L
  // Special case kicks in only if a template argument list is specified.
  template<typename T=int> void with_default(); // #cwg115-with-default
  int k10 = f(&with_default);
  // expected-error@-1 {{no matching function for call to 'f'}}
  //   expected-note@#cwg115-f {{candidate template ignored: couldn't infer template argument 'T'}}
  int k11 = f(&with_default<>);
  void k() {
    (void)&with_default;
    // expected-error@-1 {{address of overloaded function 'with_default' cannot be cast to type 'void'}}
    //   expected-note@#cwg115-with-default {{candidate function template}}
    (void)&with_default<>;
    &with_default;
    // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}}
    //   expected-note@#cwg115-with-default {{possible target for call}}
    &with_default<>;
    // expected-warning@-1 {{expression result unused}}
  }
#endif
}

namespace cwg116 { // cwg116: yes
  template<int> struct A {};
  template<int N> void f(A<N>) {} // #cwg116-f-N
  template<int M> void f(A<M>) {}
  // expected-error@-1 {{redefinition of 'f'}}
  //   expected-note@#cwg116-f-N {{previous definition is here}}
  template<typename T> void f(A<sizeof(T)>) {} // #cwg116-f-T
  template<typename U> void f(A<sizeof(U)>) {}
  // expected-error@-1 {{redefinition of 'f'}}
  //   expected-note@#cwg116-f-T {{previous definition is here}}
}

// cwg117: na
// cwg118 is in cwg118.cpp
// cwg119: na
// cwg120: na

namespace cwg121 { // cwg121: yes
  struct X {
    template<typename T> struct Y {};
  };
  template<typename T> struct Z {
    X::Y<T> x;
    T::Y<T> y;
    // expected-error@-1 {{use 'template' keyword to treat 'Y' as a dependent template name}}
    // cxx98-17-error@-2 {{missing 'typename' prior to dependent type name T::Y; implicit 'typename' is a C++20 extension}}
  };
  Z<X> z;
}

namespace cwg122 { // cwg122: yes
  template<typename T> void f();
  void g() { f<int>(); }
}

// cwg123: na
// cwg124 is in cwg124.cpp

// cwg125: yes
struct cwg125_A { struct cwg125_B {}; }; // #cwg125_B
cwg125_A::cwg125_B cwg125_C();
namespace cwg125_B { cwg125_A cwg125_C(); }
namespace cwg125 {
  struct X {
    friend cwg125_A::cwg125_B (::cwg125_C)(); // ok
    friend cwg125_A (::cwg125_B::cwg125_C)(); // ok
    friend cwg125_A::cwg125_B::cwg125_C(); // #cwg125_C
    // expected-error@#cwg125_C {{missing return type for function 'cwg125_C'; did you mean the constructor name 'cwg125_B'?}}
    // cxx98-error@#cwg125_C {{'cwg125_B' is missing exception specification 'throw()'}}
    //   cxx98-note@#cwg125_B {{previous declaration is here}}
    // since-cxx11-error@#cwg125_C {{'cwg125_B' is missing exception specification 'noexcept'}}
    //   since-cxx11-note@#cwg125_B {{previous declaration is here}}
  };
}

namespace cwg126 { // cwg126: partial
  // FIXME: We do not yet generate correct code for this change:
  // eg:
  //   catch (void*&) should catch void* but not int*
  //   catch (void*) and catch (void*const&) should catch both
  // Likewise:
  //   catch (Base *&) should catch Base* but not Derived*
  //   catch (Base *) should catch both
  // In each case, we emit the same code for both catches.
  //
  // The ABI does not let us represent the language rule in the unwind tables.
  // So, when catching by non-const (or volatile) reference to pointer, we
  // should compare the exception type to the caught type and only accept an
  // exact match.
  struct C {};
  struct D : C {};
  struct E : private C { friend class A; friend class B; };
  struct F : protected C {};
  struct G : C {};
  struct H : D, G {};

#if __cplusplus <= 201402L
  struct A {
    virtual void cp() throw(C*);
    virtual void dp() throw(C*);
    virtual void ep() throw(C*); // #cwg126-ep
    virtual void fp() throw(C*); // #cwg126-fp
    virtual void gp() throw(C*);
    virtual void hp() throw(C*); // #cwg126-hp

    virtual void cr() throw(C&);
    virtual void dr() throw(C&);
    virtual void er() throw(C&); // #cwg126-er
    virtual void fr() throw(C&); // #cwg126-fr
    virtual void gr() throw(C&);
    virtual void hr() throw(C&); // #cwg126-hr

    virtual void pv() throw(void*);

    virtual void np() throw(C*);
    virtual void npm() throw(int C::*);
    virtual void nr() throw(C*&); // #cwg126-nr
    virtual void ncr() throw(C*const&);

    virtual void ref1() throw(C *const&);
    virtual void ref2() throw(C *);

    virtual void v() throw(int);
    virtual void w() throw(const int);
    virtual void x() throw(int*); // #cwg126-x
    virtual void y() throw(const int*);
    virtual void z() throw(int); // #cwg126-z
  };
  struct B : A {
    virtual void cp() throw(C*);
    virtual void dp() throw(D*);
    virtual void ep() throw(E*);
    // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx98-14-note@#cwg126-ep {{overridden virtual function is here}}
    virtual void fp() throw(F*);
    // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx98-14-note@#cwg126-fp {{overridden virtual function is here}}
    virtual void gp() throw(G*);
    virtual void hp() throw(H*);
    // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx98-14-note@#cwg126-hp {{overridden virtual function is here}}

    virtual void cr() throw(C&);
    virtual void dr() throw(D&);
    virtual void er() throw(E&);
    // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx98-14-note@#cwg126-er {{overridden virtual function is here}}
    virtual void fr() throw(F&);
    // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx98-14-note@#cwg126-fr {{overridden virtual function is here}}
    virtual void gr() throw(G&);
    virtual void hr() throw(H&);
    // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx98-14-note@#cwg126-hr {{overridden virtual function is here}}

    virtual void pv() throw(C*);

#if __cplusplus >= 201103L
    using nullptr_t = decltype(nullptr);
    virtual void np() throw(nullptr_t);
    virtual void npm() throw(nullptr_t&);
    virtual void nr() throw(nullptr_t);
    // cxx11-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx11-14-note@#cwg126-nr {{overridden virtual function is here}}
    virtual void ncr() throw(nullptr_t);
#endif // __cplusplus >= 201103L

    virtual void ref1() throw(D *const &);
    virtual void ref2() throw(D *);

    virtual void v() throw(const int);
    virtual void w() throw(int);
    virtual void x() throw(const int*);
    // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx98-14-note@#cwg126-x {{overridden virtual function is here}}
    virtual void y() throw(int*); // ok
    virtual void z() throw(long);
    // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}}
    //   cxx98-14-note@#cwg126-z {{overridden virtual function is here}}
  };
#endif // __cplusplus <= 201402L
  void f() throw(int);
  // since-cxx17-error@-1 {{ISO C++17 does not allow dynamic exception specifications}}
  //   since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
}

namespace cwg127 { // cwg127: 2.9
  __extension__ typedef __decltype(sizeof(0)) size_t;
  template<typename T> struct A {
    A() { throw 0; }
    void *operator new(size_t, const char * = 0);
    void operator delete(void *, const char *) { T::error; } // #cwg127-delete-const-char
    // expected-error@#cwg127-delete-const-char {{type 'void' cannot be used prior to '::' because it has no members}}
    //   expected-note@#cwg127-p {{in instantiation of member function 'cwg127::A<void>::operator delete' requested here}}
    // expected-error@#cwg127-delete-const-char {{type 'int' cannot be used prior to '::' because it has no members}}
    //   expected-note@#cwg127-q {{in instantiation of member function 'cwg127::A<int>::operator delete' requested here}}
    void operator delete(void *) { T::error; }
  };
  A<void> *p = new A<void>; // #cwg127-p
  A<int> *q = new ("") A<int>; // #cwg127-q
}

namespace cwg128 { // cwg128: yes
  enum E1 { e1 } x = e1;
  enum E2 { e2 } y = static_cast<E2>(x), z = static_cast<E2>(e1);
}

// cwg129: dup 616
// cwg130: na

namespace cwg131 { // cwg131: sup P1949
  const char *a_with_\u0e8c = "\u0e8c";
  const char *b_with_\u0e8d = "\u0e8d";
  const char *c_with_\u0e8e = "\u0e8e";
}

namespace cwg132 { // cwg132: no
  void f() {
    extern struct {} x; // ok
    extern struct S {} y; // FIXME: This is invalid.
  }
  static enum { E } e;
}

// cwg133: dup 87
// cwg134: na

namespace cwg135 { // cwg135: yes
  struct A {
    A f(A a) { return a; }
    friend A g(A a) { return a; }
    static A h(A a) { return a; }
  };
}

namespace cwg136 { // cwg136: 3.4
  void f(int, int, int = 0); // #cwg136-f
  void g(int, int, int); // #cwg136-g
  struct A {
    friend void f(int, int = 0, int);
    // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}}
    //   expected-note@#cwg136-f {{previous declaration is here}}
    friend void g(int, int, int = 0);
    // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}}
    //   expected-note@#cwg136-g {{previous declaration is here}}
    friend void h(int, int, int = 0);
    // expected-error@-1 {{friend declaration specifying a default argument must be a definition}}
    friend void i(int, int, int = 0) {} // #cwg136-A-i
    friend void j(int, int, int = 0) {}
    operator int();
  };
  void i(int, int, int);
  // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}}
  //   expected-note@#cwg136-A-i {{previous declaration is here}}
  void q() {
    j(A(), A()); // ok, has default argument
  }
  extern "C" void k(int, int, int, int); // #cwg136-k
  namespace NSA {
  struct A {
    friend void cwg136::k(int, int, int, int = 0);
    // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}}
    //   expected-note@#cwg136-k {{previous declaration is here}}
  };
  }
  namespace NSB {
  struct A {
    friend void cwg136::k(int, int, int = 0, int); // #cwg136-friend-k
    // expected-error@#cwg136-friend-k {{friend declaration specifying a default argument must be the only declaration}}
    //   expected-note@#cwg136-k {{previous declaration is here}}
    // expected-error@#cwg136-friend-k {{missing default argument on parameter}}
  };
  }
  struct B {
    void f(int); // #cwg136-B-f
  };
  struct C {
    friend void B::f(int = 0);
    // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}}
    //   expected-note@#cwg136-B-f {{previous declaration is here}}
  };
}

namespace cwg137 { // cwg137: yes
  extern void *p;
  extern const void *cp;
  extern volatile void *vp;
  extern const volatile void *cvp;
  int *q = static_cast<int*>(p);
  int *qc = static_cast<int*>(cp);
  // expected-error@-1 {{static_cast from 'const void *' to 'int *' casts away qualifiers}}
  int *qv = static_cast<int*>(vp);
  // expected-error@-1 {{static_cast from 'volatile void *' to 'int *' casts away qualifiers}}
  int *qcv = static_cast<int*>(cvp);
  // expected-error@-1 {{static_cast from 'const volatile void *' to 'int *' casts away qualifiers}}
  const int *cq = static_cast<const int*>(p);
  const int *cqc = static_cast<const int*>(cp);
  const int *cqv = static_cast<const int*>(vp);
  // expected-error@-1 {{static_cast from 'volatile void *' to 'const int *' casts away qualifiers}}
  const int *cqcv = static_cast<const int*>(cvp);
  // expected-error@-1 {{static_cast from 'const volatile void *' to 'const int *' casts away qualifiers}}
  const volatile int *cvq = static_cast<const volatile int*>(p);
  const volatile int *cvqc = static_cast<const volatile int*>(cp);
  const volatile int *cvqv = static_cast<const volatile int*>(vp);
  const volatile int *cvqcv = static_cast<const volatile int*>(cvp);
}

namespace cwg139 { // cwg139: yes
  namespace example1 {
    typedef int f; // #cwg139-typedef-f
    struct A {
      friend void f(A &);
      // expected-error@-1 {{redefinition of 'f' as different kind of symbol}}
      //   expected-note@#cwg139-typedef-f {{previous definition is here}}
    };
  }

  namespace example2 {
    typedef int f;
    namespace N {
      struct A {
        friend void f(A &);
        operator int();
        void g(A a) { int i = f(a); } // ok, f is typedef not friend function
      };
    }
  }
}

namespace cwg140 { // cwg140: yes
  void f(int *const) {} // #cwg140-f-first
  void f(int[3]) {}
  // expected-error@-1 {{redefinition of 'f'}}
  //   expected-note@#cwg140-f-first {{previous definition is here}}
  void g(const int);
  void g(int n) { n = 2; }
}

namespace cwg141 { // cwg141: 3.1
  template<typename T> void f();
  template<typename T> struct S { int n; }; // #cwg141-S
  struct A : S<int> {
    template<typename T> void f();
    template<typename T> struct S {}; // #cwg141-A-S
  } a;
  struct B : S<int> {} b;
  void g() {
    a.f<int>();
    (void)a.S<int>::n; // #cwg141-a
    // cxx98-error@#cwg141-a {{lookup of 'S' in member access expression is ambiguous; using member of 'struct A'}}
    //   cxx98-note@#cwg141-A-S {{lookup in the object type 'struct A' refers here}}
    //   cxx98-note@#cwg141-S {{lookup from the current scope refers here}}
    // expected-error@#cwg141-a {{no member named 'n' in 'cwg141::A::S<int>'; did you mean '::cwg141::S<int>::n'?}}
    //   expected-note@#cwg141-S {{'::cwg141::S<int>::n' declared here}}
    // FIXME: we issue a useful diagnostic first, then some bogus ones.
    b.f<int>();
    // expected-error@-1 {{no member named 'f' in 'cwg141::B'}}
    // expected-error@-2 +{{}}
    (void)b.S<int>::n;
  }
  template<typename T> struct C {
    T t;
    void g() {
      t.f<int>();
      // expected-error@-1 {{use 'template' keyword to treat 'f' as a dependent template name}}
    }
    void h() {
      (void)t.S<int>::n; // ok
    }
    void i() {
      (void)t.S<int>(); // ok!
    }
  };
  void h() { C<B>().h(); } // ok
  struct X {
    template<typename T> void S();
  };
  void i() { C<X>().i(); } // ok!!
}

namespace cwg142 { // cwg142: 2.8
  class B { // #cwg142-B
  public:
    int mi; // #cwg142-B-mi
    static int si; // #cwg142-B-si
  };
  class D : private B { // #cwg142-D
  };
  class DD : public D {
    void f();
  };
  void DD::f() {
    mi = 3;
    // expected-error@-1 {{'mi' is a private member of 'cwg142::B'}}
    //   expected-note@#cwg142-D {{constrained by private inheritance here}}
    //   expected-note@#cwg142-B-mi {{member is declared here}}
    si = 3;
    // expected-error@-1 {{'si' is a private member of 'cwg142::B'}}
    //   expected-note@#cwg142-D {{constrained by private inheritance here}}
    //   expected-note@#cwg142-B-si {{member is declared here}}
    B b_old;
    // expected-error@-1 {{'B' is a private member of 'cwg142::B'}}
    //   expected-note@#cwg142-D {{constrained by private inheritance here}}
    //   expected-note@#cwg142-B {{member is declared here}}
    cwg142::B b;
    b.mi = 3;
    b.si = 3;
    B::si = 3;
    // expected-error@-1 {{'B' is a private member of 'cwg142::B'}}
    //   expected-note@#cwg142-D {{constrained by private inheritance here}}
    //   expected-note@#cwg142-B {{member is declared here}}
    cwg142::B::si = 3;
    B *bp1_old = this; // #cwg142-bp1_old
    // expected-error@#cwg142-bp1_old {{'B' is a private member of 'cwg142::B'}}
    //   expected-note@#cwg142-D {{constrained by private inheritance here}}
    //   expected-note@#cwg142-B {{member is declared here}}
    // expected-error@#cwg142-bp1_old {{cannot cast 'cwg142::DD' to its private base class 'B'}}
    //   expected-note@#cwg142-D {{declared private here}}
    cwg142::B *bp1 = this;
    // expected-error@-1 {{cannot cast 'cwg142::DD' to its private base class 'cwg142::B'}}
    //   expected-note@#cwg142-D {{declared private here}}
    B *bp2_old = (B*)this; // #cwg142-bp2_old
    // expected-error@#cwg142-bp2_old {{'B' is a private member of 'cwg142::B'}}
    //   expected-note@#cwg142-D {{constrained by private inheritance here}}
    //   expected-note@#cwg142-B {{member is declared here}}
    // expected-error@#cwg142-bp2_old {{'B' is a private member of 'cwg142::B'}}
    //   expected-note@#cwg142-D {{constrained by private inheritance here}}
    //   expected-note@#cwg142-B {{member is declared here}}
    cwg142::B *bp2 = (cwg142::B*)this;
    bp2->mi = 3;
  }
}

namespace cwg143 { // cwg143: yes
  namespace A { struct X; }
  namespace B { void f(A::X); }
  namespace A {
    struct X { friend void B::f(X); };
  }
  void g(A::X x) {
    f(x);
    // expected-error@-1 {{use of undeclared identifier 'f'}}
  }
}

namespace cwg145 { // cwg145: yes
  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 {{ISO 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 {{ISO C++17 does not allow incrementing expression of type bool}}
  }
}

namespace cwg147 { // cwg147: yes
  namespace example1 {
    template<typename> struct A {
      template<typename T> A(T);
    };
    // Per core issue 1435, this is ill-formed because A<int>::A<int> does not
    // name the injected-class-name. (A<int>::A does, though.)
    template<> template<> A<int>::A<int>(int) {}
    // expected-error@-1 {{out-of-line constructor for 'A' cannot have template arguments}}
    template<> template<> A<float>::A(float) {}
  }
  namespace example2 {
    struct A { A(); };
    struct B : A { B(); };
    A::A a1;
    // expected-error@-1 {{qualified reference to 'A' is a constructor name rather than a type in this context}}
    B::A a2;
  }
  namespace example3 {
    template<typename> struct A {
      template<typename T> A(T);
      static A a;
    };
    template<> A<int>::A<int>(A<int>::a);
    // expected-error@-1 {{qualified reference to 'A' is a constructor name rather than a template name in this context}}
  }
}

namespace cwg148 { // cwg148: yes
  struct A { int A::*p; };
  static_assert(__is_pod(int(A::*)), "");
  static_assert(__is_pod(A), "");
}

// cwg149: na

namespace cwg150 { // cwg150: 19
  namespace p1 {
    template <class T, class U = int>
    class ARG { };

    template <class X, template <class Y> class PARM>
    void f(PARM<X>) { }

    void g() {
      ARG<int> x;
      f(x);
    }
  } // namespace p1

  namespace p2 {
    template <template <class T, class U = int> class PARM>
    class C {
      PARM<int> pi;
    };
  } // namespace p2

  namespace n1 {
    struct Dense { static const unsigned int dim = 1; };

    template <template <typename> class View,
              typename Block>
    void operator+(float, View<Block> const&);

    template <typename Block,
              unsigned int Dim = Block::dim>
    class Lvalue_proxy { operator float() const; };

    void test_1d (void) {
      Lvalue_proxy<Dense> p;
      float b;
      b + p;
    }
  } // namespace n1
}

namespace cwg151 { // cwg151: 3.1
  struct X {};
  typedef int X::*p;
  static_assert(__enable_constant_folding(p() == 0), "");
}

namespace cwg152 { // cwg152: yes
  struct A {
    A(); // #cwg152-A-ctor
    explicit A(const A&); // #cwg152-A-explicit-ctor
  };
  A a1 = A();
  // cxx98-14-error@-1 {{no matching constructor for initialization of 'A'}}
  //   cxx98-14-note@#cwg152-A-explicit-ctor {{explicit constructor is not a candidate}}
  //   cxx98-14-note@#cwg152-A-ctor {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
  A a2((A()));

  A &f();
  A a3 = f();
  // expected-error@-1 {{no matching constructor for initialization of 'A'}}
  //   expected-note@#cwg152-A-explicit-ctor {{explicit constructor is not a candidate}}
  //   expected-note@#cwg152-A-ctor {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
  A a4(f());
}

// cwg153: na

namespace cwg154 { // cwg154: yes
  union { int a; };
  // expected-error@-1 {{nonymous unions at namespace or global scope must be declared 'static'}}
  namespace {
    union { int b; };
  }
  static union { int c; };
}

namespace cwg155 { // cwg155: dup 632
  struct S { int n; } s = { { 1 } };
  // expected-warning@-1 {{braces around scalar initializer}}
}

// cwg158 is in cwg158.cpp

namespace cwg159 { // cwg159: 3.5
  namespace X { void f(); }
  void f();
  void cwg159::f() {}
  // expected-warning@-1 {{extra qualification on member 'f'}}
  void cwg159::X::f() {}
}

// cwg160: na

namespace cwg161 { // cwg161: 3.1
  class A {
  protected:
    struct B { int n; } b; // #cwg161-B
    static B bs;
    void f(); // #cwg161-f
    static void sf();
  };
  struct C : A {};
  struct D : A {
    void g(C c) {
      (void)b.n;
      B b1;
      C::B b2; // ok, accessible as a member of A
      (void)&C::b;
      // expected-error@-1 {{'b' is a protected member of 'cwg161::A'}}
      //   expected-note@#cwg161-B {{declared protected here}}
      (void)&C::bs;
      (void)c.b;
      // expected-error@-1 {{'b' is a protected member of 'cwg161::A'}}
      //   expected-note@#cwg161-B {{declared protected here}}
      (void)c.bs;
      f();
      sf();
      c.f();
      // expected-error@-1 {{protected}}
      //   expected-note@#cwg161-f {{declared protected here}}
      c.sf();
      A::f();
      D::f();
      A::sf();
      C::sf();
      D::sf();
    }
  };
}

namespace cwg162 { // cwg162: 19
  struct A {
    char &f(char);
    static int &f(int);

    void g() {
      int &a = (&A::f)(0);
      char &b = (&A::f)('0');
      // expected-error@-1 {{non-const lvalue reference to type 'char' cannot bind to a value of unrelated type 'int'}}
    }
  };

  int &c = (&A::f)(0);
  char &d = (&A::f)('0');
  // expected-error@-1 {{non-const lvalue reference to type 'char' cannot bind to a value of unrelated type 'int'}}
}

// cwg163: na

namespace cwg164 { // cwg164: yes
  void f(int);
  template <class T> int g(T t) { return f(t); }

  enum E { e };
  int f(E);

  int k = g(e);
}

namespace cwg165 { // cwg165: no
  namespace N {
    struct A { friend struct B; };
    void f() { void g(); }
  }
  // FIXME: cwg1477 says this is ok, cwg165 says it's ill-formed
  struct N::B {};
  // FIXME: cwg165 says this is ill-formed, but the argument in cwg1477 says it's ok
  void N::g() {}
}

namespace cwg166 { // cwg166: 2.9
  namespace A { class X; }

  template<typename T> int f(T t) { return t.n; }
  int g(A::X);
  template<typename T> int h(T t) { return t.n; }
  // expected-error@-1 {{'n' is a private member of 'cwg166::A::X'}}
  //   expected-note@#cwg166-h-instantiation {{in instantiation of function template specialization 'cwg166::h<cwg166::A::X>' requested here}}
  //   expected-note@#cwg166-X-n {{implicitly declared private here}}
  int i(A::X);

  namespace A {
    class X {
      friend int f<X>(X);
      friend int cwg166::g(X);
      friend int h(X);
      friend int i(X);
      int n; // #cwg166-X-n
    };

    int h(X x) { return x.n; }
    int i(X x) { return x.n; }
  }

  template int f(A::X);
  int g(A::X x) { return x.n; }
  template int h(A::X); // #cwg166-h-instantiation
  int i(A::X x) { return x.n; }
  // expected-error@-1 {{'n' is a private member of 'cwg166::A::X'}}
  //   expected-note@#cwg166-X-n {{implicitly declared private here}}
}

// cwg167: sup 1012

namespace cwg168 { // cwg168: no
  extern "C" typedef int (*p)();
  extern "C++" typedef int (*q)();
  struct S {
    static int f();
  };
  p a = &S::f; // FIXME: this should fail.
  q b = &S::f;
}

namespace cwg169 { // cwg169: yes
  template<typename> struct A { int n; };
  struct B {
    template<typename> struct C;
    template<typename> void f();
    template<typename> static int n;
    // cxx98-11-error@-1 {{variable templates are a C++14 extension}}
  };
  struct D : A<int>, B {
    using A<int>::n;
    using B::C<int>;
    // expected-error@-1 {{using declaration cannot refer to a template specialization}}
    using B::f<int>;
    // expected-error@-1 {{using declaration cannot refer to a template specialization}}
    using B::n<int>;
    // expected-error@-1 {{using declaration cannot refer to a template specialization}}
  };
}

namespace { // cwg171: 3.4
  int cwg171a;
}
int cwg171b; // #cwg171b-int
namespace cwg171 {
  extern "C" void cwg171a();
  extern "C" void cwg171b();
  // expected-error@-1 {{declaration of 'cwg171b' with C language linkage conflicts with declaration in global scope}}
  //   expected-note@#cwg171b-int {{declared in global scope here}}
}

namespace cwg172 { // cwg172: yes
  enum { zero };
  static_assert(-1 < zero, "");

  enum { x = -1, y = (unsigned int)-1 };
  static_assert(sizeof(x) > sizeof(int), "");

  enum { a = (unsigned int)-1 / 2 };
  static_assert(sizeof(a) == sizeof(int), "");
  static_assert(-a < 0, "");

  enum { b = (unsigned int)-1 / 2 + 1 };
  static_assert(sizeof(b) == sizeof(unsigned int), "");
  static_assert(-b > 0, "");

  enum { c = (unsigned long)-1 / 2 };
  static_assert(sizeof(c) == sizeof(long), "");
  static_assert(-c < 0, "");

  enum { d = (unsigned long)-1 / 2 + 1 };
  static_assert(sizeof(d) == sizeof(unsigned long), "");
  static_assert(-d > 0, "");

  enum { e = (unsigned long long)-1 / 2 };
  // cxx98-error@-1 {{'long long' is a C++11 extension}}
  static_assert(sizeof(e) == sizeof(long), "");
  static_assert(-e < 0, "");

  enum { f = (unsigned long long)-1 / 2 + 1 };
  // cxx98-error@-1 {{'long long' is a C++11 extension}}
  static_assert(sizeof(f) == sizeof(unsigned long), "");
  static_assert(-f > 0, "");
}

namespace cwg173 { // cwg173: yes
  static_assert('0' + 1 == '1' && '0' + 2 == '2' && '0' + 3 == '3' &&
                '0' + 4 == '4' && '0' + 5 == '5' && '0' + 6 == '6' &&
                '0' + 7 == '7' && '0' + 8 == '8' && '0' + 9 == '9', "");
}

// cwg174: sup 1012

namespace cwg175 { // cwg175: 2.8
  struct A {}; // #cwg175-A
  struct B : private A {}; // #cwg175-B
  struct C : B {
    A a;
    // expected-error@-1 {{'A' is a private member of 'cwg175::A'}}
    //   expected-note@#cwg175-B {{constrained by private inheritance here}}
    //   expected-note@#cwg175-A {{member is declared here}}
    cwg175::A b;
  };
}

namespace cwg176 { // cwg176: 3.1
  template<typename T> class Y;
  template<> class Y<int> {
    void f() {
      typedef Y A; // #cwg176-A-first
      typedef Y<char> A;
      // expected-error@-1 {{typedef redefinition with different types ('Y<char>' vs 'Y<int>')}}
      //   expected-note@#cwg176-A-first {{previous definition is here}}
    }
  };

  template<typename T> struct Base {}; // #cwg176-Base
  template<typename T> struct Derived : public Base<T> {
    void f() {
      typedef typename Derived::template Base<T> A;
      typedef typename Derived::Base A;
    }
  };
  template struct Derived<int>;

  template<typename T> struct Derived2 : Base<int>, Base<char> {
    typename Derived2::Base b;
    // expected-error@-1 {{member 'Base' found in multiple base classes of different types}}
    //   expected-note@#cwg176-Base {{member type 'cwg176::Base<int>' found by ambiguous name lookup}}
    //   expected-note@#cwg176-Base {{member type 'cwg176::Base<char>' found by ambiguous name lookup}}
    typename Derived2::Base<double> d;
  };

  template<typename T> class X { // #cwg176-X
    X *p1;
    X<T> *p2;
    X<int> *p3;
    cwg176::X *p4; // #cwg176-p4
    // cxx98-14-error@#cwg176-p4 {{use of class template 'cwg176::X' requires template arguments}}
    //  cxx98-14-note@#cwg176-X {{template is declared here}}
    // since-cxx17-error@#cwg176-p4 {{use of class template 'cwg176::X' requires template arguments; argument deduction not allowed in non-static class member}}
    //  since-cxx17-note@#cwg176-X {{template is declared here}}
  };
}

namespace cwg177 { // cwg177: yes
  struct B {};
  struct A {
    A(A &); // #cwg177-A-copy-ctor
    A(const B &); // #cwg177-A-ctor-from-B
  };
  B b;
  A a = b;
  // cxx98-14-error@-1 {{no viable constructor copying variable of type 'A'}}
  //   cxx98-14-note@#cwg177-A-copy-ctor {{candidate constructor not viable: expects an lvalue for 1st argument}}
  //   cxx98-14-note@#cwg177-A-ctor-from-B {{candidate constructor not viable: no known conversion from 'A' to 'const B &' for 1st argument}}

  struct C { C(C&); }; // #cwg177-C-copy-ctor
  struct D : C {};
  struct E { operator D(); };
  E e;
  C c = e;
  // expected-error@-1 {{no viable constructor copying variable of type 'D'}}
  //   expected-note@#cwg177-C-copy-ctor {{candidate constructor not viable: expects an lvalue for 1st argument}}
}

namespace cwg178 { // cwg178: yes
  static_assert(int() == 0, "");
#if __cplusplus >= 201103L
  static_assert(int{} == 0, "");
  struct S { int a, b; };
  static_assert(S{1}.b == 0, "");
  struct T { constexpr T() : n() {} int n; };
  static_assert(T().n == 0, "");
  struct U : S { constexpr U() : S() {} };
  static_assert(U().b == 0, "");
#endif
}

namespace cwg179 { // cwg179: yes
  void f();
  int n = &f - &f;
  // expected-error@-1 {{arithmetic on pointers to the function type 'void ()'}}
}

namespace cwg180 { // cwg180: 2.8
  template<typename T> struct X : T, T::some_base {
    X() : T::some_type_that_might_be_T(), T::some_base() {}
    friend class T::some_class;
    void f() {
      enum T::some_enum e;
    }
  };
}

namespace cwg181 { // cwg181: yes
  namespace X {
    template <template X<class T> > struct A { };
    // expected-error@-1 +{{}}
    template <template X<class T> > void f(A<X>) { }
    // expected-error@-1 +{{}}
  }

  namespace Y {
    template <template <class T> class X> struct A { };
    template <template <class T> class X> void f(A<X>) { }
  }
}

namespace cwg182 { // cwg182: 14
  template <class T> struct C {
    void f();
    void g();
  };

  template <class T> void C<T>::f() {}
  template <class T> void C<T>::g() {}

  class A {
    class B {};
    void f();
  };

  template void C<A::B>::f();
  template <> void C<A::B>::g();

  void A::f() {
    C<B> cb;
    cb.f();
  }
}

namespace cwg183 { // cwg183: sup 382
  template<typename T> struct A {};
  template<typename T> struct B {
    typedef int X;
  };
  template<> struct A<int> {
    typename B<int>::X x;
    // cxx98-error@-1 {{'typename' occurs outside of a template}}
  };
}

namespace cwg184 { // cwg184: yes
  template<typename T = float> struct B {};

  template<template<typename TT = float> class T> struct A {
    void f();
    void g();
  };

  template<template<typename TT> class T> void A<T>::f() { // #cwg184-T
    T<> t;
    // expected-error@-1 {{too few template arguments for template template parameter 'T'}}
    //   expected-note@#cwg184-T {{template is declared here}}
  }

  template<template<typename TT = char> class T> void A<T>::g() {
    T<> t;
    typedef T<> X;
    typedef T<char> X;
  }

  void h() { A<B>().g(); }
}

// cwg185 is in cwg185.cpp

namespace cwg187 { // cwg187: sup 481
  const int Z = 1;
  template<int X = Z, int Z = X> struct A;
  typedef A<> T;
  typedef A<1, 1> T;
}

namespace cwg188 { // cwg188: yes
  char c[10];
  static_assert(sizeof(0, c) == 10, "");
}

// cwg190 FIXME: add codegen test for tbaa
//              or implement C++20 std::is_layout_compatible and test it this way

int cwg191_j;
namespace cwg191 { // cwg191: yes
  namespace example1 {
    struct outer {
      static int i;
      struct inner {
        void f() {
          struct local {
            void g() {
              i = 5;
            }
          };
        }
      };
    };
  }

  namespace example2 {
    struct S {
      void f() {
        struct local2 {
          void g() {
            cwg191_j = 5;
          }
        };
      }
    };
  }
}

// cwg193 is in cwg193.cpp

namespace cwg194 { // cwg194: yes
  struct A {
    A();
    void A();
    // expected-error@-1 {{constructor cannot have a return type}}
  };
  struct B {
    void B();
    // expected-error@-1 {{constructor cannot have a return type}}
    B();
  };
  struct C {
    inline explicit C(int) {}
  };
}

namespace cwg195 { // cwg195: yes
  void f();
  int *p = (int*)&f;
  // cxx98-error@-1 {{cast between pointer-to-function and pointer-to-object is an extension}}
  void (*q)() = (void(*)())&p;
  // cxx98-error@-1 {{cast between pointer-to-function and pointer-to-object is an extension}}
}

namespace cwg197 { // cwg197: yes
  char &f(char);

  template <class T> void g(T t) {
    char &a = f(1);
    char &b = f(T(1));
    // expected-error@-1 {{non-const lvalue reference to type 'char' cannot bind to a value of unrelated type 'int'}}
    //   expected-note@#cwg197-g-e-call {{in instantiation of function template specialization 'cwg197::g<cwg197::E>' requested here}}
    char &c = f(t);
    // expected-error@-1 {{non-const lvalue reference to type 'char' cannot bind to a value of unrelated type 'int'}}
  }

  void f(int);

  enum E { e };
  int &f(E);

  void h() {
    g('a');
    g(2);
    g(e); // #cwg197-g-e-call
  }
}

namespace cwg198 { // cwg198: yes
  struct A {
    int n;
    struct B {
      int m[sizeof(n)];
      // cxx98-error@-1 {{invalid use of non-static data member 'n'}}
      int f() { return n; }
      // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'B'}}
    };
    struct C;
    struct D;
  };
  struct A::C {
    int m[sizeof(n)];
    // cxx98-error@-1 {{invalid use of non-static data member 'n'}}
    int f() { return n; }
    // expected-error@-1 {{use of non-static data member 'n' of 'A' from nested type 'C'}}
  };
  struct A::D : A {
    int m[sizeof(n)];
    // cxx98-error@-1 {{invalid use of non-static data member 'n'}}
    int f() { return n; }
  };
}

// cwg199 is in cwg199.cpp