[PATCH] D62591: [OpenCL][PR42031] Prevent deducing addr space in type alias.
Anastasia Stulova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 3 07:30:53 PDT 2019
Anastasia updated this revision to Diff 202721.
Anastasia added a comment.
- Exclude pointee from early return in addr space deduction
- Improved testing: added FileCheck and avoid testing unnecessary bits
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62591/new/
https://reviews.llvm.org/D62591
Files:
lib/Sema/SemaType.cpp
test/SemaOpenCLCXX/address-space-deduction.cl
Index: test/SemaOpenCLCXX/address-space-deduction.cl
===================================================================
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -1,13 +1,13 @@
-//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify
+//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify | FileCheck %s
//expected-no-diagnostics
-//CHECK: |-VarDecl foo {{.*}} 'const __global int' constexpr cinit
+//CHECK: |-VarDecl {{.*}} foo 'const __global int'
constexpr int foo = 0;
class c {
public:
- //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
+ //CHECK: `-VarDecl {{.*}} foo2 'const __global int'
static constexpr int foo2 = 0;
};
@@ -15,7 +15,7 @@
void xxx(T *in) {
// This pointer can't be deduced to generic because addr space
// will be taken from the template argument.
- //CHECK: `-VarDecl {{.*}} i 'T *' cinit
+ //CHECK: `-VarDecl {{.*}} i 'T *'
T *i = in;
}
@@ -23,3 +23,16 @@
int foo[10];
xxx(&foo[0]);
}
+
+struct c1 {};
+
+// We only deduce addr space in type alias in pointer types.
+//CHECK: TypeAliasDecl {{.*}} alias_c1 'c1'
+using alias_c1 = c1;
+//CHECK: TypeAliasDecl {{.*}} alias_c1_ptr '__generic c1 *'
+using alias_c1_ptr = c1 *;
+
+struct c2 {
+ alias_c1 y;
+ alias_c1_ptr ptr = &y;
+};
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7350,6 +7350,9 @@
(D.getContext() == DeclaratorContext::MemberContext &&
(!IsPointee &&
D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)) ||
+ // Do not deduce addr space of non-pointee in type alias because it
+ // doesn't define any object.
+ (D.getContext() == DeclaratorContext::AliasDeclContext && !IsPointee) ||
// Do not deduce addr space for types used to define a typedef and the
// typedef itself, except the pointee type of a pointer type which is used
// to define the typedef.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62591.202721.patch
Type: text/x-patch
Size: 2068 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190603/95da568c/attachment.bin>
More information about the cfe-commits
mailing list