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

Richard Smith richard at metafoo.co.uk
Wed Feb 20 11:22:37 PST 2013


On Tue, Feb 19, 2013 at 9:58 PM, Matt Arsenault
<Matthew.Arsenault at amd.com>wrote:

>   I was thinking it was the pointee's address space. I've changed that and
> added that case to the test
>
> Hi rsmith,
>
> http://llvm-reviews.chandlerc.com/D426
>
> CHANGE SINCE LAST DIFF
>   http://llvm-reviews.chandlerc.com/D426?vs=1026&id=1029#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
> @@ -1678,8 +1678,7 @@
>          (CanonFrom.getLocalCVRQualifiers() !=
> CanonTo.getLocalCVRQualifiers()
>           || CanonFrom.getObjCGCAttr() != CanonTo.getObjCGCAttr()
>           || CanonFrom.getObjCLifetime() != CanonTo.getObjCLifetime()
> -         || (CanonFrom->isSamplerT() &&
> -           CanonFrom.getAddressSpace() != CanonTo.getAddressSpace()))) {
> +         || CanonFrom.getAddressSpace() != CanonTo.getAddressSpace())) {
>

How about simplifying these four lines to

  CanonFrom.getLocalQualifiers() != CanonTo.getLocalQualifiers()

Other than that, this LGTM.

       FromType = ToType;
>        CanonFrom = CanonTo;
>      }
> Index: test/SemaCXX/address-space-initialize.cpp
> ===================================================================
> --- /dev/null
> +++ test/SemaCXX/address-space-initialize.cpp
> @@ -0,0 +1,26 @@
> +// 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130220/a8d9801f/attachment.html>


More information about the cfe-commits mailing list