1 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
2 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
3 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
4 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
5 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
6 // RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
8 // PR13819 -- __SIZE_TYPE__ is incompatible.
9 typedef __SIZE_TYPE__
size_t; // expected-error 0-1 {{extension}}
11 #if __cplusplus < 201103L
12 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
17 namespace dr200
{ // dr200: dup 214
18 template <class T
> T
f(int);
19 template <class T
, class U
> T
f(U
) = delete; // expected-error 0-1{{extension}}
26 // dr201 FIXME: write codegen test
28 namespace dr202
{ // dr202: yes
29 template<typename T
> T
f();
30 template<int (*g
)()> struct X
{
31 int arr
[fold(g
== &f
<int>) ? 1 : -1];
36 // FIXME (export) dr204: no
38 namespace dr206
{ // dr206: yes
39 struct S
; // expected-note 2{{declaration}}
40 template<typename T
> struct Q
{ S s
; }; // expected-error {{incomplete}}
41 template<typename T
> void f() { S s
; } // expected-error {{incomplete}}
44 namespace dr207
{ // dr207: yes
59 // dr208 FIXME: write codegen test
61 namespace dr209
{ // dr209: yes
63 void f(); // expected-note {{here}}
66 friend void A::f(); // expected-error {{private}}
70 // dr210 FIXME: write codegen test
72 namespace dr211
{ // dr211: yes
77 return; // expected-error {{return in the catch of a function try block of a constructor}}
82 namespace dr213
{ // dr213: yes
83 template <class T
> struct A
: T
{
86 int &r2
= g(t
); // expected-error {{explicit qualification required to use member 'g' from dependent base class}}
91 int &g(B
); // expected-note {{here}}
95 template void A
<B
>::h(B
); // expected-note {{instantiation}}
98 namespace dr214
{ // dr214: yes
99 template<typename T
, typename U
> T
checked_cast(U from
) { U::error
; }
100 template<typename T
, typename U
> T
checked_cast(U
*from
);
102 void foo(int *arg
) { checked_cast
<const C
*>(arg
); }
104 template<typename T
> T
f(int);
105 template<typename T
, typename U
> T
f(U
) { T::error
; }
111 namespace dr215
{ // dr215: yes
112 template<typename T
> class X
{
113 friend void T::foo();
117 void foo() { (void)+X
<Y
>().n
; }
121 namespace dr216
{ // dr216: no
122 // FIXME: Should reject this: 'f' has linkage but its type does not,
123 // and 'f' is odr-used but not defined in this TU.
124 typedef enum { e
} *E
;
126 void g(E e
) { f(e
); }
129 // FIXME: Should reject this: 'f' has linkage but its type does not,
130 // and 'f' is odr-used but not defined in this TU.
131 typedef enum { e
} *E
;
134 void g(S s
, S::E e
) { s
.f(e
); }
137 namespace dr217
{ // dr217: yes
138 template<typename T
> struct S
{
141 template<typename T
> void S
<T
>::f(int = 0) {} // expected-error {{default arguments cannot be added}}
144 namespace dr218
{ // dr218: yes
157 void test1(A::S as
) { f(as
); } // expected-error {{called object type 'int'}}
158 void test2(A::S as
) { void f(); f(as
); } // expected-error {{too many arguments}} expected-note {{}}
159 void test3(A::S as
) { using A::f
; f(as
); } // ok
160 void test4(A::S as
) { using B::f
; f(as
); } // ok
161 void test5(A::S as
) { int f
; f(as
); } // expected-error {{called object type 'int'}}
162 void test6(A::S as
) { struct f
{}; (void) f(as
); } // expected-error {{no matching conversion}} expected-note +{{}}
167 struct X
{ void operator()(S
); } f
;
169 void testD(D::S ds
) { f(ds
); } // expected-error {{undeclared identifier}}
175 void testE(E::S es
) { f(es
); } // expected-error {{undeclared identifier}}
179 template<typename T
> friend void f(S
, T
) {}
182 void testF(F::S fs
) { f(fs
, 0); }
190 template<typename T
> void f(T
);
193 template<typename A
, typename B
> struct C
{};
195 void testG(G::C
<G::X::A
, G::Y::B
> gc
) { f(gc
); }
201 namespace dr221
{ // dr221: yes
202 struct A
{ // expected-note 2-4{{candidate}}
203 A
&operator=(int&); // expected-note 2{{candidate}}
205 static A
&operator=(A
&, double&); // expected-error {{cannot be a static member}}
206 static A
&operator+=(A
&, double&); // expected-error {{cannot be a static member}}
207 friend A
&operator=(A
&, char&); // expected-error {{must be a non-static member function}}
208 friend A
&operator+=(A
&, char&);
210 A
&operator=(A
&, float&); // expected-error {{must be a non-static member function}}
211 A
&operator+=(A
&, float&);
213 void test(A a
, int n
, char c
, float f
) {
216 a
= c
; // expected-error {{no viable}}
218 a
= f
; // expected-error {{no viable}}
223 namespace dr222
{ // dr222: dup 637
224 void f(int a
, int b
, int c
, int *x
) {
225 #pragma clang diagnostic push
226 #pragma clang diagnostic warning "-Wunsequenced"
228 void((a
+= b
) + (a
+= c
)); // expected-warning {{multiple unsequenced modifications to 'a'}}
231 #if __cplusplus < 201703L
232 // expected-warning@-2 {{unsequenced modification and access to 'a'}}
235 a
= b
= 0; // ok, read and write of 'b' are sequenced
238 #if __cplusplus < 201703L
239 // expected-warning@-2 {{multiple unsequenced modifications to 'a'}}
242 #pragma clang diagnostic pop
248 namespace dr224
{ // dr224: 16
250 template <class T
> class A
{
255 #if __cplusplus <= 201703L
256 // expected-error@-2 {{implicit 'typename' is a C++20 extension}}
258 ::dr224::example1::A
<T
>::type d
;
266 #if __cplusplus <= 201703L
267 // expected-error@-2 {{implicit 'typename' is a C++20 extension}}
269 ::dr224::example1::A
<T
>::type d
;
274 #if __cplusplus <= 201703L
275 // expected-error@-2 {{implicit 'typename' is a C++20 extension}}
277 typename A
<T
*>::B::type h
;
281 template <class T
> class A
<T
*> {
285 #if __cplusplus <= 201703L
286 // expected-error@-2 {{implicit 'typename' is a C++20 extension}}
290 template <class T1
, class T2
, int I
> struct B
{
292 B
<T1
, T2
, I
>::type b1
;
293 B
<T2
, T1
, I
>::type b2
;
294 #if __cplusplus <= 201703L
295 // expected-error@-2 {{implicit 'typename' is a C++20 extension}}
299 static const int my_I
= I
;
300 static const int my_I2
= I
+0;
301 static const int my_I3
= my_I
;
302 B
<my_T1
, T2
, my_I
>::type b3
;
303 B
<my_T1
, T2
, my_I2
>::type b4
;
304 B
<my_T1
, T2
, my_I3
>::type b5
;
305 #if __cplusplus <= 201703L
306 // expected-error@-4 {{implicit 'typename' is a C++20 extension}}
307 // expected-error@-4 {{implicit 'typename' is a C++20 extension}}
308 // expected-error@-4 {{implicit 'typename' is a C++20 extension}}
314 template <int, typename T
> struct X
{ typedef T type
; };
315 template <class T
> class A
{
316 static const int i
= 5;
318 X
<A::i
, char>::type x
;
319 X
<A
<T
>::i
, double>::type y
;
320 X
<A
<T
*>::i
, long>::type z
;
321 #if __cplusplus <= 201703L
322 // expected-error@-2 {{implicit 'typename' is a C++20 extension}}
326 template <class T
> int A
<T
>::f() {
333 template<typename T
> void dr225_f(T t
) { dr225_g(t
); } // expected-error {{call to function 'dr225_g' that is neither visible in the template definition nor found by argument-dependent lookup}}
334 void dr225_g(int); // expected-note {{should be declared prior to the call site}}
335 template void dr225_f(int); // expected-note {{in instantiation of}}
337 namespace dr226
{ // dr226: no
338 template<typename T
= void> void f() {}
339 #if __cplusplus < 201103L
340 // expected-error@-2 {{extension}}
341 // FIXME: This appears to be wrong: default arguments for function templates
342 // are listed as a defect (in c++98) not an extension. EDG accepts them in
343 // strict c++98 mode.
345 template<typename T
> struct S
{
346 template<typename U
= void> void g();
347 #if __cplusplus < 201103L
348 // expected-error@-2 {{extension}}
350 template<typename U
> struct X
;
351 template<typename U
> void h();
353 template<typename T
> template<typename U
> void S
<T
>::g() {}
354 template<typename T
> template<typename U
= void> struct S
<T
>::X
{}; // expected-error {{cannot add a default template arg}}
355 template<typename T
> template<typename U
= void> void S
<T
>::h() {} // expected-error {{cannot add a default template arg}}
357 template<typename
> void friend_h();
359 // FIXME: This is ill-formed.
360 template<typename
=void> struct friend_B
;
361 // FIXME: f, h, and i are ill-formed.
362 // f is ill-formed because it is not a definition.
363 // h and i are ill-formed because they are not the only declarations of the
364 // function in the translation unit.
365 template<typename
=void> void friend_f();
366 template<typename
=void> void friend_g() {}
367 template<typename
=void> void friend_h() {}
368 template<typename
=void> void friend_i() {}
369 #if __cplusplus < 201103L
370 // expected-error@-5 {{extension}} expected-error@-4 {{extension}}
371 // expected-error@-4 {{extension}} expected-error@-3 {{extension}}
374 template<typename
> void friend_i();
376 template<typename
=void, typename X
> void foo(X
) {}
377 template<typename
=void, typename X
> struct Foo
{}; // expected-error {{missing a default argument}} expected-note {{here}}
378 #if __cplusplus < 201103L
379 // expected-error@-3 {{extension}}
382 template<typename
=void, typename X
, typename
, typename Y
> int foo(X
, Y
);
383 template<typename
, typename X
, typename
=void, typename Y
> int foo(X
, Y
);
385 #if __cplusplus < 201103L
386 // expected-error@-4 {{extension}}
387 // expected-error@-4 {{extension}}
391 void dr227(bool b
) { // dr227: yes
398 namespace dr228
{ // dr228: yes
399 template <class T
> struct X
{
402 template <class T
> struct Y
{
403 void g(X
<T
> x
) { x
.template X
<T
>::f(); }
407 namespace dr229
{ // dr229: yes
408 template<typename T
> void f();
409 template<typename T
> void f
<T
*>() {} // expected-error {{function template partial specialization}}
410 template<> void f
<int>() {}
413 namespace dr230
{ // dr230: yes
415 S() { f(); } // expected-warning {{call to pure virtual member function}}
416 virtual void f() = 0; // expected-note {{declared here}}
420 namespace dr231
{ // dr231: yes
423 int i
; // expected-note {{here}}
425 void f() { using namespace inner
; }
426 int j
= i
; // expected-error {{undeclared identifier 'i'; did you mean 'inner::i'?}}
433 namespace dr236
{ // dr236: yes
435 #if __cplusplus < 201103L
436 // expected-warning@-2 {{null pointer}}
438 // expected-error@-4 {{cannot initialize}}
442 namespace dr237
{ // dr237: dup 470
443 template<typename T
> struct A
{ void f() { T::error
; } };
444 template<typename T
> struct B
: A
<T
> {};
445 template struct B
<int>; // ok
448 namespace dr239
{ // dr239: yes
455 int &g(NS::T
, float);
458 float &r
= g(parm
, 1);
459 extern int &g(NS::T
, float);
466 namespace dr241
{ // dr241: yes
469 template <int X
> void f(); // expected-note 3{{candidate}}
470 template <int X
> void g(B
);
473 template <class T
> void f(T t
); // expected-note 2{{candidate}}
474 template <class T
> void g(T t
); // expected-note {{candidate}}
477 f
<3>(b
); // expected-error 0-1{{C++20 extension}} expected-error {{no matching}}
478 g
<3>(b
); // expected-error 0-1{{C++20 extension}}
479 A::f
<3>(b
); // expected-error {{no matching}}
481 C::f
<3>(b
); // expected-error {{no matching}}
482 C::g
<3>(b
); // expected-error {{no matching}}
485 f
<3>(b
); // expected-error {{no matching}}
490 namespace dr243
{ // dr243: yes
493 A(B
); // expected-note {{candidate}}
496 operator A() = delete; // expected-error 0-1{{extension}} expected-note {{candidate}}
499 A a2
= b
; // expected-error {{ambiguous}}
502 namespace dr244
{ // dr244: 11
503 // NB: this test is reused by dr399
504 struct B
{}; // expected-note {{type 'dr244::B' found by destructor name lookup}}
509 B
* B_ptr
= &D_object
;
512 D_object
.~B(); // expected-error {{does not match the type 'D' of the object being destroyed}}
514 D_object
.D::~B(); // FIXME: Missing diagnostic for this.
517 B_ptr
->B_alias::~B();
518 B_ptr
->B_alias::~B_alias();
519 B_ptr
->dr244::~B(); // expected-error {{refers to a member in namespace}}
520 B_ptr
->dr244::~B_alias(); // expected-error {{refers to a member in namespace}}
523 template<typename T
, typename U
>
524 void f(T
*B_ptr
, U D_object
) {
525 D_object
.~B(); // FIXME: Missing diagnostic for this.
527 D_object
.D::~B(); // FIXME: Missing diagnostic for this.
530 B_ptr
->B_alias::~B();
531 B_ptr
->B_alias::~B_alias();
532 B_ptr
->dr244::~B(); // expected-error {{does not refer to a type name}}
533 B_ptr
->dr244::~B_alias(); // expected-error {{does not refer to a type name}}
535 template void f
<B
, D
>(B
*, D
);
538 template<typename T
> struct E
{};
542 typedef N::F G
; // expected-note {{found by destructor name lookup}}
544 f
.G::~E(); // expected-error {{ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~'}}
545 f
.G::~F(); // expected-error {{undeclared identifier 'F' in destructor name}}
547 // This is technically ill-formed; E is looked up in 'N::' and names the
548 // class template, not the injected-class-name of the class. But that's
549 // probably a bug in the standard.
550 f
.N::F::~E(); // expected-error {{ISO C++ requires the name after '::~' to be found in the same scope as the name before '::~'}}
551 // This is valid; we look up the second F in the same scope in which we
552 // found the first one, that is, 'N::'.
554 // This is technically ill-formed; G is looked up in 'N::' and is not found.
555 // Rejecting this seems correct, but most compilers accept, so we do also.
556 f
.N::F::~G(); // expected-error {{qualified destructor name only found in lexical scope; omit the qualifier to find this type name by unqualified lookup}}
559 // Bizarrely, compilers perform lookup in the scope for qualified destructor
560 // names, if the nested-name-specifier is non-dependent. Ensure we diagnose
562 namespace QualifiedLookupInScope
{
564 template <typename
> struct S
{ struct Inner
{}; };
566 template <typename U
> void f(typename
N::S
<U
>::Inner
*p
) {
567 typedef typename
N::S
<U
>::Inner T
;
568 p
->::dr244::QualifiedLookupInScope::N::S
<U
>::Inner::~T(); // expected-error {{no type named 'T' in}}
570 template void f
<int>(N::S
<int>::Inner
*); // expected-note {{instantiation of}}
572 template <typename U
> void g(U
*p
) {
576 p
->::dr244::QualifiedLookupInScope::N::S
<int>::Inner::~T(); // expected-error {{'T' does not refer to a type name}}
578 template void g(N::S
<int>::Inner
*);
582 namespace dr245
{ // dr245: yes
584 enum E
{}; // expected-note {{here}}
585 class E
*p
; // expected-error {{does not match previous declaration}}
589 namespace dr246
{ // dr246: yes
591 S() try { // expected-note {{try block}}
595 goto X
; // expected-error {{cannot jump}}
600 namespace dr247
{ // dr247: yes
606 void (A::*f
)() = (void (A::*)())&B::f
;
613 void (C::*g
)() = &D::f
;
614 void (D::*h
)() = &D::f
;
623 void (F::*i
)() = &F::f
;
626 namespace dr248
{ // dr248: sup P1949
627 int \u040d\u040e = 0;
630 namespace dr249
{ // dr249: yes
631 template<typename T
> struct X
{ void f(); };
632 template<typename T
> void X
<T
>::f() {}
635 namespace dr250
{ // dr250: yes
636 typedef void (*FPtr
)(double x
[]);
638 template<int I
> void f(double x
[]);
641 template<int I
= 3> void g(double x
[]); // expected-error 0-1{{extension}}
645 namespace dr252
{ // dr252: yes
647 void operator delete(void*); // expected-note {{found}}
650 void operator delete(void*); // expected-note {{found}}
655 C::~C() {} // expected-error {{'operator delete' found in multiple base classes}}
658 void operator delete(void*, int); // expected-note {{here}}
661 D::~D() {} // expected-error {{no suitable member 'operator delete'}}
664 void operator delete(void*, int);
665 void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note 1-2 {{here}}
666 virtual ~E(); // expected-error 0-1 {{attempt to use a deleted function}}
668 E::~E() {} // expected-error {{attempt to use a deleted function}}
671 // If both functions are available, the first one is a placement delete.
672 void operator delete(void*, size_t);
673 void operator delete(void*) = delete; // expected-error 0-1{{extension}} expected-note {{here}}
676 F::~F() {} // expected-error {{attempt to use a deleted function}}
679 void operator delete(void*, size_t);
685 namespace dr254
{ // dr254: yes
686 template<typename T
> struct A
{
687 typedef typename
T::type type
; // ok even if this is a typedef-name, because
688 // it's not an elaborated-type-specifier
689 typedef struct T::type foo
; // expected-error {{typedef 'type' cannot be referenced with a struct specifier}}
691 struct B
{ struct type
{}; };
692 struct C
{ typedef struct {} type
; }; // expected-note {{here}}
694 A
<C
>::type n
; // expected-note {{instantiation of}}
697 namespace dr255
{ // dr255: yes
699 void operator delete(void *){};
700 void operator delete(void *, int){};
702 void f(S
*p
) { delete p
; }
707 namespace dr257
{ // dr257: yes
708 struct A
{ A(int); }; // expected-note {{here}}
709 struct B
: virtual A
{
711 virtual void f() = 0;
717 D() {} // expected-error {{must explicitly initialize the base class 'A'}}
722 namespace dr258
{ // dr258: yes
725 template<typename
> void g(int);
733 template<int> int &g(int); // expected-note {{candidate}}
737 int &x
= b
.g
<int>(0); // expected-error {{no match}}
739 float &z
= const_cast<const B
&>(b
).h();
742 virtual void f(const int) = 0;
749 virtual void f() = 0; // expected-note {{unimplemented}}
753 } f
; // expected-error {{abstract}}
756 namespace dr259
{ // dr259: 4
757 template<typename T
> struct A
{};
758 template struct A
<int>; // expected-note {{previous}}
759 template struct A
<int>; // expected-error {{duplicate explicit instantiation}}
761 template<> struct A
<float>; // expected-note {{previous}}
762 template struct A
<float>; // expected-warning {{has no effect}}
764 template struct A
<char>; // expected-note {{here}}
765 template<> struct A
<char>; // expected-error {{explicit specialization of 'dr259::A<char>' after instantiation}}
767 template<> struct A
<double>;
768 template<> struct A
<double>;
769 template<> struct A
<double> {}; // expected-note {{here}}
770 template<> struct A
<double> {}; // expected-error {{redefinition}}
772 template<typename T
> struct B
; // expected-note {{here}}
773 template struct B
<int>; // expected-error {{undefined}}
775 template<> struct B
<float>; // expected-note {{previous}}
776 template struct B
<float>; // expected-warning {{has no effect}}
779 // FIXME: When dr260 is resolved, also add tests for DR507.
781 namespace dr261
{ // dr261: no
782 #pragma clang diagnostic push
783 #pragma clang diagnostic warning "-Wused-but-marked-unused"
785 // FIXME: This is ill-formed, with a diagnostic required, because operator new
786 // and operator delete are inline and odr-used, but not defined in this
788 // We're also missing the -Wused-but-marked-unused diagnostic here.
790 inline void *operator new(size_t) __attribute__((unused
));
791 inline void operator delete(void*) __attribute__((unused
));
795 // FIXME: This is ill-formed, with a required diagnostic, for the same
798 inline void operator delete(void*) __attribute__((unused
));
802 inline void operator delete(void*) __attribute__((unused
));
803 virtual ~C() {} // expected-warning {{'operator delete' was marked unused but was used}}
807 inline void operator delete(void*) __attribute__((unused
));
809 void h() { C::operator delete(0); } // expected-warning {{marked unused but was used}}
811 #pragma clang diagnostic pop
814 namespace dr262
{ // dr262: yes
821 namespace dr263
{ // dr263: yes
824 #if __cplusplus < 201103L
825 friend X::X() throw();
826 friend X::~X() throw();
827 #elif __cplusplus <= 201703L
828 friend constexpr X::X() noexcept
;
831 friend constexpr X::X() noexcept
;
832 friend constexpr X::~X();
834 Y::Y(); // expected-error {{extra qualification}}
835 Y::~Y(); // expected-error {{extra qualification}}
844 namespace dr272
{ // dr272: yes
849 ~X(); // expected-error {{unary expression}}
856 namespace dr273
{ // dr273: yes
871 namespace dr275
{ // dr275: no
873 template <class T
> void f(T
) {} // expected-note 1-4{{here}}
874 template <class T
> void g(T
) {} // expected-note {{candidate}}
875 template <> void f(int);
876 template <> void f(char);
877 template <> void f(double);
878 template <> void g(char);
884 template <> void N::f(char) {} // expected-error {{'M' does not enclose namespace 'N'}}
885 template <class T
> void g(T
) {}
886 template <> void g(char) {}
887 template void f(long);
888 #if __cplusplus >= 201103L
889 // FIXME: this should be rejected in c++98 too
890 // expected-error@-3 {{must occur in namespace 'N'}}
892 template void N::f(unsigned long);
893 #if __cplusplus >= 201103L
894 // FIXME: this should be rejected in c++98 too
895 // expected-error@-3 {{not in a namespace enclosing 'N'}}
897 template void h(long); // expected-error {{does not refer to a function template}}
898 template <> void f(double) {} // expected-error {{no function template matches}}
901 template <class T
> void g(T
) {} // expected-note {{candidate}}
903 template <> void N::f(char) {}
904 template <> void f(int) {} // expected-error {{no function template matches}}
906 template void f(short);
907 #if __cplusplus >= 201103L
908 // FIXME: this should be rejected in c++98 too
909 // expected-error@-3 {{must occur in namespace 'N'}}
911 template void N::f(unsigned short);
913 // FIXME: this should probably be valid. the wording from the issue
914 // doesn't clarify this, but it follows from the usual rules.
915 template void g(int); // expected-error {{ambiguous}}
917 // FIXME: likewise, this should also be valid.
918 template<typename T
> void f(T
) {} // expected-note {{candidate}}
919 template void f(short); // expected-error {{ambiguous}}
924 namespace dr277
{ // dr277: yes
927 int a
[fold(intp() ? -1 : 1)];
930 namespace dr280
{ // dr280: yes
932 typedef void f1(int);
933 typedef void f2(int, int);
934 typedef void f3(int, int, int);
936 operator f1
*(); // expected-note {{here}} expected-note {{candidate}}
940 operator f0
*(); // expected-note {{candidate}}
942 operator f3
*(); // expected-note {{here}} expected-note {{candidate}}
945 operator f0
*(); // expected-note {{candidate}}
946 operator f1
*(); // expected-note {{candidate}}
947 operator f2
*(); // expected-note {{candidate}}
948 operator f3
*(); // expected-note {{candidate}}
950 struct D
: private A
, B
{ // expected-note {{here}}
951 operator f2
*(); // expected-note {{candidate}}
953 struct E
: C
, D
{} e
;
956 d(0); // expected-error {{private member of 'dr280::A'}}
957 d(0, 0); // ok, suppressed by member in D
958 d(0, 0, 0); // expected-error {{private member of 'dr280::B'}}
959 e(); // expected-error {{ambiguous}}
960 e(0); // expected-error {{ambiguous}}
961 e(0, 0); // expected-error {{ambiguous}}
962 e(0, 0, 0); // expected-error {{ambiguous}}
966 namespace dr281
{ // dr281: no
974 friend inline void a(); // FIXME: ill-formed
975 friend inline void b();
976 friend inline void c(); // FIXME: ill-formed
977 friend inline void d() {}
978 friend inline void e() {}
979 friend inline void f() {}
983 namespace dr283
{ // dr283: yes
984 template<typename T
> // expected-note 2{{here}}
986 friend class T
; // expected-error {{shadows}}
987 class T
; // expected-error {{shadows}}
991 namespace dr284
{ // dr284: no
1003 struct B::V
{}; // expected-error {{no struct named 'V'}}
1005 struct B::X
{}; // FIXME: ill-formed
1006 enum B::Y e
; // ok per dr417
1007 class B::Z z
; // ok per dr417
1020 struct D::V
{}; // expected-error {{no struct named 'V'}}
1022 struct D::X
{}; // FIXME: ill-formed
1023 enum D::Y e2
; // ok per dr417
1024 class D::Z z2
; // ok per dr417
1027 namespace dr285
{ // dr285: yes
1028 template<typename T
> void f(T
, int); // expected-note {{match}}
1029 template<typename T
> void f(int, T
); // expected-note {{match}}
1030 template<> void f
<int>(int, int) {} // expected-error {{ambiguous}}
1033 namespace dr286
{ // dr286: yes
1034 template<class T
> struct A
{
1036 template<class T2
> struct B
{}; // expected-note {{here}}
1042 struct A
<T
>::C::B
<T2
*> { };
1044 A
<short>::C::B
<int*> absip
; // expected-error {{private}}
1049 namespace dr289
{ // dr289: yes
1050 struct A
; // expected-note {{forward}}
1051 struct B
: A
{}; // expected-error {{incomplete}}
1053 template<typename T
> struct C
{ typename
T::error error
; }; // expected-error {{cannot be used prior to '::'}}
1054 struct D
: C
<int> {}; // expected-note {{instantiation}}
1059 // dr292 FIXME: write a codegen test
1061 namespace dr294
{ // dr294: no
1062 void f() throw(int);
1063 #if __cplusplus > 201402L
1064 // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}}
1067 (void)static_cast<void (*)() throw()>(f
); // FIXME: ill-formed in C++14 and before
1068 #if __cplusplus > 201402L
1069 // FIXME: expected-error@-2 {{not allowed}}
1071 // Irony: the above is valid in C++17 and beyond, but that's exactly when
1072 // we reject it. In C++14 and before, this is ill-formed because an
1073 // exception-specification is not permitted in a type-id. In C++17, this is
1074 // valid because it's the inverse of a standard conversion sequence
1075 // containing a function pointer conversion. (Well, it's actually not valid
1076 // yet, as a static_cast is not permitted to reverse a function pointer
1077 // conversion, but that is being changed by core issue).
1079 (void)static_cast<void (*)() throw(int)>(f
); // FIXME: ill-formed in C++14 and before
1080 #if __cplusplus > 201402L
1081 // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}}
1084 void (*p
)() throw() = f
; // expected-error-re {{{{not superset|different exception specification}}}}
1085 void (*q
)() throw(int) = f
;
1086 #if __cplusplus > 201402L
1087 // expected-error@-2 {{ISO C++17 does not allow}} expected-note@-2 {{use 'noexcept}}
1092 namespace dr295
{ // dr295: 3.7
1094 const f g
; // expected-warning {{'const' qualifier on function type 'f' (aka 'int ()') has no effect}}
1096 template<typename T
> struct X
{
1102 typedef const U U
; // expected-warning {{'const' qualifier on function type 'U' (aka 'int ()') has no effect}}
1105 typedef volatile U
*V
; // expected-warning {{'volatile' qualifier on function type 'U' (aka 'int ()') has no effect}}
1108 namespace dr296
{ // dr296: yes
1110 static operator int() { return 0; } // expected-error {{static}}
1114 namespace dr298
{ // dr298: yes
1120 typedef A B
; // expected-note {{here}}
1121 typedef const A C
; // expected-note {{here}}
1128 struct B b
; // expected-error {{typedef 'B' cannot be referenced with a struct specifier}}
1129 struct C c
; // expected-error {{typedef 'C' cannot be referenced with a struct specifier}}
1131 B::B() {} // expected-error {{a type specifier is required}}
1133 C::~C() {} // expected-error {{destructor cannot be declared using a typedef 'C' (aka 'const dr298::A') of the class name}}
1135 typedef struct D E
; // expected-note {{here}}
1136 struct E
{}; // expected-error {{conflicts with typedef}}
1145 namespace dr299
{ // dr299: yes c++11
1150 operator int(); // expected-note {{}}
1151 operator unsigned short(); // expected-note {{}}
1153 // FIXME: should this apply to c++98 mode?
1154 int *p
= new int[S()]; // expected-error 0-1{{extension}}
1155 int *q
= new int[T()]; // expected-error {{ambiguous}}