diff options
| author | Nikola Smiljanic <popizdeh@gmail.com> | 2014-05-31 02:10:59 +0000 |
|---|---|---|
| committer | Nikola Smiljanic <popizdeh@gmail.com> | 2014-05-31 02:10:59 +0000 |
| commit | 4461de208abfe5632f6b3f5e1d910829835e7baa (patch) | |
| tree | ff902a6d9868f4bdbeb0ec63478568d70e7c9aae /clang | |
| parent | 496524b4484bce312c7885dab25846e69498727f (diff) | |
| download | bcm5719-llvm-4461de208abfe5632f6b3f5e1d910829835e7baa.tar.gz bcm5719-llvm-4461de208abfe5632f6b3f5e1d910829835e7baa.zip | |
PR12961 - Extend DR532 to cover C++98/03.
llvm-svn: 209955
Diffstat (limited to 'clang')
3 files changed, 46 insertions, 82 deletions
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 008b833bf0c..7d9cec141a3 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -4178,34 +4178,24 @@ static bool isAtLeastAsSpecializedAs(Sema &S, // 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: diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp deleted file mode 100644 index 60c60cb0b28..00000000000 --- a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3-0x.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// 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; } -} diff --git a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp index 8212a125be6..a1f6374c3d5 100644 --- a/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp @@ -1,18 +1,20 @@ -// 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; } } @@ -27,3 +29,27 @@ namespace OrderWithStaticMember { 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 |

