1 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
8 // FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
9 __extension__
typedef __SIZE_TYPE__
size_t;
11 namespace std
{ struct type_info
; }
13 namespace dr400
{ // dr400: yes
14 struct A
{ int a
; struct a
{}; }; // expected-note 2{{conflicting}} expected-note {{ambiguous}}
15 struct B
{ int a
; struct a
{}; }; // expected-note 2{{target}} expected-note {{ambiguous}}
16 struct C
: A
, B
{ using A::a
; struct a b
; };
17 struct D
: A
, B
{ using A::a
; using B::a
; struct a b
; }; // expected-error 2{{conflicts}}
18 struct E
: A
, B
{ struct a b
; }; // expected-error {{found in multiple base classes}}
21 namespace dr401
{ // dr401: yes
22 template<class T
, class U
= typename
T::type
> class A
: public T
{}; // expected-error {{protected}} expected-error 2{{private}}
26 typedef int type
; // expected-note {{protected}}
27 #if __cplusplus == 199711L
28 // expected-note@-2 {{protected}}
33 typedef int type
; // expected-note {{private}}
34 friend class A
<C
>; // expected-note {{default argument}}
38 typedef int type
; // expected-note {{private}}
39 friend class A
<D
, int>;
42 A
<B
> *b
; // expected-note {{default argument}}
43 A
<D
> *d
; // expected-note {{in instantiation of default argument}}
46 template<class T
, class U
= typename
T::type
> class A
: public T
{};
52 E::A
<F
> eaf
; // ok, default argument is in befriended context
54 // FIXME: Why do we get different diagnostics in C++11 onwards here? We seem
55 // to not treat the default template argument as a SFINAE context in C++98.
56 template<class T
, class U
= typename
T::type
> void f(T
) {}
58 #if __cplusplus < 201103L
59 // expected-error@-3 0-1{{extension}} expected-error@-3 {{protected}} expected-note@-3 {{instantiation}}
60 // expected-note@-3 {{substituting}}
62 // expected-error@-5 {{no matching}} expected-note@-6 {{protected}}
66 namespace dr403
{ // dr403: yes
71 template<typename T
> struct X
{};
72 typedef struct X
<A::S
>::X XS
;
74 int k
= f(p
); // ok, finds A::f, even though type XS is a typedef-name
75 // referring to an elaborated-type-specifier naming a
76 // injected-class-name, which is about as far from a
77 // template-id as we can make it.
83 namespace dr405
{ // dr405: yes
96 void test1(A::S as
) { f(as
); } // expected-error {{called object type 'int'}}
97 void test2(A::S as
) { void f(); f(as
); } // expected-error {{too many arguments}} expected-note {{}}
98 void test3(A::S as
) { using A::f
; f(as
); } // ok
99 void test4(A::S as
) { using B::f
; f(as
); } // ok
100 void test5(A::S as
) { int f
; f(as
); } // expected-error {{called object type 'int'}}
101 void test6(A::S as
) { struct f
{}; (void) f(as
); } // expected-error {{no matching conversion}} expected-note +{{}}
106 struct X
{ void operator()(S
); } f
;
108 void testD(D::S ds
) { f(ds
); } // expected-error {{undeclared identifier}}
114 void testE(E::S es
) { f(es
); } // expected-error {{undeclared identifier}}
117 namespace dr406
{ // dr406: yes
119 static int n
; // expected-error {{static data member 'n' not allowed in anonymous struct}}
122 static int n
; // expected-error {{static data member 'n' not allowed in anonymous union}}
126 namespace dr407
{ // dr407: 3.8
127 // NB: reused by dr1894 and dr2199
133 typedef struct S S
; // expected-note {{here}}
134 struct S
*p
; // expected-error {{typedef 'S' cannot be referenced with a struct specifier}}
141 struct S
{}; // expected-note {{found}}
144 typedef int S
; // expected-note {{found}}
149 struct S s
; // expected-error {{ambiguous}}
157 // The standard doesn't say whether this is valid. We interpret
158 // DR407 as meaning "if lookup finds both a tag and a typedef with the
159 // same type, then it's OK in an elaborated-type-specifier".
167 // The standard doesn't say what to do in these cases either.
181 namespace dr408
{ // dr408: 3.4
182 template<int N
> void g() { int arr
[N
!= 1 ? 1 : -1]; }
183 template<> void g
<2>() { }
185 template<typename T
> struct S
{
189 template<typename T
> int S
<T
>::i
[] = { 1 };
191 template<typename T
> void S
<T
>::f() {
192 g
<sizeof (i
) / sizeof (int)>();
194 template<> int S
<int>::i
[] = { 1, 2 };
195 template void S
<int>::f(); // uses g<2>(), not g<1>().
198 template<typename T
> struct R
{
202 template<typename T
> int R
<T
>::arr
[1];
203 template<typename T
> void R
<T
>::f() {
204 int arr
[sizeof(arr
) != sizeof(int) ? 1 : -1];
206 template<> int R
<int>::arr
[2];
207 template void R
<int>::f();
210 namespace dr409
{ // dr409: yes
211 template<typename T
> struct A
{
217 #if __cplusplus <= 201703L
218 // expected-error@-2 {{implicit 'typename' is a C++20 extension}}
223 namespace dr410
{ // dr410: no
224 template<class T
> void f(T
);
227 template<class T
> void h(T
);
228 template<class T
> void i(T
);
230 friend void f
<>(int);
231 friend void h
<>(int);
233 template<class T
> void i(T
);
234 friend void i
<>(int);
236 static void z(); // expected-note {{private}}
239 template<> void h(int) { A::z(); }
240 // FIXME: This should be ill-formed. The member A::i<> is befriended,
241 // not this function.
242 template<> void i(int) { A::z(); }
244 template<> void f(int) { M::A::z(); }
245 void g(int) { M::A::z(); } // expected-error {{private}}
248 // dr412 is in its own file.
250 namespace dr413
{ // dr413: yes
256 S s
= { 1, 2, 3 }; // expected-error {{excess elements}}
259 struct T
{ // expected-note {{here}}
265 T t2
= { 1, 2 }; // expected-error {{aggregate with no elements requires explicit braces}}
268 namespace dr414
{ // dr414: dup 305
277 namespace dr415
{ // dr415: yes
278 template<typename T
> void f(T
, ...) { T::error
; }
280 void g() { f(0, 0); } // ok
283 namespace dr416
{ // dr416: yes
285 int &operator+(const A
&, const A
&);
287 struct A
{ float &operator+(A
&); };
291 namespace dr417
{ // dr417: no
293 struct dr417::A
{}; // expected-warning {{extra qualification}}
294 struct B
{ struct X
; };
296 struct C::X
{}; // expected-error {{no struct named 'X' in 'dr417::C'}}
297 struct B::X
{ struct Y
; };
298 struct C::X::Y
{}; // ok!
305 // FIXME: This is ill-formed.
307 struct dr417::D
{}; // expected-warning {{extra qualification}}
309 struct dr417::E
{}; // expected-warning {{extra qualification}} expected-error {{no struct named 'E'}}
314 struct dr417::G
{}; // expected-error {{namespace 'M' does not enclose}}
315 struct dr417::H
{}; // expected-error {{namespace 'M' does not enclose}}
319 namespace dr418
{ // dr418: no
321 void f1(int, int = 0);
322 void f1(int = 0, int);
325 } // namespace example1
329 void f2(int); // #dr418-f2-decl
339 f2(); // expected-error {{no matching function}}
340 // expected-note@#dr418-f2-decl {{requires 1 argument}}
342 } // namespace example2
344 // example from [over.match.best]/4
347 extern "C" void f(int = 5);
350 extern "C" void f(int = 5);
358 f(); // FIXME: this should fail
360 } // namespace example3
363 namespace dr420
{ // dr420: yes
364 template<typename T
> struct ptr
{
365 T
*operator->() const;
366 T
&operator*() const;
368 template<typename T
, typename P
> void test(P p
) {
375 template void test
<int>(int*);
376 template void test
<int>(ptr
<int>);
377 template void test
<X
>(X
*);
378 template void test
<X
>(ptr
<X
>);
382 p
->template Y
<int>::~Y
<int>();
384 p
->template ~Y
<int>(); // expected-error {{'template' keyword not permitted in destructor name}}
386 template<typename T
> struct Y
{};
387 template void test2(Y
<int>*);
388 template void test2(ptr
<Y
<int> >);
390 void test3(int *p
, ptr
<int> q
) {
398 #if __cplusplus >= 201103L
399 template<typename T
> using id
= T
;
400 struct A
{ template<typename T
> using id
= T
; };
401 void test4(int *p
, ptr
<int> q
) {
404 p
->id
<int>::~id
<int>();
405 q
->id
<int>::~id
<int>();
406 p
->template id
<int>::~id
<int>(); // OK since dr2292
407 q
->template id
<int>::~id
<int>(); // OK since dr2292
408 p
->A::template id
<int>::~id
<int>();
409 q
->A::template id
<int>::~id
<int>();
414 namespace dr421
{ // dr421: yes
415 struct X
{ X(); int n
; int &r
; };
416 int *p
= &X().n
; // expected-error-re {{{{taking the address of a temporary|cannot take the address of an rvalue}}}}
420 namespace dr422
{ // dr422: yes
421 template<typename T
, typename U
> void f() {
422 typedef T type
; // expected-note {{prev}}
423 typedef U type
; // expected-error {{redef}}
425 template void f
<int, int>();
426 template void f
<int, char>(); // expected-note {{instantiation}}
429 namespace dr423
{ // dr423: yes
430 template<typename T
> struct X
{ operator T
&(); };
431 void f(X
<int> x
) { x
+= 1; }
434 namespace dr424
{ // dr424: yes
436 typedef int N
; // expected-note {{previous}}
437 typedef int N
; // expected-error {{redefinition}}
440 typedef X X
; // expected-note {{previous}}
447 typedef X X
; // expected-error {{redefinition}}
453 typedef int N
; // expected-note {{previous}}
454 typedef int N
; // expected-error {{redefinition}}
458 namespace dr425
{ // dr425: yes
459 struct A
{ template<typename T
> operator T() const; } a
;
460 float f
= 1.0f
* a
; // expected-error {{ambiguous}} expected-note 5+{{built-in candidate}}
462 template<typename T
> struct is_float
;
463 template<> struct is_float
<float> { typedef void type
; };
466 template<typename T
, typename U
= typename is_float
<T
>::type
> operator T() const; // expected-error 0-1{{extension}}
468 float g
= 1.0f
* b
; // ok
471 namespace dr427
{ // dr427: yes
473 struct D
: public B
{
474 D(B
&) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}}
479 const D
&d2
= static_cast<const D
&>(b
);
480 const D
&d3
= (const D
&)b
;
481 const D
&d4(b
); // expected-error {{deleted}}
484 namespace dr428
{ // dr428: yes
485 template<typename T
> T
make();
486 extern struct X x
; // expected-note 5{{forward declaration}}
488 throw void(); // expected-error {{cannot throw}}
490 throw make
<const volatile void*>();
491 throw x
; // expected-error {{cannot throw}}
492 throw make
<X
&>(); // expected-error {{cannot throw}}
493 throw make
<X
*>(); // expected-error {{cannot throw}}
494 throw make
<const volatile X
&>(); // expected-error {{cannot throw}}
495 throw make
<const volatile X
*>(); // expected-error {{cannot throw}}
499 namespace dr429
{ // dr429: yes c++11
500 // FIXME: This rule is obviously intended to apply to C++98 as well.
502 static void *operator new(size_t, size_t);
503 static void operator delete(void*, size_t);
505 #if __cplusplus >= 201103L
506 // expected-error@-2 {{'new' expression with placement arguments refers to non-placement 'operator delete'}}
507 // expected-note@-4 {{here}}
510 static void *operator new(size_t, size_t);
511 static void operator delete(void*);
512 static void operator delete(void*, size_t);
513 } *b
= new (0) B
; // ok, second delete is not a non-placement deallocation function
516 namespace dr430
{ // dr430: yes c++11
518 // FIXME: This should apply in C++98 too.
520 int a
[] = { n
++, n
++, n
++ };
521 #if __cplusplus < 201103L
522 // expected-warning@-2 {{multiple unsequenced modifications to 'n'}}
527 namespace dr431
{ // dr431: yes
529 template<typename T
> T
*get();
530 template<typename T
> struct B
{
531 template<typename U
> U
*get();
535 template<typename T
> void f(A a
) {
536 a
.get
<A
>()->get
<T
>();
538 ->get
<T
>(); // expected-error {{use 'template'}}
539 a
.get
<T
>()->template get
<T
>();
541 A::B
<int> *b
= a
.get
<A::B
<int> >();
543 b
->A::B
<int>::get
<int>();
544 b
->A::B
<int>::get
<T
>();
545 b
->A::B
<T
>::get
<int>(); // expected-error {{use 'template'}}
546 b
->A::B
<T
>::template get
<int>();
547 b
->A::B
<T
>::get
<T
>(); // expected-error {{use 'template'}}
548 b
->A::B
<T
>::template get
<T
>();
549 A::B
<T
> *c
= a
.get
<A::B
<T
> >();
550 c
->get
<int>(); // expected-error {{use 'template'}}
551 c
->template get
<int>();
555 namespace dr432
{ // dr432: yes
556 template<typename T
> struct A
{};
557 template<typename T
> struct B
: A
<B
> {}; // expected-error {{requires template arguments}} expected-note {{declared}}
558 template<typename T
> struct C
: A
<C
<T
> > {};
559 #if __cplusplus >= 201103L
560 template<typename T
> struct D
: decltype(A
<D
>()) {}; // expected-error {{requires template arguments}} expected-note {{declared}}
564 namespace dr433
{ // dr433: yes
565 template<class T
> struct S
{
569 template<class T
> void S
<T
>::f(union U
*) {}
574 namespace dr434
{ // dr434: sup 2352
578 const int *&rpci
= pi
; // expected-error {{incompatible qualifiers}}
579 const int * const &rcpci
= pi
; // OK
584 #if __cplusplus >= 201103L
586 const int * const &rcpci
= pi
;
587 static_assert(&rcpci
== &pi
, "");
593 namespace dr436
{ // dr436: yes
594 enum E
{ f
}; // expected-note {{previous}}
595 void f(); // expected-error {{redefinition}}
598 namespace dr437
{ // dr437: sup 1308
599 // This is superseded by 1308, which is in turn superseded by 1330,
600 // which restores this rule.
601 template<typename U
> struct T
: U
{};
604 #if __cplusplus > 201402L
605 // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}}
607 void g() throw(T
<S
>);
608 #if __cplusplus > 201402L
609 // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}}
613 #if __cplusplus > 201402L
614 // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}}
620 // dr438 FIXME write a codegen test
621 // dr439 FIXME write a codegen test
622 // dr441 FIXME write a codegen test
626 namespace dr444
{ // dr444: yes
628 struct B
{ // expected-note {{candidate function (the implicit copy}} expected-note 0-1 {{implicit move}}
629 D
&operator=(D
&) = delete; // expected-error 0-1{{extension}} expected-note {{deleted}}
631 struct D
: B
{ // expected-note {{candidate function (the implicit copy}} expected-note 0-1 {{implicit move}}
635 d
= d
; // expected-error {{deleted}}
639 namespace dr445
{ // dr445: yes
640 class A
{ void f(); }; // expected-note {{private}}
642 friend void A::f(); // expected-error {{private}}
646 namespace dr446
{ // dr446: yes
650 A(const A
&) = delete; // expected-error 0-1{{extension}} expected-note +{{deleted}}
654 void f(A a
, bool b
, C c
) {
656 b
? A() : a
; // expected-error {{deleted}}
657 b
? a
: A(); // expected-error {{deleted}}
659 #if __cplusplus <= 201402L
660 // expected-error@-2 {{deleted}}
664 b
? a
: C(); // expected-error {{deleted}}
666 #if __cplusplus <= 201402L
667 // expected-error@-2 {{deleted}}
670 #if __cplusplus <= 201402L
671 // expected-error@-2 {{deleted}}
676 namespace dr447
{ // dr447: yes
677 struct A
{ int n
; int a
[4]; };
678 template<int> struct U
{
680 template<typename V
> static void h();
682 template<typename T
> U
<sizeof(T
)> g(T
);
683 template<typename T
, int N
> void f(int n
) {
684 // ok, not type dependent
685 g(__builtin_offsetof(A
, n
)).h
<int>();
686 g(__builtin_offsetof(T
, n
)).h
<int>();
687 // value dependent if first argument is a dependent type
688 U
<__builtin_offsetof(A
, n
)>::type a
;
689 U
<__builtin_offsetof(T
, n
)>::type b
; // expected-error +{{}} expected-warning 0+{{}}
690 // as an extension, we allow the member-designator to include array indices
691 g(__builtin_offsetof(A
, a
[0])).h
<int>();
692 g(__builtin_offsetof(A
, a
[N
])).h
<int>();
693 U
<__builtin_offsetof(A
, a
[0])>::type c
;
694 U
<__builtin_offsetof(A
, a
[N
])>::type d
; // expected-error +{{}} expected-warning 0+{{}}
698 namespace dr448
{ // dr448: yes
699 template<typename T
= int> void f(int); // expected-error 0-1{{extension}} expected-note {{no known conversion}}
700 template<typename T
> void g(T t
) {
701 f
<T
>(t
); // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
702 dr448::f(t
); // expected-error {{no matching function}}
704 template<typename T
> void f(T
); // expected-note {{should be declared prior to the call site}}
705 namespace HideFromADL
{ struct X
{}; }
706 template void g(int); // ok
707 template void g(HideFromADL::X
); // expected-note {{instantiation of}}
712 namespace dr450
{ // dr450: yes
715 void f2(A
&); // expected-note +{{not viable}}
719 f2(S().n
); // expected-error {{no match}}}
721 #if __cplusplus >= 201103L
724 f2(A
{}); // expected-error {{no match}}
729 namespace dr451
{ // dr451: yes
730 const int a
= 1 / 0; // expected-warning {{undefined}}
731 const int b
= 1 / 0; // expected-warning {{undefined}} expected-note {{here}} expected-note 0-1{{division by zero}}
732 int arr
[b
]; // expected-error +{{variable length arr}} expected-note {{initializer of 'b' is not a constant}}
735 namespace dr452
{ // dr452: yes
740 A() : a(f()), b(this->f() + a
), c(this->a
), p(this) {}
744 // dr454 FIXME write a codegen test
746 namespace dr456
{ // dr456: yes
750 #if __cplusplus >= 201103L
751 // expected-error@-2 {{cannot initialize}}
753 // expected-warning@-4 {{null}}
756 const bool f
= false;
758 #if __cplusplus >= 201103L
759 // expected-error@-2 {{cannot initialize}}
761 // expected-warning@-4 {{null}}
765 namespace dr457
{ // dr457: yes
767 const volatile int b
= 1;
769 int bx
[b
]; // expected-error +{{variable length array}} expected-note {{read of volatile}}
773 eb
= b
// expected-error {{constant}} expected-note {{read of volatile-qualified}}
777 namespace dr458
{ // dr458: 11
781 template<typename
> int g();
784 template<typename
> struct B
: A
{
786 template<typename
> int g();
787 template<typename
> int h();
793 template<typename T
> // expected-note {{declared here}}
795 return T
; // expected-error {{'T' does not refer to a value}}
802 template<typename T
> template<typename U
>
806 template<typename U
> template<typename T
> // expected-note {{declared here}}
808 return T
; // expected-error {{'T' does not refer to a value}}
812 namespace dr460
{ // dr460: yes
813 namespace X
{ namespace Q
{ int n
; } }
815 using X
; // expected-error {{requires a qualified name}}
816 using dr460::X
; // expected-error {{cannot refer to a namespace}}
817 using X::Q
; // expected-error {{cannot refer to a namespace}}
822 // dr462 FIXME write a codegen test
827 namespace dr466
{ // dr466: no
829 typedef const int CI
;
830 typedef volatile int VI
;
831 void f(int *a
, CI
*b
, VI
*c
) {
839 a
->CI::~VI(); // FIXME: This is invalid; CI and VI are not the same scalar type.
857 namespace dr467
{ // dr467: yes
864 static int k
= stuff();
870 goto later
; // expected-error {{cannot jump}}
871 int k
= stuff(); // expected-note {{bypasses variable initialization}}
877 namespace dr468
{ // dr468: yes c++11
878 // FIXME: Should we allow this in C++98 too?
879 template<typename
> struct A
{
880 template<typename
> struct B
{
884 int k
= dr468::template A
<int>::template B
<char>::C
;
885 #if __cplusplus < 201103L
886 // expected-error@-2 2{{'template' keyword outside of a template}}
890 namespace dr469
{ // dr469: no
891 template<typename T
> struct X
; // expected-note {{here}}
892 template<typename T
> struct X
<const T
> {};
893 X
<int&> x
; // expected-error {{undefined}}
896 namespace dr470
{ // dr470: yes
897 template<typename T
> struct A
{
900 template<typename T
> struct C
{
903 template struct A
<int>; // expected-note {{previous}}
904 template struct A
<int>::B
; // expected-error {{duplicate explicit instantiation}}
906 // ok, instantiating C<char> doesn't instantiate base class members.
907 template struct A
<char>;
908 template struct C
<char>;
911 namespace dr471
{ // dr471: yes
913 struct B
: private virtual A
{};
914 struct C
: protected virtual A
{};
915 struct D
: B
, C
{ int f() { return n
; } };
916 struct E
: private virtual A
{
919 struct F
: E
, B
{ int f() { return n
; } };
920 struct G
: virtual A
{
922 using A::n
; // expected-note {{here}}
924 struct H
: B
, G
{ int f() { return n
; } }; // expected-error {{private}}
927 namespace dr474
{ // dr474: yes
934 void g(); // expected-note {{previous}}
938 int g(); // expected-error {{cannot be overloaded}}
942 // dr475 FIXME write a codegen test
944 namespace dr477
{ // dr477: 3.5
950 friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}}
951 friend virtual void A::f(); // expected-error {{'virtual' is invalid in friend declarations}}
953 explicit A::A() {} // expected-error {{can only be specified inside the class definition}}
954 virtual void A::f() {} // expected-error {{can only be specified inside the class definition}}
957 namespace dr478
{ // dr478: yes
958 struct A
{ virtual void f() = 0; }; // expected-note {{unimplemented}}
960 void f(A a
[10]); // expected-error {{array of abstract class type}}
963 namespace dr479
{ // dr479: yes
967 S(const S
&); // expected-note +{{here}}
968 ~S(); // expected-note +{{here}}
972 // expected-error@-1 {{temporary of type 'S' has private destructor}}
973 // expected-error@-2 {{exception object of type 'S' has private destructor}}
974 #if __cplusplus < 201103L
975 // expected-error@-4 {{C++98 requires an accessible copy constructor}}
977 #if __cplusplus <= 201402L
978 // expected-error@-7 {{calling a private constructor}} (copy ctor)
982 S s
; // expected-error {{private destructor}}}
984 // expected-error@-1 {{calling a private constructor}}
985 // expected-error@-2 {{exception object of type 'S' has private destructor}}
992 // expected-error@-1 {{calling a private constructor}}
993 // expected-error@-2 {{variable of type 'S' has private destructor}}
998 namespace dr480
{ // dr480: yes
1001 struct C
: virtual B
{};
1005 int D::*b
= a
; // expected-error {{virtual base}}
1008 int A::*d
= static_cast<int A::*>(c
); // expected-error {{virtual base}}
1012 D
*g
= static_cast<D
*>(f
); // expected-error {{virtual base}}
1016 D
&k
= static_cast<D
&>(j
); // expected-error {{virtual base}}
1019 namespace dr481
{ // dr481: yes
1020 template<class T
, T U
> class A
{ T
*x
; };
1021 T
*x
; // expected-error {{unknown type}}
1023 template<class T
*U
> class B
{ T
*x
; };
1027 template<class T
> void f(class D
*p
);
1031 template<typename A
= C
, typename C
= A
> struct E
{
1033 typedef ::dr481::C c
; // expected-note {{previous}}
1034 typedef C c
; // expected-error {{different type}}
1037 template struct E
<>; // ok
1038 template struct E
<int>; // expected-note {{instantiation of}}
1040 template<template<typename U_no_typo_correction
> class A
,
1042 U_no_typo_correction
*C
> // expected-error {{unknown type}}
1044 U_no_typo_correction
*x
; // expected-error {{unknown type}}
1047 template<template<class H
*> class> struct G
{
1053 template<N X
, typename N
, template<N Y
> class T
> struct I
;
1054 template<char*> struct J
;
1055 I
<123, char*, J
> *j
;
1058 namespace dr482
{ // dr482: 3.5
1062 int dr482::a
= 0; // expected-warning {{extra qualification}}
1063 void dr482::f() {} // expected-warning {{extra qualification}}
1065 inline namespace X
{ // expected-error 0-1{{C++11 feature}}
1070 int dr482::b
= 0; // expected-warning {{extra qualification}}
1071 void dr482::g() {} // expected-warning {{extra qualification}}
1072 struct dr482::S
{}; // expected-warning {{extra qualification}}
1074 void dr482::f(); // expected-warning {{extra qualification}}
1075 void dr482::g(); // expected-warning {{extra qualification}}
1077 // FIXME: The following are valid in DR482's wording, but these are bugs in
1078 // the wording which we deliberately don't implement.
1079 namespace N
{ typedef int type
; }
1080 typedef int N::type
; // expected-error {{typedef declarator cannot be qualified}}
1083 struct A::B
{}; // expected-error {{extra qualification}}
1085 #if __cplusplus >= 201103L
1087 enum class A::C
{}; // expected-error {{extra qualification}}
1092 namespace dr483
{ // dr483: yes
1094 int check1
[__SCHAR_MAX__
>= 127 ? 1 : -1];
1095 int check2
[__SHRT_MAX__
>= 32767 ? 1 : -1];
1096 int check3
[__INT_MAX__
>= 32767 ? 1 : -1];
1097 int check4
[__LONG_MAX__
>= 2147483647 ? 1 : -1];
1098 int check5
[__LONG_LONG_MAX__
>= 9223372036854775807 ? 1 : -1];
1099 #if __cplusplus < 201103L
1100 // expected-error@-2 1+{{extension}}
1104 int check1
[__PTRDIFF_WIDTH__
>= 16 ? 1 : -1];
1105 int check2
[__SIG_ATOMIC_WIDTH__
>= 8 ? 1 : -1];
1106 int check3
[__SIZE_WIDTH__
>= 16 ? 1 : -1];
1107 int check4
[__WCHAR_WIDTH__
>= 8 ? 1 : -1];
1108 int check5
[__WINT_WIDTH__
>= 16 ? 1 : -1];
1112 namespace dr484
{ // dr484: yes
1127 void f() { return CA::f(); }
1131 typedef C CT
; // expected-note {{here}}
1132 struct CT
{}; // expected-error {{conflicts with typedef}}
1136 typedef D DT
; // expected-note {{here}}
1138 struct N::DT
{}; // expected-error {{conflicts with typedef}}
1141 S(); // expected-error {{a type specifier is required}}
1145 namespace dr485
{ // dr485: yes
1148 int operator+(S
, S
);
1149 template<typename T
> int f(S
);
1151 template<typename T
> int f();
1154 int a
= operator+(s
, s
);
1158 namespace dr486
{ // dr486: yes
1159 template<typename T
> T
f(T
*); // expected-note 2{{substitution failure}}
1168 f
<void()>(&g
); // expected-error {{no match}}
1169 f
<int[10]>(&n
); // expected-error {{no match}}
1173 namespace dr487
{ // dr487: yes
1175 int operator+(int, E
); // expected-note 0-1{{here}}
1176 int i
[4 + e
]; // expected-error 2{{variable length array}} expected-note 0-1{{non-constexpr}}
1179 namespace dr488
{ // dr488: yes c++11
1180 template <typename T
> void f(T
);
1183 // FIXME: It seems CWG thought this should be a SFINAE failure prior to
1184 // allowing local types as template arguments. In C++98, we should either
1185 // allow local types as template arguments or treat this as a SFINAE
1189 #if __cplusplus < 201103L
1190 // expected-error@-2 {{local type}}
1197 namespace dr490
{ // dr490: yes
1198 template<typename T
> struct X
{};
1202 struct K
{}; // expected-note {{declared}}
1207 int X
<T
>::*i(); // expected-note {{previous}}
1210 template<typename T
> T
k();
1220 friend int A::h(X
<T
>);
1222 // FIXME: Per this DR, these two are valid! That is another defect
1223 // (no number yet...) which will eventually supersede this one.
1224 friend int X
<T
>::*A::i(); // expected-error {{return type}}
1225 friend int K::*A::j(); // expected-error {{undeclared identifier 'K'; did you mean 'A::K'?}}
1227 // ok, lookup finds B::T, not A::T, so return type matches
1228 friend char A::k
<T
>();
1229 friend int A::k
<U
>();
1231 // A conversion-type-id in a conversion-function-id is always looked up in
1232 // the class of the conversion function first.
1233 friend A::operator X
<T
>();
1237 namespace dr491
{ // dr491: dup 413
1238 struct A
{} a
, b
[3] = { a
, {} };
1239 A c
[2] = { a
, {}, b
[1] }; // expected-error {{excess elements}}
1242 // dr492 FIXME write a codegen test
1244 namespace dr493
{ // dr493: dup 976
1246 template <class T
> operator const T
&() const;
1254 namespace dr494
{ // dr494: dup 372
1267 namespace dr495
{ // dr495: 3.5
1268 template<typename T
>
1270 operator int() { return T::error
; }
1271 template<typename U
> operator U();
1276 template<typename T
>
1278 template<typename U
> operator U();
1279 operator int() { return T::error
; }
1285 namespace dr496
{ // dr496: sup 2094
1286 struct A
{ int n
; };
1287 struct B
{ volatile int n
; };
1288 int check1
[ __is_trivially_copyable(const int) ? 1 : -1];
1289 // This checks the dr2094 behavior, not dr496
1290 int check2
[ __is_trivially_copyable(volatile int) ? 1 : -1];
1291 int check3
[ __is_trivially_constructible(A
, const A
&) ? 1 : -1];
1292 int check4
[ __is_trivially_constructible(B
, const B
&) ? 1 : -1];
1293 int check5
[ __is_trivially_assignable(A
, const A
&) ? 1 : -1];
1294 int check6
[ __is_trivially_assignable(B
, const B
&) ? 1 : -1];
1297 namespace dr497
{ // dr497: sup 253
1304 cs
.*pm
= 88; // expected-error {{not assignable}}
1314 cs
.*pm
= 88; // expected-error {{not assignable}}
1318 namespace dr499
{ // dr499: yes
1320 void f() { throw str
; }