[PATCH] D57101: [AST] Fix addr space of result type for dereference operator
Anastasia Stulova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 23 08:47:19 PST 2019
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
When we dereference a pointer the result of the dereference operation is no longer in the address space of its pointee i.e.
__attribute__((address_space(1))) int * a;
(*a);// the expression is in the default addr space and not in addr space 1.
https://reviews.llvm.org/D57101
Files:
lib/Sema/SemaExpr.cpp
test/SemaOpenCLCXX/address_space_overloading.cl
Index: test/SemaOpenCLCXX/address_space_overloading.cl
===================================================================
--- test/SemaOpenCLCXX/address_space_overloading.cl
+++ test/SemaOpenCLCXX/address_space_overloading.cl
@@ -1,12 +1,12 @@
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
-// FIXME: This test shouldn't trigger any errors.
+// expected-no-diagnostics
struct RetGlob {
int dummy;
};
-struct RetGen { //expected-error{{binding value of type '__generic RetGen' to reference to type 'RetGen' drops <<ERROR>> qualifiers}}
+struct RetGen {
char dummy;
};
@@ -19,5 +19,5 @@
__local int *ArgLoc;
RetGlob TestGlob = foo(ArgGlob);
RetGen TestGen = foo(ArgGen);
- TestGen = foo(ArgLoc); //expected-note{{in implicit copy assignment operator for 'RetGen' first required here}}
+ TestGen = foo(ArgLoc);
}
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -12997,6 +12997,8 @@
Input = DefaultFunctionArrayLvalueConversion(Input.get());
if (Input.isInvalid()) return ExprError();
resultType = CheckIndirectionOperand(*this, Input.get(), VK, OpLoc);
+ // The result type of a dereferenced object is in the default addr space.
+ resultType = Context.removeAddrSpaceQualType(resultType);
break;
}
case UO_Plus:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57101.183106.patch
Type: text/x-patch
Size: 1397 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190123/ff5d40c8/attachment-0001.bin>
More information about the cfe-commits
mailing list