Skip to content

Commit e6917e9

Browse files
authored
[clang][NFC] Add test for CWG1898 "Use of “equivalent” in overload resolution" (#113439)
[CWG1898](https://cplusplus.github.io/CWG/issues/1898.html) Use of “equivalent” in overload resolution ==================== [P1787R6](https://wg21.link/p1787r6): > CWG1898 is resolved by explicitly using the defined term parameter-type-list. Except that now it's called non-object-parameter-type-list, which is defined in [dcl.fct] [p8](https://eel.is/c++draft/dcl.fct#8) and [p4](https://eel.is/c++draft/dcl.fct#8). As for the wording, the first sentence [\_N4140\_.[over.dcl]/1](https://timsong-cpp.github.io/cppwp/n4140/over.dcl#1) where the word "equivalent" was used: > Two function declarations of the same name refer to the same function if they are in the same scope and have equivalent parameter declarations ([over.load]). was replaced with what is now known as "corresponding overloads", defined in [[basic.scope.scope]/4](https://eel.is/c++draft/basic.scope#scope-4). The definition is present in P1787R6, but it's hard to reference, because the "corresponding overloads" term was coined later.
1 parent f24c1dd commit e6917e9

File tree

2 files changed

+84
-1
lines changed

2 files changed

+84
-1
lines changed

clang/test/CXX/drs/cwg18xx.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,3 +640,86 @@ namespace H {
640640
struct S s;
641641
}
642642
}
643+
644+
namespace cwg1898 { // cwg1898: 2.7
645+
void e(int) {} // #cwg1898-e
646+
void e(int) {}
647+
// expected-error@-1 {{redefinition of 'e'}}
648+
// expected-note@#cwg1898-e {{previous definition is here}}
649+
650+
void e2(int) {}
651+
void e2(long) {} // OK, different type
652+
653+
void f(int) {} // #cwg1898-f
654+
void f(const int) {}
655+
// expected-error@-1 {{redefinition of 'f'}}
656+
// expected-note@#cwg1898-f {{previous definition is here}}
657+
658+
void g(int) {} // #cwg1898-g
659+
void g(volatile int) {}
660+
// since-cxx20-warning@-1 {{volatile-qualified parameter type 'volatile int' is deprecated}}
661+
// expected-error@-2 {{redefinition of 'g'}}
662+
// expected-note@#cwg1898-g {{previous definition is here}}
663+
664+
void h(int *) {} // #cwg1898-h
665+
void h(int[]) {}
666+
// expected-error@-1 {{redefinition of 'h'}}
667+
// expected-note@#cwg1898-h {{previous definition is here}}
668+
669+
void h2(int *) {} // #cwg1898-h2
670+
void h2(int[2]) {}
671+
// expected-error@-1 {{redefinition of 'h2'}}
672+
// expected-note@#cwg1898-h2 {{previous definition is here}}
673+
674+
void h3(int (*)[2]) {} // #cwg1898-h3
675+
void h3(int [3][2]) {}
676+
// expected-error@-1 {{redefinition of 'h3'}}
677+
// expected-note@#cwg1898-h3 {{previous definition is here}}
678+
679+
void h4(int (*)[2]) {}
680+
void h4(int [3][3]) {} // OK, differ in non-top-level extent of array
681+
682+
void i(int *) {}
683+
void i(const int *) {} // OK, pointee cv-qualification is not discarded
684+
685+
void i2(int *) {} // #cwg1898-i2
686+
void i2(int * const) {}
687+
// expected-error@-1 {{redefinition of 'i2'}}
688+
// expected-note@#cwg1898-i2 {{previous definition is here}}
689+
690+
void j(void(*)()) {} // #cwg1898-j
691+
void j(void()) {}
692+
// expected-error@-1 {{redefinition of 'j'}}
693+
// expected-note@#cwg1898-j {{previous definition is here}}
694+
695+
void j2(void(int)) {} // #cwg1898-j2
696+
void j2(void(const int)) {}
697+
// expected-error@-1 {{redefinition of 'j2'}}
698+
// expected-note@#cwg1898-j2 {{previous definition is here}}
699+
700+
struct A {
701+
void k(int) {} // #cwg1898-k
702+
void k(int) {}
703+
// expected-error@-1 {{class member cannot be redeclared}}
704+
// expected-note@#cwg1898-k {{previous definition is here}}
705+
};
706+
707+
struct B : A {
708+
void k(int) {} // OK, shadows A::k
709+
};
710+
711+
void l() {}
712+
void l(...) {}
713+
714+
#if __cplusplus >= 201103L
715+
template <typename T>
716+
void m(T) {}
717+
template <typename... Ts>
718+
void m(Ts...) {}
719+
720+
template <typename T, typename U>
721+
void m2(T, U) {}
722+
template <typename... Ts, typename U>
723+
void m2(Ts..., U) {}
724+
#endif
725+
} // namespace cwg1898

clang/www/cxx_dr_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11219,7 +11219,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1121911219
<td><a href="https://cplusplus.github.io/CWG/issues/1898.html">1898</a></td>
1122011220
<td>CD6</td>
1122111221
<td>Use of &#8220;equivalent&#8221; in overload resolution</td>
11222-
<td class="unknown" align="center">Unknown</td>
11222+
<td class="full" align="center">Clang 2.7</td>
1122311223
</tr>
1122411224
<tr id="1899">
1122511225
<td><a href="https://cplusplus.github.io/CWG/issues/1899.html">1899</a></td>

0 commit comments

Comments
 (0)