summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaType.cpp3
-rw-r--r--clang/test/SemaOpenCLCXX/address-space-deduction.cl20
2 files changed, 20 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 27f034bd140..47de398d4fd 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7401,6 +7401,9 @@ static void deduceOpenCLImplicitAddrSpace(TypeProcessingState &State,
(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.
diff --git a/clang/test/SemaOpenCLCXX/address-space-deduction.cl b/clang/test/SemaOpenCLCXX/address-space-deduction.cl
index d6dcc853a60..6b2a07cad74 100644
--- a/clang/test/SemaOpenCLCXX/address-space-deduction.cl
+++ b/clang/test/SemaOpenCLCXX/address-space-deduction.cl
@@ -1,12 +1,26 @@
-//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;
};
+
+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;
+};
+
OpenPOWER on IntegriCloud