[flang-commits] [flang] [libcxx] [lld] [libc] [clang] [lldb] [llvm] [clang][NFC] Refactor expected directives in C++ DRs 100-199 (PR #74061)

via flang-commits flang-commits at lists.llvm.org
Fri Dec 1 03:17:40 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)

<details>
<summary>Changes</summary>

This patch continues the work started with ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding PR for details.

---

Patch is 54.76 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/74061.diff


1 Files Affected:

- (modified) clang/test/CXX/drs/dr1xx.cpp (+436-248) 


``````````diff
diff --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp
index 50236eb7c9499d4..e80999e7a2d0cff 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<const char (*)[4]> struct A {}; // expected-note 0-1{{declared here}}
-  template<const char (&)[4]> struct B {}; // expected-note 0-1{{declared here}}
-  template<const char *> struct C {}; // expected-note 0-1{{declared here}}
-  template<const char &> 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<const char (*)[4]> struct A {}; // #dr100-A
+  template<const char (&)[4]> struct B {}; // #dr100-B
+  template<const char *> struct C {}; // #dr100-C
+  template<const char &> 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<typename T> T f(T a, T b) { return a + b; } // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
+    template<typename T> T f(T a, T b) { return a + b; }
+    // expected-error at -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<dr102::B::S>' 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 at -1 {{'const' qualifier on reference type 'r1' (aka 'int &') has no effect}}
+  typedef const r1 &r1;
+  // expected-warning at -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 at -1 {{'const' qualifier on reference type 'r2' (aka 'const int &') has no effect}}
+  typedef const r2 &r2;
+  // expected-warning at -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<typename T> struct A {
     struct B { typedef int X; };
     B::X x;
-#if __cplusplus <= 201703L
-    // expected-error at -2 {{implicit 'typename' is a C++20 extension}}
-#endif
-    struct C : B { X x; }; // expected-error {{unknown type name}}
+    // cxx98-17-error at -1 {{missing 'typename' prior to dependent type name B::X; implicit 'typename' is a C++20 extension}}
+    struct C : B { X x; };
+    // expected-error at -1 {{unknown type name 'X'}}
   };
   template<> struct A<int>::B { int X; };
 }
@@ -87,46 +94,55 @@ namespace dr108 { // dr108: 2.9
 namespace dr109 { // dr109: yes
   struct A { template<typename T> void f(T); };
   template<typename T> struct B : T {
-    using T::template f; // expected-error {{'template' keyword not permitted here}}
-    using T::template f<int>; // expected-error {{'template' keyword not permitted here}} expected-error {{using declaration cannot refer to a template specialization}}
+    using T::template f;
+    // expected-error at -1 {{'template' keyword not permitted here}}
+    using T::template f<int>;
+    // expected-error at -1 {{'template' keyword not permitted here}}
+    // expected-error at -2 {{using declaration cannot refer to a template specialization}}
     // FIXME: We shouldn't suggest using the 'template' keyword in a location where it's not valid.
-    using T::f<int>; // expected-error {{use 'template' keyword}} expected-error {{using declaration cannot refer to a template specialization}}
-    void g() { this->f<int>(123); } // expected-error {{use 'template' keyword}}
+    using T::f<int>;
+    // expected-error at -1 {{use 'template' keyword to treat 'f' as a dependent template name}}
+    // expected-error at -2 {{using declaration cannot refer to a template specialization}}
+    void g() { this->f<int>(123); }
+    // expected-error at -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 at -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<const volatile T*> struct X {};
+  // FIXME: Test this somehow in C++11 and on.
   X<a1> x1;
+  // cxx98-error at -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<a2> x2;
   X<a3> x3;
+  // cxx98-error at -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<a4> x4;
-#if __cplusplus < 201103L
-  // expected-error at -5 {{internal linkage}} expected-note at -10 {{here}}
-  // expected-error at -4 {{internal linkage}} expected-note at -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 at -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<typename T> void f(T);
     void g() { f(0); }
-  } b; // expected-error {{abstract}}
+  } b;
+  // expected-error at -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<typename T> int f(T); // expected-note +{{}}
-  template<typename T> int g(T); // expected-note +{{}}
-  template<typename T> int g(T, int); // expected-note +{{}}
+  template<typename T> int f(T); // #dr115-f
+  template<typename T> int g(T); // #dr115-g
+  template<typename T> int g(T, int); // #dr115-g-int
 
-  int k1 = f(&f); // expected-error {{no match}}
+  int k1 = f(&f);
+  // expected-error at -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>);
-  int k3 = f(&g<int>); // expected-error {{no match}}
+  int k3 = f(&g<int>);
+  // expected-error at -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 at -1 {{address of overloaded function 'f' cannot be cast to type 'void'}}
+    // expected-note@#dr115-f {{candidate function template}}
     (void)&f<int>;
-    (void)&g<int>; // 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<int>; // expected-warning {{unused}}
-    &g<int>; // expected-error {{reference to overloaded function could not be resolved}}
+    (void)&g<int>;
+    // expected-error at -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 at -1 {{reference to overloaded function could not be resolved; did you mean to call it?}}
+    // expected-note@#dr115-f {{possible target for call}}
+    &f<int>;
+    // expected-warning at -1 {{expression result unused}}
+    &g<int>;
+    // expected-error at -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<typename T> 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 at -1 {{cannot create a non-constant pointer to member function}}
   int k5 = f(&s.f<int>);
-  int k6 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}
+  int k6 = f(&s.g<int>);
+  // expected-error at -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 at -1 {{cannot create a non-constant pointer to member function}}
     (void)&s.f<int>;
-    (void)&s.g<int>; // expected-error {{non-constant pointer to member}}
-
-    &s.f; // expected-error {{non-constant pointer to member}}
-    &s.f<int>; // expected-warning {{unused}}
-    &s.g<int>; // expected-error {{non-constant pointer to member}}
+    (void)&s.g<int>;
+    // expected-error at -1 {{cannot create a non-constant pointer to member function}}
+
+    &s.f;
+    // expected-error at -1 {{cannot create a non-constant pointer to member function}}
+    &s.f<int>;
+    // expected-warning at -1 {{expression result unused}}
+    &s.g<int>;
+    // expected-error at -1 {{cannot create a non-constant pointer to member function}}
   }
 
   struct T {
@@ -188,40 +228,58 @@ namespace dr115 { // dr115: 3.0
     template<typename T> int g(T, int);
   } t;
 
-  int k7 = f(&s.f); // expected-error {{non-constant pointer to member}}
+  int k7 = f(&s.f);
+  // expected-error at -1 {{cannot create a non-constant pointer to member function}}
   int k8 = f(&s.f<int>);
-  int k9 = f(&s.g<int>); // expected-error {{non-constant pointer to member}}
+  int k9 = f(&s.g<int>);
+  // expected-error at -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 at -1 {{cannot create a non-constant pointer to member function}}
     (void)&s.f<int>;
-    (void)&s.g<int>; // expected-error {{non-constant pointer to member}}
-
-    &s.f; // expected-error {{non-constant pointer to member}}
-    &s.f<int>; // expected-warning {{unused}}
-    &s.g<int>; // expected-error {{non-constant pointer to member}}
+    (void)&s.g<int>;
+    // expected-error at -1 {{cannot create a non-constant pointer to member function}}
+
+    &s.f;
+    // expected-error at -1 {{cannot create a non-constant pointer to member function}}
+    &s.f<int>;
+    // expected-warning at -1 {{expression result unused}}
+    &s.g<int>;
+    // expected-error at -1 {{cannot create a non-constant pointer to member function}}
   }
 
 #if __cplusplus >= 201103L
   // Special case kicks in only if a template argument list is specified.
-  template<typename T=int> void with_default(); // expected-note +{{}}
-  int k10 = f(&with_default); // expected-error {{no matching function}}
+  template<typename T=int> void with_default(); // #dr115-with-default
+  int k10 = f(&with_default);
+  // expected-error at -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 at -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 at -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 at -1 {{expression result unused}}
   }
 #endif
 }
 
 namespace dr116 { // dr116: yes
   template<int> struct A {};
-  template<int N> void f(A<N>) {} // expected-note {{previous}}
-  template<int M> void f(A<M>) {} // expected-error {{redefinition}}
-  template<typename T> void f(A<sizeof(T)>) {} // expected-note {{previous}}
-  template<typename U> void f(A<sizeof(U)>) {} // expected-error {{redefinition}}
+  template<int N> void f(A<N>) {} // #dr116-f-N
+  template<int M> void f(A<M>) {}
+  // expected-error at -1 {{redefinition of 'f'}}
+  // expected-note@#dr116-f-N {{previous definition is here}}
+  template<typename T> void f(A<sizeof(T)>) {} // #dr116-f-T
+  template<typename U> void f(A<sizeof(U)>) {}
+  // expected-error at -1 {{redefinition of 'f'}}
+  // expected-note@#dr116-f-T {{previous definition is here}}
 }
 
 // dr117: na
@@ -235,7 +293,9 @@ namespace dr121 { // dr121: yes
   };
   template<typename T> struct Z {
     X::Y<T> x;
-    T::Y<T> y; // expected-error +{{}}
+    T::Y<T> y;
+    // expected-error at -1 {{use 'template' keyword to treat 'Y' as a dependent template name}}
+    // cxx98-17-error at -2 {{missing 'typename' prior to dependent type name T::Y; implicit 'typename' is a C++20 extension}}
   };
   Z<X> 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 at -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 {...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/74061


More information about the flang-commits mailing list