// otherwise, the ordering rules for static functions against non-static
// functions don't make any sense.
//
- // C++98/03 doesn't have this provision, so instead we drop the
- // first argument of the free function, which seems to match
- // existing practice.
+ // C++98/03 doesn't have this provision but we've extended DR532 to cover
+ // it as wording was broken prior to it.
SmallVector<QualType, 4> Args1;
- unsigned Skip1 = 0, Skip2 = 0;
unsigned NumComparedArguments = NumCallArguments1;
if (!Method2 && Method1 && !Method1->isStatic()) {
- if (S.getLangOpts().CPlusPlus11) {
- // Compare 'this' from Method1 against first parameter from Method2.
- AddImplicitObjectParameterType(S.Context, Method1, Args1);
- ++NumComparedArguments;
- } else
- // Ignore first parameter from Method2.
- ++Skip2;
+ // Compare 'this' from Method1 against first parameter from Method2.
+ AddImplicitObjectParameterType(S.Context, Method1, Args1);
+ ++NumComparedArguments;
} else if (!Method1 && Method2 && !Method2->isStatic()) {
- if (S.getLangOpts().CPlusPlus11)
- // Compare 'this' from Method2 against first parameter from Method1.
- AddImplicitObjectParameterType(S.Context, Method2, Args2);
- else
- // Ignore first parameter from Method1.
- ++Skip1;
+ // Compare 'this' from Method2 against first parameter from Method1.
+ AddImplicitObjectParameterType(S.Context, Method2, Args2);
}
- Args1.insert(Args1.end(), Proto1->param_type_begin() + Skip1,
+ Args1.insert(Args1.end(), Proto1->param_type_begin(),
Proto1->param_type_end());
- Args2.insert(Args2.end(), Proto2->param_type_begin() + Skip2,
+ Args2.insert(Args2.end(), Proto2->param_type_begin(),
Proto2->param_type_end());
// C++ [temp.func.order]p5:
+++ /dev/null
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
-// expected-no-diagnostics
-
-// Core DR 532.
-namespace PR8130 {
- struct A { };
-
- template<class T> struct B {
- template<class R> int &operator*(R&);
- };
-
- template<class T, class R> float &operator*(T&, R&);
- void test() {
- A a;
- B<A> b;
- int &ir = b * a;
- }
-}
-
-namespace OperatorWithRefQualifier {
- struct A { };
- template<class T> struct B {
- template<class R> int &operator*(R&) &&;
- };
-
- template<class T, class R> float &operator*(T&&, R&);
- void test() {
- A a;
- B<A> b;
- float &ir = b * a;
- int &ir2 = B<A>() * a;
- }
-}
-
-namespace OrderWithStaticMember {
- struct A {
- template<class T> int g(T**, int=0) { return 0; }
- template<class T> static int g(T*) { return 1; }
- };
- void f() {
- A a;
- int **p;
- a.g(p);
- }
-}
-
-namespace PR17075 {
- template <typename T> struct V {};
- struct S { template<typename T> S &operator>>(T &t) = delete; };
- template<typename T> S &operator>>(S &s, V<T> &v);
- void f(S s, V<int> v) { s >> v; }
-}
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// expected-no-diagnostics
-namespace DeduceVsMember {
- template<typename T>
- struct X {
- template<typename U>
- int &operator==(const U& other) const;
- };
+// Core DR 532.
+namespace PR8130 {
+ struct A { };
- template<typename T, typename U>
- float &operator==(const T&, const X<U>&);
+ template<class T> struct B {
+ template<class R> int &operator*(R&);
+ };
- void test(X<int> xi, X<float> xf) {
- float& ir = (xi == xf);
+ template<class T, class R> float &operator*(T&, R&);
+ void test() {
+ A a;
+ B<A> b;
+ int &ir = b * a;
}
}
a.g(p);
}
}
+
+#if __cplusplus >= 201103L
+namespace OperatorWithRefQualifier {
+ struct A { };
+ template<class T> struct B {
+ template<class R> int &operator*(R&) &&;
+ };
+
+ template<class T, class R> float &operator*(T&&, R&);
+ void test() {
+ A a;
+ B<A> b;
+ float &ir = b * a;
+ int &ir2 = B<A>() * a;
+ }
+}
+
+namespace PR17075 {
+ template <typename T> struct V {};
+ struct S { template<typename T> S &operator>>(T &t) = delete; };
+ template<typename T> S &operator>>(S &s, V<T> &v);
+ void f(S s, V<int> v) { s >> v; }
+}
+#endif