On Tue, Feb 19, 2013 at 3:44 PM, Matt Arsenault < [email protected]> wrote:
> Hi, > > I encountered this error when trying to use address_space when compiling > as C++, but not C. > > // No error > __attribute__((address_space(42))) > const float withc = 1.0f; > > // No error > __attribute__((address_space(42))) > volatile float withv = 1.0f; > > // Error > __attribute__((address_space(42))) > float nocv = 1.0f; > > > This would produce the error: > > as_initializer.cpp:12:7: error: cannot initialize a variable of type > '__attribute__((address_space(42))) float' with an rvalue of type > 'float' > float nocv = 1.0f; > ^ ~~~~ > 1 error generated. > > This patch adds a test for this case, and allows the conversion if the > address spaces are different for non-pointer types. I'm not really familiar > with the code so I'm not particularly confident that this is the correct > fix. Please review! > > http://llvm-reviews.chandlerc.com/D426 > > 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,7 +1678,7 @@ > (CanonFrom.getLocalCVRQualifiers() != > CanonTo.getLocalCVRQualifiers() > || CanonFrom.getObjCGCAttr() != CanonTo.getObjCGCAttr() > || CanonFrom.getObjCLifetime() != CanonTo.getObjCLifetime() > - || (CanonFrom->isSamplerT() && > + || (!CanonFrom->isAnyPointerType() && > Why should this not apply for pointer types? If I have a pointer-to-default-address-space in address space 42, I would think I should be able to initialize that with a pointer-to-default-address-space. I think that would make this whole check be just CanonFrom.getLocalUnqualifiedType() == CanonTo.getLocalUnqualifiedType() && CanonFrom.getLocalQualifiers() != CanonTo.getLocalQualifiers() > CanonFrom.getAddressSpace() != CanonTo.getAddressSpace()))) { > FromType = ToType; > CanonFrom = CanonTo; > Index: test/SemaCXX/address-space-initialize.cpp > =================================================================== > --- /dev/null > +++ test/SemaCXX/address-space-initialize.cpp > @@ -0,0 +1,24 @@ > +// 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]'}} > + > + > + > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
