Author: stulova Date: Wed Jun 5 07:50:01 2019 New Revision: 362611 URL: http://llvm.org/viewvc/llvm-project?rev=362611&view=rev Log: [OpenCL][PR42031] Prevent deducing addr space in type alias. Similar to typedefs we shouldn't deduce addr space in type alias. Differential Revision: https://reviews.llvm.org/D62591
Modified: cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=362611&r1=362610&r2=362611&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jun 5 07:50:01 2019 @@ -7401,6 +7401,9 @@ static void deduceOpenCLImplicitAddrSpac (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. Modified: cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl?rev=362611&r1=362610&r2=362611&view=diff ============================================================================== --- cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl (original) +++ cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl Wed Jun 5 07:50:01 2019 @@ -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; +}; + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits