diff --git a/clang/test/CXX/drs/dr0xx.cpp b/clang/test/CXX/drs/dr0xx.cpp index e79ce6daf2655..768da0f8e6fa7 100644 --- a/clang/test/CXX/drs/dr0xx.cpp +++ b/clang/test/CXX/drs/dr0xx.cpp @@ -89,12 +89,11 @@ namespace dr7 { // dr7: 3.4 class B : virtual private A {}; // #dr7-B class C : public B {} c; // #dr7-C // expected-error@#dr7-C {{inherited virtual base class 'A' has private destructor}} - // expected-note@#dr7-C {{in implicit default constructor for 'dr7::C' first required here}} - // expected-note@#dr7-B {{declared private here}} - + // expected-note@#dr7-C {{in implicit default constructor for 'dr7::C' first required here}} + // expected-note@#dr7-B {{declared private here}} // expected-error@#dr7-C {{inherited virtual base class 'A' has private destructor}} - // expected-note@#dr7-C {{in implicit destructor for 'dr7::C' first required here}} - // expected-note@#dr7-B {{declared private here}} + // expected-note@#dr7-C {{in implicit destructor for 'dr7::C' first required here}} + // expected-note@#dr7-B {{declared private here}} class VeryDerivedC : public B, virtual public A {} vdc; class X { ~X(); }; // #dr7-X @@ -237,11 +236,10 @@ namespace dr16 { // dr16: 2.8 // expected-note@#dr16-A-f-decl {{member is declared here}} A::f(); // #dr16-A-f-call // expected-error@#dr16-A-f-call {{'A' is a private member of 'dr16::A'}} - // expected-note@#dr16-B {{constrained by implicitly private inheritance here}} - // expected-note@#dr16-A {{member is declared here}} - + // expected-note@#dr16-B {{constrained by implicitly private inheritance here}} + // expected-note@#dr16-A {{member is declared here}} // expected-error@#dr16-A-f-call {{cannot cast 'dr16::C' to its private base class 'dr16::A'}} - // expected-note@#dr16-B {{implicitly declared private here}} + // expected-note@#dr16-B {{implicitly declared private here}} } }; } @@ -361,9 +359,9 @@ namespace dr26 { // dr26: yes // FIXME: In C++98, we diagnose this twice. B(const B &, B = B()); // cxx98-14-error@-1 {{recursive evaluation of default argument}} - // cxx98-14-note@-2 {{default argument used here}} + // cxx98-14-note@-2 {{default argument used here}} // cxx98-error@-3 {{recursive evaluation of default argument}} - // cxx98-note@-4 {{default argument used here}} + // cxx98-note@-4 {{default argument used here}} }; struct C { static C &f(); @@ -788,23 +786,20 @@ namespace dr49 { // dr49: 2.8 A<&k> a; A

b; // #dr49-b // cxx98-error@#dr49-b {{non-type template argument referring to object 'p' with internal linkage is a C++11 extension}} - // cxx98-note@#dr49-p {{non-type template argument refers to object here}} - + // cxx98-note@#dr49-p {{non-type template argument refers to object here}} // cxx98-14-error@#dr49-b {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} - // cxx98-14-note@#dr49-A {{template parameter is declared here}} + // cxx98-14-note@#dr49-A {{template parameter is declared here}} int *q = &k; // #dr49-q A c; // #dr49-c // cxx98-error@#dr49-c {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}} - // cxx98-note@#dr49-A {{template parameter is declared here}} - + // cxx98-note@#dr49-A {{template parameter is declared here}} // cxx11-14-error@#dr49-c {{non-type template argument of type 'int *' is not a constant expression}} - // cxx11-14-note@#dr49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}} - // cxx11-14-note@#dr49-q {{declared here}} - // cxx11-14-note@#dr49-A {{template parameter is declared here}} - + // cxx11-14-note@#dr49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}} + // cxx11-14-note@#dr49-q {{declared here}} + // cxx11-14-note@#dr49-A {{template parameter is declared here}} // since-cxx17-error@#dr49-c {{non-type template argument is not a constant expression}} - // since-cxx17-note@#dr49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}} - // since-cxx17-note@#dr49-q {{declared here}} + // since-cxx17-note@#dr49-c {{read of non-constexpr variable 'q' is not allowed in a constant expression}} + // since-cxx17-note@#dr49-q {{declared here}} } namespace dr50 { // dr50: yes @@ -835,11 +830,10 @@ namespace dr52 { // dr52: 2.8 int k = b.A::n; // #dr52-k // FIXME: This first diagnostic is very strangely worded, and seems to be bogus. // expected-error@#dr52-k {{'A' is a private member of 'dr52::A'}} - // expected-note@#dr52-B {{constrained by private inheritance here}} - // expected-note@#dr52-A {{member is declared here}} - + // expected-note@#dr52-B {{constrained by private inheritance here}} + // expected-note@#dr52-A {{member is declared here}} // expected-error@#dr52-k {{cannot cast 'struct B' to its private base class 'dr52::A'}} - // expected-note@#dr52-B {{declared private here}} + // expected-note@#dr52-B {{declared private here}} } namespace dr53 { // dr53: yes @@ -1171,8 +1165,7 @@ namespace dr76 { // dr76: yes const volatile int n = 1; int arr[n]; // #dr76-vla // expected-error@#dr76-vla {{variable length arrays in C++ are a Clang extension}} - // expected-note@#dr76-vla {{read of volatile-qualified type 'const volatile int' is not allowed in a constant expression}} - + // expected-note@#dr76-vla {{read of volatile-qualified type 'const volatile int' is not allowed in a constant expression}} // expected-error@#dr76-vla {{variable length array declaration not allowed at file scope}} } @@ -1346,8 +1339,7 @@ namespace dr92 { // dr92: 4 c++17 // since-cxx17-note@-2 {{use 'noexcept(false)' instead}} void (*p)() throw(int) = &f; // #dr92-p // since-cxx17-error@#dr92-p {{ISO C++17 does not allow dynamic exception specifications}} - // since-cxx17-note@#dr92-p {{use 'noexcept(false)' instead}} - + // since-cxx17-note@#dr92-p {{use 'noexcept(false)' instead}} // cxx98-14-error@#dr92-p {{target exception specification is not superset of source}} // since-cxx17-warning@#dr92-p {{target exception specification is not superset of source}} void (*q)() throw(int); @@ -1363,11 +1355,11 @@ namespace dr92 { // dr92: 4 c++17 g(f); // cxx98-14-error@-1 {{target exception specification is not superset of source}} // since-cxx17-error@-2 {{no matching function for call to 'g'}} - // since-cxx17-note@#dr92-g {{candidate function not viable: no known conversion from 'void () throw(int, float)' to 'void (*)() throw()' for 1st argument}} + // since-cxx17-note@#dr92-g {{candidate function not viable: no known conversion from 'void () throw(int, float)' to 'void (*)() throw()' for 1st argument}} g(q); // cxx98-14-error@-1 {{target exception specification is not superset of source}} // since-cxx17-error@-2 {{no matching function for call to 'g'}} - // since-cxx17-note@#dr92-g {{candidate function not viable: no known conversion from 'void (*)() throw(int)' to 'void (*)() throw()' for 1st argument}} + // since-cxx17-note@#dr92-g {{candidate function not viable: no known conversion from 'void (*)() throw(int)' to 'void (*)() throw()' for 1st argument}} } // Prior to C++17, this is OK because the exception specification is not diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp index 50236eb7c9499..4465e7e0f1bfd 100644 --- a/clang/test/CXX/drs/dr1xx.cpp +++ b/clang/test/CXX/drs/dr1xx.cpp @@ -1,30 +1,31 @@ -// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors +// 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 namespace dr100 { // dr100: yes - template struct A {}; // expected-note 0-1{{declared here}} - template struct B {}; // expected-note 0-1{{declared here}} - template struct C {}; // expected-note 0-1{{declared here}} - template struct D {}; // expected-note 0-1{{declared here}} - A<&"foo"> a; // #100a - B<"bar"> b; // #100b - C<"baz"> c; // #100c - D<*"quux"> d; // #100d -#if __cplusplus < 201703L - // expected-error@#100a {{does not refer to any declaration}} - // expected-error@#100b {{does not refer to any declaration}} - // expected-error@#100c {{does not refer to any declaration}} - // expected-error@#100d {{does not refer to any declaration}} -#else - // expected-error@#100a {{pointer to string literal is not allowed in a template argument}} - // expected-error@#100b {{reference to string literal is not allowed in a template argument}} - // expected-error@#100c {{pointer to subobject of string literal is not allowed in a template argument}} - // expected-error@#100d {{reference to subobject of string literal is not allowed in a template argument}} -#endif + template struct A {}; // #dr100-A + template struct B {}; // #dr100-B + template struct C {}; // #dr100-C + template struct D {}; // #dr100-D + A<&"foo"> a; // #dr100-a + // cxx98-14-error@#dr100-a {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-A {{template parameter is declared here}} + // since-cxx17-error@#dr100-a {{pointer to string literal is not allowed in a template argument}} + B<"bar"> b; // #dr100-b + // cxx98-14-error@#dr100-b {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-B {{template parameter is declared here}} + // since-cxx17-error@#dr100-b {{reference to string literal is not allowed in a template argument}} + C<"baz"> c; // #dr100-c + // cxx98-14-error@#dr100-c {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-C {{template parameter is declared here}} + // since-cxx17-error@#dr100-c {{pointer to subobject of string literal is not allowed in a template argument}} + D<*"quux"> d; // #dr100-d + // cxx98-14-error@#dr100-d {{non-type template argument does not refer to any declaration}} + // cxx98-14-note@#dr100-D {{template parameter is declared here}} + // since-cxx17-error@#dr100-d {{reference to subobject of string literal is not allowed in a template argument}} } namespace dr101 { // dr101: 3.5 @@ -42,13 +43,16 @@ namespace dr101 { // dr101: 3.5 namespace dr102 { // dr102: yes namespace A { - template T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} + template 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@#dr102-instantiation {{in instantiation of function template specialization 'dr102::A::f' requested here}} + // expected-note@#dr102-operator-plus {{'operator+' should be declared prior to the call site or in namespace 'dr102::B'}} } namespace B { struct S {}; } - B::S operator+(B::S, B::S); // expected-note {{should be declared prior to the call site or in namespace 'dr102::B'}} - template B::S A::f(B::S, B::S); // expected-note {{in instantiation of}} + B::S operator+(B::S, B::S); // #dr102-operator-plus + template B::S A::f(B::S, B::S); // #dr102-instantiation } // dr103: na @@ -58,13 +62,17 @@ namespace dr102 { // dr102: yes namespace dr106 { // dr106: sup 540 typedef int &r1; typedef r1 &r1; - typedef const r1 r1; // expected-warning {{has no effect}} - typedef const r1 &r1; // expected-warning {{has no effect}} + 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 {{has no effect}} - typedef const r2 &r2; // expected-warning {{has no effect}} + 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 dr107 { // dr107: yes @@ -76,10 +84,9 @@ namespace dr108 { // dr108: 2.9 template struct A { struct B { typedef int X; }; B::X x; -#if __cplusplus <= 201703L - // expected-error@-2 {{implicit 'typename' is a C++20 extension}} -#endif - struct C : B { X x; }; // expected-error {{unknown type name}} + // 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::B { int X; }; } @@ -87,46 +94,55 @@ namespace dr108 { // dr108: 2.9 namespace dr109 { // dr109: yes struct A { template void f(T); }; template struct B : T { - using T::template f; // expected-error {{'template' keyword not permitted here}} - using T::template f; // expected-error {{'template' keyword not permitted here}} expected-error {{using declaration cannot refer to a template specialization}} + using T::template f; + // expected-error@-1 {{'template' keyword not permitted here}} + using T::template f; + // 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; // expected-error {{use 'template' keyword}} expected-error {{using declaration cannot refer to a template specialization}} - void g() { this->f(123); } // expected-error {{use 'template' keyword}} + using T::f; + // 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(123); } + // expected-error@-1 {{use 'template' keyword to treat 'f' as a dependent template name}} }; } namespace dr111 { // dr111: dup 535 struct A { A(); A(volatile A&, int = 0); A(A&, const char * = "foo"); }; - struct B : A { B(); }; // expected-note +{{would lose const qualifier}} expected-note {{requires 0 arguments}} + struct B : A { B(); }; // #dr111-B const B b1; - B b2(b1); // expected-error {{no matching constructor}} + B b2(b1); + // expected-error@-1 {{no matching constructor for initialization of 'B'}} + // expected-note@#dr111-B {{candidate constructor (the implicit copy constructor) not viable: 1st argument ('const B') would lose const qualifier}} + // expected-note@#dr111-B {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} } namespace dr112 { // dr112: yes struct T { int n; }; typedef T Arr[1]; - const T a1[1] = {}; + const T a1[1] = {}; // #dr112-a1 volatile T a2[1] = {}; - const Arr a3 = {}; + const Arr a3 = {}; // #dr112-a3 volatile Arr a4 = {}; template struct X {}; + // FIXME: Test this somehow in C++11 and on. X x1; + // cxx98-error@-1 {{non-type template argument referring to object 'a1' with internal linkage is a C++11 extension}} + // cxx98-note@#dr112-a1 {{non-type template argument refers to object here}} X x2; X x3; + // cxx98-error@-1 {{non-type template argument referring to object 'a3' with internal linkage is a C++11 extension}} + // cxx98-note@#dr112-a3 {{non-type template argument refers to object here}} X x4; -#if __cplusplus < 201103L - // expected-error@-5 {{internal linkage}} expected-note@-10 {{here}} - // expected-error@-4 {{internal linkage}} expected-note@-9 {{here}} -#else - // FIXME: Test this somehow. -#endif } namespace dr113 { // dr113: yes extern void (*p)(); void f() { - no_such_function(); // expected-error {{undeclared}} + no_such_function(); + // expected-error@-1 {{use of undeclared identifier 'no_such_function'}} p(); } void g(); @@ -135,31 +151,48 @@ namespace dr113 { // dr113: yes namespace dr114 { // dr114: yes struct A { - virtual void f(int) = 0; // expected-note {{unimplemented}} + virtual void f(int) = 0; // #dr114-A-f }; struct B : A { template void f(T); void g() { f(0); } - } b; // expected-error {{abstract}} + } b; + // expected-error@-1 {{variable type 'struct B' is an abstract class}} + // expected-note@#dr114-A-f {{unimplemented pure virtual method 'f' in 'B'}} } namespace dr115 { // dr115: 3.0 - template int f(T); // expected-note +{{}} - template int g(T); // expected-note +{{}} - template int g(T, int); // expected-note +{{}} + template int f(T); // #dr115-f + template int g(T); // #dr115-g + template int g(T, int); // #dr115-g-int - int k1 = f(&f); // expected-error {{no match}} + int k1 = f(&f); + // expected-error@-1 {{no matching function for call to 'f'}} + // expected-note@#dr115-f {{candidate template ignored: couldn't infer template argument 'T'}} int k2 = f(&f); - int k3 = f(&g); // expected-error {{no match}} + int k3 = f(&g); + // expected-error@-1 {{no matching function for call to 'f'}} + // expected-note@#dr115-f {{candidate template ignored: couldn't infer template argument 'T'}} void h() { - (void)&f; // expected-error {{address of overloaded function 'f' cannot be cast to type 'void'}} + (void)&f; + // expected-error@-1 {{address of overloaded function 'f' cannot be cast to type 'void'}} + // expected-note@#dr115-f {{candidate function template}} (void)&f; - (void)&g; // expected-error {{address of overloaded function 'g' cannot be cast to type 'void'}} - - &f; // expected-error {{reference to overloaded function could not be resolved}} - &f; // expected-warning {{unused}} - &g; // expected-error {{reference to overloaded function could not be resolved}} + (void)&g; + // expected-error@-1 {{address of overloaded function 'g' cannot be cast to type 'void'}} + // expected-note@#dr115-g-int {{candidate function template}} + // expected-note@#dr115-g {{candidate function template}} + + &f; + // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} + // expected-note@#dr115-f {{possible target for call}} + &f; + // expected-warning@-1 {{expression result unused}} + &g; + // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} + // expected-note@#dr115-g-int {{possible target for call}} + // expected-note@#dr115-g {{possible target for call}} } struct S { @@ -168,18 +201,25 @@ namespace dr115 { // dr115: 3.0 template static int g(T, int); } s; - int k4 = f(&s.f); // expected-error {{non-constant pointer to member}} + int k4 = f(&s.f); + // expected-error@-1 {{cannot create a non-constant pointer to member function}} int k5 = f(&s.f); - int k6 = f(&s.g); // expected-error {{non-constant pointer to member}} + int k6 = f(&s.g); + // expected-error@-1 {{cannot create a non-constant pointer to member function}} void i() { - (void)&s.f; // expected-error {{non-constant pointer to member}} + (void)&s.f; + // expected-error@-1 {{cannot create a non-constant pointer to member function}} (void)&s.f; - (void)&s.g; // expected-error {{non-constant pointer to member}} - - &s.f; // expected-error {{non-constant pointer to member}} - &s.f; // expected-warning {{unused}} - &s.g; // expected-error {{non-constant pointer to member}} + (void)&s.g; + // 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; + // expected-warning@-1 {{expression result unused}} + &s.g; + // expected-error@-1 {{cannot create a non-constant pointer to member function}} } struct T { @@ -188,40 +228,58 @@ namespace dr115 { // dr115: 3.0 template int g(T, int); } t; - int k7 = f(&s.f); // expected-error {{non-constant pointer to member}} + int k7 = f(&s.f); + // expected-error@-1 {{cannot create a non-constant pointer to member function}} int k8 = f(&s.f); - int k9 = f(&s.g); // expected-error {{non-constant pointer to member}} + int k9 = f(&s.g); + // expected-error@-1 {{cannot create a non-constant pointer to member function}} void j() { - (void)&s.f; // expected-error {{non-constant pointer to member}} + (void)&s.f; + // expected-error@-1 {{cannot create a non-constant pointer to member function}} (void)&s.f; - (void)&s.g; // expected-error {{non-constant pointer to member}} - - &s.f; // expected-error {{non-constant pointer to member}} - &s.f; // expected-warning {{unused}} - &s.g; // expected-error {{non-constant pointer to member}} + (void)&s.g; + // 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; + // expected-warning@-1 {{expression result unused}} + &s.g; + // 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 void with_default(); // expected-note +{{}} - int k10 = f(&with_default); // expected-error {{no matching function}} + template void with_default(); // #dr115-with-default + int k10 = f(&with_default); + // expected-error@-1 {{no matching function for call to 'f'}} + // expected-note@#dr115-f {{candidate template ignored: couldn't infer template argument 'T'}} int k11 = f(&with_default<>); void k() { - (void)&with_default; // expected-error {{overloaded function}} + (void)&with_default; + // expected-error@-1 {{address of overloaded function 'with_default' cannot be cast to type 'void'}} + // expected-note@#dr115-with-default {{candidate function template}} (void)&with_default<>; - &with_default; // expected-error {{overloaded function}} - &with_default<>; // expected-warning {{unused}} + &with_default; + // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} + // expected-note@#dr115-with-default {{possible target for call}} + &with_default<>; + // expected-warning@-1 {{expression result unused}} } #endif } namespace dr116 { // dr116: yes template struct A {}; - template void f(A) {} // expected-note {{previous}} - template void f(A) {} // expected-error {{redefinition}} - template void f(A) {} // expected-note {{previous}} - template void f(A) {} // expected-error {{redefinition}} + template void f(A) {} // #dr116-f-N + template void f(A) {} + // expected-error@-1 {{redefinition of 'f'}} + // expected-note@#dr116-f-N {{previous definition is here}} + template void f(A) {} // #dr116-f-T + template void f(A) {} + // expected-error@-1 {{redefinition of 'f'}} + // expected-note@#dr116-f-T {{previous definition is here}} } // dr117: na @@ -235,7 +293,9 @@ namespace dr121 { // dr121: yes }; template struct Z { X::Y x; - T::Y y; // expected-error +{{}} + T::Y 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 z; } @@ -249,15 +309,19 @@ namespace dr122 { // dr122: yes // dr124: dup 201 // dr125: yes -struct dr125_A { struct dr125_B {}; }; // expected-note {{here}} +struct dr125_A { struct dr125_B {}; }; // #dr125_B dr125_A::dr125_B dr125_C(); namespace dr125_B { dr125_A dr125_C(); } namespace dr125 { struct X { friend dr125_A::dr125_B (::dr125_C)(); // ok friend dr125_A (::dr125_B::dr125_C)(); // ok - friend dr125_A::dr125_B::dr125_C(); // expected-error {{did you mean the constructor name 'dr125_B'?}} - // expected-error@-1 {{missing exception specification}} + friend dr125_A::dr125_B::dr125_C(); // #dr125_C + // expected-error@#dr125_C {{missing return type for function 'dr125_C'; did you mean the constructor name 'dr125_B'?}} + // cxx98-error@#dr125_C {{'dr125_B' is missing exception specification 'throw()'}} + // cxx98-note@#dr125_B {{previous declaration is here}} + // since-cxx11-error@#dr125_C {{'dr125_B' is missing exception specification 'noexcept'}} + // since-cxx11-note@#dr125_B {{previous declaration is here}} }; } @@ -275,7 +339,6 @@ namespace dr126 { // dr126: partial // 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. -#if __cplusplus <= 201402L struct C {}; struct D : C {}; struct E : private C { friend class A; friend class B; }; @@ -283,53 +346,64 @@ namespace dr126 { // dr126: partial 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*); // expected-note {{overridden}} - virtual void fp() throw(C*); // expected-note {{overridden}} + virtual void ep() throw(C*); // #dr126-ep + virtual void fp() throw(C*); // #dr126-fp virtual void gp() throw(C*); - virtual void hp() throw(C*); // expected-note {{overridden}} + virtual void hp() throw(C*); // #dr126-hp virtual void cr() throw(C&); virtual void dr() throw(C&); - virtual void er() throw(C&); // expected-note {{overridden}} - virtual void fr() throw(C&); // expected-note {{overridden}} + virtual void er() throw(C&); // #dr126-er + virtual void fr() throw(C&); // #dr126-fr virtual void gr() throw(C&); - virtual void hr() throw(C&); // expected-note {{overridden}} + virtual void hr() throw(C&); // #dr126-hr virtual void pv() throw(void*); -#if __cplusplus >= 201103L virtual void np() throw(C*); virtual void npm() throw(int C::*); - virtual void nr() throw(C*&); // expected-note {{overridden}} + virtual void nr() throw(C*&); // #dr126-nr virtual void ncr() throw(C*const&); -#endif 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*); // expected-note {{overridden}} + virtual void x() throw(int*); // #dr126-x virtual void y() throw(const int*); - virtual void z() throw(int); // expected-note {{overridden}} + virtual void z() throw(int); // #dr126-z }; struct B : A { virtual void cp() throw(C*); virtual void dp() throw(D*); - virtual void ep() throw(E*); // expected-error {{more lax}} - virtual void fp() throw(F*); // expected-error {{more lax}} + virtual void ep() throw(E*); + // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}} + // cxx98-14-note@#dr126-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@#dr126-fp {{overridden virtual function is here}} virtual void gp() throw(G*); - virtual void hp() throw(H*); // expected-error {{more lax}} + virtual void hp() throw(H*); + // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}} + // cxx98-14-note@#dr126-hp {{overridden virtual function is here}} virtual void cr() throw(C&); virtual void dr() throw(D&); - virtual void er() throw(E&); // expected-error {{more lax}} - virtual void fr() throw(F&); // expected-error {{more lax}} + virtual void er() throw(E&); + // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}} + // cxx98-14-note@#dr126-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@#dr126-fr {{overridden virtual function is here}} virtual void gr() throw(G&); - virtual void hr() throw(H&); // expected-error {{more lax}} + virtual void hr() throw(H&); + // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}} + // cxx98-14-note@#dr126-hr {{overridden virtual function is here}} virtual void pv() throw(C*); @@ -337,22 +411,29 @@ namespace dr126 { // dr126: partial using nullptr_t = decltype(nullptr); virtual void np() throw(nullptr_t); virtual void npm() throw(nullptr_t&); - virtual void nr() throw(nullptr_t); // expected-error {{more lax}} + virtual void nr() throw(nullptr_t); + // cxx11-14-error@-1 {{exception specification of overriding function is more lax than base version}} + // cxx11-14-note@#dr126-nr {{overridden virtual function is here}} virtual void ncr() throw(nullptr_t); -#endif +#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*); // expected-error {{more lax}} + virtual void x() throw(const int*); + // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}} + // cxx98-14-note@#dr126-x {{overridden virtual function is here}} virtual void y() throw(int*); // ok - virtual void z() throw(long); // expected-error {{more lax}} + virtual void z() throw(long); + // cxx98-14-error@-1 {{exception specification of overriding function is more lax than base version}} + // cxx98-14-note@#dr126-z {{overridden virtual function is here}} }; -#else - void f() throw(int); // expected-error {{ISO C++17 does not allow}} expected-note {{use 'noexcept}} -#endif +#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 dr127 { // dr127: yes @@ -360,11 +441,16 @@ namespace dr127 { // dr127: yes template struct A { A() { throw 0; } void *operator new(size_t, const char * = 0); - void operator delete(void *, const char *) { T::error; } // expected-error 2{{no members}} + void operator delete(void *, const char *) { T::error; } // #dr127-delete-const-char + // expected-error@#dr127-delete-const-char {{type 'void' cannot be used prior to '::' because it has no members}} + // expected-note@#dr127-p {{in instantiation of member function 'dr127::A::operator delete' requested here}} + + // expected-error@#dr127-delete-const-char {{type 'int' cannot be used prior to '::' because it has no members}} + // expected-note@#dr127-q {{in instantiation of member function 'dr127::A::operator delete' requested here}} void operator delete(void *) { T::error; } }; - A *p = new A; // expected-note {{instantiat}} - A *q = new ("") A; // expected-note {{instantiat}} + A *p = new A; // #dr127-p + A *q = new ("") A; // #dr127-q } namespace dr128 { // dr128: yes @@ -401,36 +487,50 @@ namespace dr135 { // dr135: yes } namespace dr136 { // dr136: 3.4 - void f(int, int, int = 0); // expected-note {{previous declaration is here}} - void g(int, int, int); // expected-note {{previous declaration is here}} + void f(int, int, int = 0); // #dr136-f + void g(int, int, int); // #dr136-g struct A { - friend void f(int, int = 0, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - friend void g(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} - friend void h(int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be a definition}} - friend void i(int, int, int = 0) {} // expected-note {{previous declaration is here}} + friend void f(int, int = 0, int); + // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}} + // expected-note@#dr136-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@#dr136-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) {} // #dr136-A-i friend void j(int, int, int = 0) {} operator int(); }; - void i(int, int, int); // expected-error {{friend declaration specifying a default argument must be the only declaration}} + void i(int, int, int); + // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}} + // expected-note@#dr136-A-i {{previous declaration is here}} void q() { j(A(), A()); // ok, has default argument } - extern "C" void k(int, int, int, int); // expected-note 2{{previous declaration is here}} + extern "C" void k(int, int, int, int); // #dr136-k namespace NSA { struct A { - friend void dr136::k(int, int, int, int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} + friend void dr136::k(int, int, int, int = 0); + // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}} + // expected-note@#dr136-k {{previous declaration is here}} }; } namespace NSB { struct A { - friend void dr136::k(int, int, int = 0, int); // expected-error {{missing default argument on parameter}} expected-error {{must be the only declaration}} + friend void dr136::k(int, int, int = 0, int); // #dr136-friend-k + // expected-error@#dr136-friend-k {{friend declaration specifying a default argument must be the only declaration}} + // expected-note@#dr136-k {{previous declaration is here}} + // expected-error@#dr136-friend-k {{missing default argument on parameter}} }; } struct B { - void f(int); // expected-note {{previous declaration is here}} + void f(int); // #dr136-B-f }; struct C { - friend void B::f(int = 0); // expected-error {{friend declaration specifying a default argument must be the only declaration}} + friend void B::f(int = 0); + // expected-error@-1 {{friend declaration specifying a default argument must be the only declaration}} + // expected-note@#dr136-B-f {{previous declaration is here}} }; } @@ -440,13 +540,18 @@ namespace dr137 { // dr137: yes extern volatile void *vp; extern const volatile void *cvp; int *q = static_cast(p); - int *qc = static_cast(cp); // expected-error {{casts away qualifiers}} - int *qv = static_cast(vp); // expected-error {{casts away qualifiers}} - int *qcv = static_cast(cvp); // expected-error {{casts away qualifiers}} + int *qc = static_cast(cp); + // expected-error@-1 {{static_cast from 'const void *' to 'int *' casts away qualifiers}} + int *qv = static_cast(vp); + // expected-error@-1 {{static_cast from 'volatile void *' to 'int *' casts away qualifiers}} + int *qcv = static_cast(cvp); + // expected-error@-1 {{static_cast from 'const volatile void *' to 'int *' casts away qualifiers}} const int *cq = static_cast(p); const int *cqc = static_cast(cp); - const int *cqv = static_cast(vp); // expected-error {{casts away qualifiers}} - const int *cqcv = static_cast(cvp); // expected-error {{casts away qualifiers}} + const int *cqv = static_cast(vp); + // expected-error@-1 {{static_cast from 'volatile void *' to 'const int *' casts away qualifiers}} + const int *cqcv = static_cast(cvp); + // expected-error@-1 {{static_cast from 'const volatile void *' to 'const int *' casts away qualifiers}} const volatile int *cvq = static_cast(p); const volatile int *cvqc = static_cast(cp); const volatile int *cvqv = static_cast(vp); @@ -455,9 +560,11 @@ namespace dr137 { // dr137: yes namespace dr139 { // dr139: yes namespace example1 { - typedef int f; // expected-note {{previous}} + typedef int f; // #dr139-typedef-f struct A { - friend void f(A &); // expected-error {{different kind of symbol}} + friend void f(A &); + // expected-error@-1 {{redefinition of 'f' as different kind of symbol}} + // expected-note@#dr139-typedef-f {{previous definition is here}} }; } @@ -474,35 +581,41 @@ namespace dr139 { // dr139: yes } namespace dr140 { // dr140: yes - void f(int *const) {} // expected-note {{previous}} - void f(int[3]) {} // expected-error {{redefinition}} + void f(int *const) {} // #dr140-f-first + void f(int[3]) {} + // expected-error@-1 {{redefinition of 'f'}} + // expected-note@#dr140-f-first {{previous definition is here}} void g(const int); void g(int n) { n = 2; } } namespace dr141 { // dr141: 3.1 template void f(); - template struct S { int n; }; // expected-note {{'::dr141::S::n' declared here}} + template struct S { int n; }; // #dr141-S struct A : S { template void f(); - template struct S {}; + template struct S {}; // #dr141-A-S } a; struct B : S {} b; void g() { a.f(); - (void)a.S::n; // expected-error {{no member named 'n' in 'dr141::A::S'; did you mean '::dr141::S::n'?}} -#if __cplusplus < 201103L - // expected-error@-2 {{ambiguous}} - // expected-note@-11 {{lookup from the current scope}} - // expected-note@-9 {{lookup in the object type}} -#endif - b.f(); // expected-error {{no member}} expected-error +{{}} + (void)a.S::n; // #dr141-a + // cxx98-error@#dr141-a {{lookup of 'S' in member access expression is ambiguous; using member of 'struct A'}} + // cxx98-note@#dr141-A-S {{lookup in the object type 'struct A' refers here}} + // cxx98-note@#dr141-S {{lookup from the current scope refers here}} + // expected-error@#dr141-a {{no member named 'n' in 'dr141::A::S'; did you mean '::dr141::S::n'?}} + // expected-note@#dr141-S {{'::dr141::S::n' declared here}} + // FIXME: we issue a useful diagnostic first, then some bogus ones. + b.f(); + // expected-error@-1 {{no member named 'f' in 'dr141::B'}} + // expected-error@-2 +{{}} (void)b.S::n; } template struct C { T t; void g() { - t.f(); // expected-error {{use 'template'}} + t.f(); + // expected-error@-1 {{use 'template' keyword to treat 'f' as a dependent template name}} } void h() { (void)t.S::n; // ok @@ -519,28 +632,53 @@ namespace dr141 { // dr141: 3.1 } namespace dr142 { // dr142: 2.8 - class B { // expected-note +{{here}} + class B { // #dr142-B public: - int mi; // expected-note +{{here}} - static int si; // expected-note +{{here}} + int mi; // #dr142-B-mi + static int si; // #dr142-B-si }; - class D : private B { // expected-note +{{here}} + class D : private B { // #dr142-D }; class DD : public D { void f(); }; void DD::f() { - mi = 3; // expected-error {{private member}} - si = 3; // expected-error {{private member}} - B b_old; // expected-error {{private member}} + mi = 3; + // expected-error@-1 {{'mi' is a private member of 'dr142::B'}} + // expected-note@#dr142-D {{constrained by private inheritance here}} + // expected-note@#dr142-B-mi {{member is declared here}} + si = 3; + // expected-error@-1 {{'si' is a private member of 'dr142::B'}} + // expected-note@#dr142-D {{constrained by private inheritance here}} + // expected-note@#dr142-B-si {{member is declared here}} + B b_old; + // expected-error@-1 {{'B' is a private member of 'dr142::B'}} + // expected-note@#dr142-D {{constrained by private inheritance here}} + // expected-note@#dr142-B {{member is declared here}} dr142::B b; b.mi = 3; b.si = 3; - B::si = 3; // expected-error {{private member}} + B::si = 3; + // expected-error@-1 {{'B' is a private member of 'dr142::B'}} + // expected-note@#dr142-D {{constrained by private inheritance here}} + // expected-note@#dr142-B {{member is declared here}} dr142::B::si = 3; - B *bp1_old = this; // expected-error {{private member}} expected-error {{private base class}} - dr142::B *bp1 = this; // expected-error {{private base class}} - B *bp2_old = (B*)this; // expected-error 2{{private member}} + B *bp1_old = this; // #dr142-bp1_old + // expected-error@#dr142-bp1_old {{'B' is a private member of 'dr142::B'}} + // expected-note@#dr142-D {{constrained by private inheritance here}} + // expected-note@#dr142-B {{member is declared here}} + // expected-error@#dr142-bp1_old {{cannot cast 'dr142::DD' to its private base class 'B'}} + // expected-note@#dr142-D {{declared private here}} + dr142::B *bp1 = this; + // expected-error@-1 {{cannot cast 'dr142::DD' to its private base class 'dr142::B'}} + // expected-note@#dr142-D {{declared private here}} + B *bp2_old = (B*)this; // #dr142-bp2_old + // expected-error@#dr142-bp2_old {{'B' is a private member of 'dr142::B'}} + // expected-note@#dr142-D {{constrained by private inheritance here}} + // expected-note@#dr142-B {{member is declared here}} + // expected-error@#dr142-bp2_old {{'B' is a private member of 'dr142::B'}} + // expected-note@#dr142-D {{constrained by private inheritance here}} + // expected-note@#dr142-B {{member is declared here}} dr142::B *bp2 = (dr142::B*)this; bp2->mi = 3; } @@ -553,19 +691,19 @@ namespace dr143 { // dr143: yes struct X { friend void B::f(X); }; } void g(A::X x) { - f(x); // expected-error {{undeclared identifier 'f'}} + f(x); + // expected-error@-1 {{use of undeclared identifier 'f'}} } } namespace dr145 { // dr145: yes void f(bool b) { -#if __cplusplus <= 201402L - ++b; // expected-warning {{deprecated}} - b++; // expected-warning {{deprecated}} -#else - ++b; // expected-error {{increment}} - b++; // expected-error {{increment}} -#endif + ++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}} } } @@ -576,13 +714,15 @@ namespace dr147 { // dr147: yes }; // Per core issue 1435, this is ill-formed because A::A does not // name the injected-class-name. (A::A does, though.) - template<> template<> A::A(int) {} // expected-error {{out-of-line constructor for 'A' cannot have template arguments}} + template<> template<> A::A(int) {} + // expected-error@-1 {{out-of-line constructor for 'A' cannot have template arguments}} template<> template<> A::A(float) {} } namespace example2 { struct A { A(); }; struct B : A { B(); }; - A::A a1; // expected-error {{is a constructor}} + 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 { @@ -590,7 +730,8 @@ namespace dr147 { // dr147: yes template A(T); static A a; }; - template<> A::A(A::a); // expected-error {{is a constructor}} + template<> A::A(A::a); + // expected-error@-1 {{qualified reference to 'A' is a constructor name rather than a template name in this context}} } } @@ -616,24 +757,28 @@ namespace dr151 { // dr151: 3.1 namespace dr152 { // dr152: yes struct A { - A(); // expected-note 0-2{{not viable}} - explicit A(const A&); // expected-note 1-2{{not a candidate}} + A(); // #dr152-A-ctor + explicit A(const A&); // #dr152-A-explicit-ctor }; A a1 = A(); -#if __cplusplus <= 201402L - // expected-error@-2 {{no matching constructor}} -#endif + // cxx98-14-error@-1 {{no matching constructor for initialization of 'A'}} + // cxx98-14-note@#dr152-A-explicit-ctor {{explicit constructor is not a candidate}} + // cxx98-14-note@#dr152-A-ctor {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} A a2((A())); A &f(); - A a3 = f(); // expected-error {{no matching constructor}} + A a3 = f(); + // expected-error@-1 {{no matching constructor for initialization of 'A'}} + // expected-note@#dr152-A-explicit-ctor {{explicit constructor is not a candidate}} + // expected-note@#dr152-A-ctor {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} A a4(f()); } // dr153: na namespace dr154 { // dr154: yes - union { int a; }; // expected-error {{must be declared 'static'}} + union { int a; }; + // expected-error@-1 {{nonymous unions at namespace or global scope must be declared 'static'}} namespace { union { int b; }; } @@ -641,7 +786,8 @@ namespace dr154 { // dr154: yes } namespace dr155 { // dr155: dup 632 - struct S { int n; } s = { { 1 } }; // expected-warning {{braces around scalar initializer}} + struct S { int n; } s = { { 1 } }; + // expected-warning@-1 {{braces around scalar initializer}} } // dr158 is in its own file. @@ -649,7 +795,8 @@ namespace dr155 { // dr155: dup 632 namespace dr159 { // dr159: 3.5 namespace X { void f(); } void f(); - void dr159::f() {} // expected-warning {{extra qualification}} + void dr159::f() {} + // expected-warning@-1 {{extra qualification on member 'f'}} void dr159::X::f() {} } @@ -658,9 +805,9 @@ namespace dr159 { // dr159: 3.5 namespace dr161 { // dr161: 3.1 class A { protected: - struct B { int n; } b; // expected-note 2{{here}} + struct B { int n; } b; // #dr161-B static B bs; - void f(); // expected-note {{here}} + void f(); // #dr161-f static void sf(); }; struct C : A {}; @@ -669,13 +816,19 @@ namespace dr161 { // dr161: 3.1 (void)b.n; B b1; C::B b2; // ok, accessible as a member of A - (void)&C::b; // expected-error {{protected}} + (void)&C::b; + // expected-error@-1 {{'b' is a protected member of 'dr161::A'}} + // expected-note@#dr161-B {{declared protected here}} (void)&C::bs; - (void)c.b; // expected-error {{protected}} + (void)c.b; + // expected-error@-1 {{'b' is a protected member of 'dr161::A'}} + // expected-note@#dr161-B {{declared protected here}} (void)c.bs; f(); sf(); - c.f(); // expected-error {{protected}} + c.f(); + // expected-error@-1 {{protected}} + // expected-note@#dr161-f {{declared protected here}} c.sf(); A::f(); D::f(); @@ -692,13 +845,17 @@ namespace dr162 { // dr162: no static int &f(int); void g() { - int &a = (&A::f)(0); // FIXME: expected-error {{could not be resolved}} - char &b = (&A::f)('0'); // expected-error {{could not be resolved}} + int &a = (&A::f)(0); + // FIXME: expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} + char &b = (&A::f)('0'); + // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} } }; - int &c = (&A::f)(0); // FIXME: expected-error {{could not be resolved}} - char &d = (&A::f)('0'); // expected-error {{could not be resolved}} + int &c = (&A::f)(0); + // FIXME: expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} + char &d = (&A::f)('0'); + // expected-error@-1 {{reference to overloaded function could not be resolved; did you mean to call it?}} } // dr163: na @@ -729,7 +886,10 @@ namespace dr166 { // dr166: 2.9 template int f(T t) { return t.n; } int g(A::X); - template int h(T t) { return t.n; } // expected-error {{private}} + template int h(T t) { return t.n; } + // expected-error@-1 {{'n' is a private member of 'dr166::A::X'}} + // expected-note@#dr166-h-instantiation {{in instantiation of function template specialization 'dr166::h' requested here}} + // expected-note@#dr166-X-n {{implicitly declared private here}} int i(A::X); namespace A { @@ -738,7 +898,7 @@ namespace dr166 { // dr166: 2.9 friend int dr166::g(X); friend int h(X); friend int i(X); - int n; // expected-note 2{{here}} + int n; // #dr166-X-n }; int h(X x) { return x.n; } @@ -747,8 +907,10 @@ namespace dr166 { // dr166: 2.9 template int f(A::X); int g(A::X x) { return x.n; } - template int h(A::X); // expected-note {{instantiation}} - int i(A::X x) { return x.n; } // expected-error {{private}} + template int h(A::X); // #dr166-h-instantiation + int i(A::X x) { return x.n; } + // expected-error@-1 {{'n' is a private member of 'dr166::A::X'}} + // expected-note@#dr166-X-n {{implicitly declared private here}} } // dr167: sup 1012 @@ -768,23 +930,29 @@ namespace dr169 { // dr169: yes struct B { template struct C; template void f(); - template static int n; // expected-error 0-1{{extension}} + template static int n; + // cxx98-11-error@-1 {{variable templates are a C++14 extension}} }; struct D : A, B { using A::n; - using B::C; // expected-error {{using declaration cannot refer to a template specialization}} - using B::f; // expected-error {{using declaration cannot refer to a template specialization}} - using B::n; // expected-error {{using declaration cannot refer to a template specialization}} + using B::C; + // expected-error@-1 {{using declaration cannot refer to a template specialization}} + using B::f; + // expected-error@-1 {{using declaration cannot refer to a template specialization}} + using B::n; + // expected-error@-1 {{using declaration cannot refer to a template specialization}} }; } namespace { // dr171: yes int dr171a; } -int dr171b; // expected-note {{here}} +int dr171b; // #dr171b-int namespace dr171 { extern "C" void dr171a(); - extern "C" void dr171b(); // expected-error {{conflicts}} + extern "C" void dr171b(); + // expected-error@-1 {{declaration of 'dr171b' with C language linkage conflicts with declaration in global scope}} + // expected-note@#dr171b-int {{declared in global scope here}} } namespace dr172 { // dr172: yes @@ -810,12 +978,14 @@ namespace dr172 { // dr172: yes int check6a[sizeof(d) == sizeof(unsigned long) ? 1 : -1]; int check6b[-d > 0 ? 1 : -1]; - enum { e = (unsigned long long)-1 / 2 }; // expected-error 0-1{{extension}} - int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; // expected-error 0-1{{extension}} + enum { e = (unsigned long long)-1 / 2 }; + // cxx98-error@-1 {{'long long' is a C++11 extension}} + int check7a[sizeof(e) == sizeof(long) ? 1 : -1]; int check7b[-e < 0 ? 1 : -1]; - enum { f = (unsigned long long)-1 / 2 + 1 }; // expected-error 0-1{{extension}} - int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; // expected-error 0-1{{extension}} + enum { f = (unsigned long long)-1 / 2 + 1 }; + // cxx98-error@-1 {{'long long' is a C++11 extension}} + int check8a[sizeof(f) == sizeof(unsigned long) ? 1 : -1]; int check8b[-f > 0 ? 1 : -1]; } @@ -828,10 +998,13 @@ namespace dr173 { // dr173: yes // dr174: sup 1012 namespace dr175 { // dr175: 2.8 - struct A {}; // expected-note {{here}} - struct B : private A {}; // expected-note {{constrained by private inheritance}} + struct A {}; // #dr175-A + struct B : private A {}; // #dr175-B struct C : B { - A a; // expected-error {{private}} + A a; + // expected-error@-1 {{'A' is a private member of 'dr175::A'}} + // expected-note@#dr175-B {{constrained by private inheritance here}} + // expected-note@#dr175-A {{member is declared here}} dr175::A b; }; } @@ -840,12 +1013,14 @@ namespace dr176 { // dr176: 3.1 template class Y; template<> class Y { void f() { - typedef Y A; // expected-note {{here}} - typedef Y A; // expected-error {{different types ('Y' vs 'Y')}} + typedef Y A; // #dr176-A-first + typedef Y A; + // expected-error@-1 {{typedef redefinition with different types ('Y' vs 'Y')}} + // expected-note@#dr176-A-first {{previous definition is here}} } }; - template struct Base {}; // expected-note 2{{found}} + template struct Base {}; // #dr176-Base template struct Derived : public Base { void f() { typedef typename Derived::template Base A; @@ -855,35 +1030,44 @@ namespace dr176 { // dr176: 3.1 template struct Derived; template struct Derived2 : Base, Base { - typename Derived2::Base b; // expected-error {{found in multiple base classes}} + typename Derived2::Base b; + // expected-error@-1 {{member 'Base' found in multiple base classes of different types}} + // expected-note@#dr176-Base {{member type 'dr176::Base' found by ambiguous name lookup}} + // expected-note@#dr176-Base {{member type 'dr176::Base' found by ambiguous name lookup}} typename Derived2::Base d; }; - template class X { // expected-note {{here}} + template class X { // #dr176-X X *p1; X *p2; X *p3; - dr176::X *p4; // expected-error {{requires template arguments}} + dr176::X *p4; // #dr176-p4 + // cxx98-14-error@#dr176-p4 {{use of class template 'dr176::X' requires template arguments}} + // cxx98-14-note@#dr176-X {{template is declared here}} + // since-cxx17-error@#dr176-p4 {{use of class template 'X' requires template arguments; argument deduction not allowed in non-static class member}} + // since-cxx17-note@#dr176-X {{template is declared here}} }; } namespace dr177 { // dr177: yes struct B {}; struct A { - A(A &); // expected-note 0-1{{not viable: expects an lvalue}} - A(const B &); // expected-note 0-1{{not viable: no known conversion from 'A' to}} + A(A &); // #dr177-A-copy-ctor + A(const B &); // #dr177-A-ctor-from-B }; B b; A a = b; -#if __cplusplus <= 201402L - // expected-error@-2 {{no viable constructor copying variable}} -#endif + // cxx98-14-error@-1 {{no viable constructor copying variable of type 'A'}} + // cxx98-14-note@#dr177-A-copy-ctor {{candidate constructor not viable: expects an lvalue for 1st argument}} + // cxx98-14-note@#dr177-A-ctor-from-B {{candidate constructor not viable: no known conversion from 'A' to 'const B &' for 1st argument}} - struct C { C(C&); }; // expected-note {{not viable: expects an lvalue for 1st argument}} + struct C { C(C&); }; // #dr177-C-copy-ctor struct D : C {}; struct E { operator D(); }; E e; - C c = e; // expected-error {{no viable constructor copying variable of type 'D'}} + C c = e; + // expected-error@-1 {{no viable constructor copying variable of type 'D'}} + // expected-note@#dr177-C-copy-ctor {{candidate constructor not viable: expects an lvalue for 1st argument}} } namespace dr178 { // dr178: yes @@ -901,7 +1085,8 @@ namespace dr178 { // dr178: yes namespace dr179 { // dr179: yes void f(); - int n = &f - &f; // expected-error {{arithmetic on pointers to the function type 'void ()'}} + int n = &f - &f; + // expected-error@-1 {{arithmetic on pointers to the function type 'void ()'}} } namespace dr180 { // dr180: 2.8 @@ -916,8 +1101,10 @@ namespace dr180 { // dr180: 2.8 namespace dr181 { // dr181: yes namespace X { - template