[cfe-commits] r130411 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/address-space-references.cpp

Douglas Gregor dgregor at apple.com
Thu Apr 28 10:56:11 PDT 2011


Author: dgregor
Date: Thu Apr 28 12:56:11 2011
New Revision: 130411

URL: http://llvm.org/viewvc/llvm-project?rev=130411&view=rev
Log:
When determining whether two types are reference-compatible, check
non-CVR qualifiers as well as CVR qualifiers. For example, don't allow
a reference to an integer in address space 1 to bind to an integer in
address space 2.

Added:
    cfe/trunk/test/SemaCXX/address-space-references.cpp   (with props)
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=130411&r1=130410&r2=130411&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Apr 28 12:56:11 2011
@@ -3071,7 +3071,12 @@
   //   overload resolution, cases for which cv1 is greater
   //   cv-qualification than cv2 are identified as
   //   reference-compatible with added qualification (see 13.3.3.2).
-  if (T1Quals.getCVRQualifiers() == T2Quals.getCVRQualifiers())
+  //
+  // Note that we also require equivalence of Objective-C GC and address-space
+  // qualifiers when performing these computations, so that e.g., an int in
+  // address space 1 is not reference-compatible with an int in address
+  // space 2.
+  if (T1Quals == T2Quals)
     return Ref_Compatible;
   else if (T1.isMoreQualifiedThan(T2))
     return Ref_Compatible_With_Added_Qualification;

Added: cfe/trunk/test/SemaCXX/address-space-references.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/address-space-references.cpp?rev=130411&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/address-space-references.cpp (added)
+++ cfe/trunk/test/SemaCXX/address-space-references.cpp Thu Apr 28 12:56:11 2011
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int __attribute__((address_space(1))) int_1;
+typedef int __attribute__((address_space(2))) int_2;
+
+void f0(int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \
+// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}}
+void f0(const int_1 &); // expected-note{{candidate function not viable: 1st argument ('int') is in address space 0, but parameter must be in address space 1}} \
+// expected-note{{candidate function not viable: 1st argument ('int_2' (aka '__attribute__((address_space(2))) int')) is in address space 2, but parameter must be in address space 1}}
+
+void test_f0() {
+  int i;
+  static int_1 i1;
+  static int_2 i2;
+
+  f0(i); // expected-error{{no matching function for call to 'f0'}}
+  f0(i1);
+  f0(i2); // expected-error{{no matching function for call to 'f0'}}
+}

Propchange: cfe/trunk/test/SemaCXX/address-space-references.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/SemaCXX/address-space-references.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/SemaCXX/address-space-references.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the cfe-commits mailing list