[PATCH] Fix error when initializing a variable with address_space without a cv-qualifier in C++ mode

Matt Arsenault Matthew.Arsenault at amd.com
Wed Feb 20 12:23:10 PST 2013


  I wasn't going to touch those since I don't know what the ObjC stuff is, but OK

Hi rsmith,

http://llvm-reviews.chandlerc.com/D426

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D426?vs=1029&id=1048#toc

Files:
  lib/Sema/SemaOverload.cpp
  test/SemaCXX/address-space-initialize.cpp

Index: lib/Sema/SemaOverload.cpp
===================================================================
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -1675,11 +1675,7 @@
     CanonTo = S.Context.getCanonicalType(ToType);
     if (CanonFrom.getLocalUnqualifiedType()
                                        == CanonTo.getLocalUnqualifiedType() &&
-        (CanonFrom.getLocalCVRQualifiers() != CanonTo.getLocalCVRQualifiers()
-         || CanonFrom.getObjCGCAttr() != CanonTo.getObjCGCAttr()
-         || CanonFrom.getObjCLifetime() != CanonTo.getObjCLifetime()
-         || (CanonFrom->isSamplerT() && 
-           CanonFrom.getAddressSpace() != CanonTo.getAddressSpace()))) {
+        CanonFrom.getLocalQualifiers() != CanonTo.getLocalQualifiers()) {
       FromType = ToType;
       CanonFrom = CanonTo;
     }
Index: test/SemaCXX/address-space-initialize.cpp
===================================================================
--- /dev/null
+++ test/SemaCXX/address-space-initialize.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((address_space(42)))
+const float withc = 1.0f;
+
+__attribute__((address_space(42)))
+volatile float withv = 1.0f;
+
+__attribute__((address_space(42)))
+float nocv = 1.0f;
+
+__attribute__((address_space(42)))
+float nocv_array[10] = { 1.0f };
+
+__attribute__((address_space(42)))
+int nocv_iarray[10] = { 4 };
+
+
+__attribute__((address_space(9999)))
+int* as_ptr = nocv_iarray; // expected-error{{cannot initialize a variable of type '__attribute__((address_space(9999))) int *' with an lvalue of type '__attribute__((address_space(42))) int [10]'}}
+
+
+__attribute__((address_space(42))) int* __attribute__((address_space(42))) ptr_in_same_addr_space = nocv_iarray;
+__attribute__((address_space(42))) int* __attribute__((address_space(999))) ptr_in_different_addr_space = nocv_iarray;
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D426.3.patch
Type: text/x-patch
Size: 1879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130220/cd538f7d/attachment.bin>


More information about the cfe-commits mailing list