]> granicus.if.org Git - clang/commitdiff
Fix ambiguity detection in GetBestOverloadCandidateSimple.
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 30 Jul 2012 15:53:26 +0000 (15:53 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 30 Jul 2012 15:53:26 +0000 (15:53 +0000)
When performing the simplistic overload resolution for single-argument methods,
don't check the best overload for ambiguity with itself when the best overload
doesn't happen to be the first one.

Fixes PR13480.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160961 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclCXX.cpp
test/SemaCXX/cxx98-compat.cpp

index 217b27a8d15fb678445900b7a9d5acc39440ae2b..eec2e9d3cf74031c0289f73ed1b75b540d1d368d 100644 (file)
@@ -344,8 +344,8 @@ GetBestOverloadCandidateSimple(
     if (Cands[Best].second.compatiblyIncludes(Cands[I].second))
       Best = I;
   
-  for (unsigned I = 1; I != N; ++I)
-    if (Cands[Best].second.compatiblyIncludes(Cands[I].second))
+  for (unsigned I = 0; I != N; ++I)
+    if (I != Best && Cands[Best].second.compatiblyIncludes(Cands[I].second))
       return 0;
   
   return Cands[Best].first;
index b9a8a1c65e707f1c0aa329725866c6a59dff656f..9bd854a6645a32e31bb6c8aca75f0efe3c6c9623 100644 (file)
@@ -335,3 +335,14 @@ namespace NullPointerTemplateArg {
   X<(int*)0> x; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}}
   Y<(int A::*)0> y; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}}
 }
+
+namespace PR13480 {
+  struct basic_iterator {
+    basic_iterator(const basic_iterator &it) {}
+    basic_iterator(basic_iterator &it) {} // expected-note {{because type 'PR13480::basic_iterator' has a user-declared copy constructor}}
+  };
+
+  union test {
+    basic_iterator it; // expected-warning {{union member 'it' with a non-trivial copy constructor is incompatible with C++98}}
+  };
+}