[cfe-commits] r57942 - in /cfe/trunk: include/clang/AST/Type.h lib/Sema/SemaOverload.cpp test/SemaCXX/overload-call.cpp

Douglas Gregor doug.gregor at gmail.com
Tue Oct 21 17:38:22 PDT 2008


Author: dgregor
Date: Tue Oct 21 19:38:21 2008
New Revision: 57942

URL: http://llvm.org/viewvc/llvm-project?rev=57942&view=rev
Log:
Fix a thinko in the qualification-conversion check when the qualificaitons are disjoint, and add some overloading-based tests of qualification conversions

Modified:
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/overload-call.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=57942&r1=57941&r2=57942&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Oct 21 19:38:21 2008
@@ -178,7 +178,7 @@
   bool isAtLeastAsQualifiedAs(QualType Other) const {
     unsigned MyQuals = this->getCVRQualifiers();
     unsigned OtherQuals = Other.getCVRQualifiers();
-    return MyQuals | OtherQuals == MyQuals;
+    return (MyQuals | OtherQuals) == MyQuals;
   }
 
   /// operator==/!= - Indicate whether the specified types and qualifiers are

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=57942&r1=57941&r2=57942&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Oct 21 19:38:21 2008
@@ -685,7 +685,7 @@
 
     //   -- for every j > 0, if const is in cv 1,j then const is in cv
     //      2,j, and similarly for volatile.
-    if (FromType.isMoreQualifiedThan(ToType))
+    if (!ToType.isAtLeastAsQualifiedAs(FromType))
       return false;
 
     //   -- if the cv 1,j and cv 2,j are different, then const is in

Modified: cfe/trunk/test/SemaCXX/overload-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-call.cpp?rev=57942&r1=57941&r2=57942&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/overload-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-call.cpp Tue Oct 21 19:38:21 2008
@@ -135,3 +135,32 @@
   double* dp2 = multiparm(iv, sv, sv);
   multiparm(sv, sv, lv); // expected-error {{ call to 'multiparm' is ambiguous; candidates are: }}
 }
+
+// Test overloading based on qualification vs. no qualification
+// conversion.
+int* quals1(int const * p);
+char* quals1(int * p);
+
+int* quals2(int const * const * pp);
+char* quals2(int * * pp);
+
+int* quals3(int const * * const * ppp);
+char* quals3(int *** ppp);
+
+void test_quals(int * p, int * * pp, int * * * ppp) {
+  char* q1 = quals1(p);
+  char* q2 = quals2(pp);
+  char* q3 = quals3(ppp);
+}
+
+// Test overloading based on qualification ranking (C++ 13.3.2)p3.
+int* quals_rank1(int const * p);
+float* quals_rank1(int const volatile *p);
+
+int* quals_rank2(int const * const * pp);
+float* quals_rank2(int * const * pp);
+
+void test_quals_ranking(int * p, int volatile *pq, int * * pp, int * * * ppp) {
+  //  int* q1 = quals_rank1(p);
+  float* q2 = quals_rank1(pq); 
+}





More information about the cfe-commits mailing list