diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -12640,6 +12640,8 @@ return; } } + // The declaration is unitialized, no need for further checks. + return; } VarDecl::DefinitionKind DefKind = Var->isThisDeclarationADefinition(); diff --git a/clang/test/CodeGen/attr-loader-uninitialized.c b/clang/test/CodeGen/attr-loader-uninitialized.c --- a/clang/test/CodeGen/attr-loader-uninitialized.c +++ b/clang/test/CodeGen/attr-loader-uninitialized.c @@ -18,7 +18,19 @@ } s; // CHECK: @i ={{.*}} global %struct.s undef +// CHECK: @j1 ={{.*}}addrspace(1) global %struct.s undef +// CHECK: @j2 ={{.*}}addrspace(2) global %struct.s undef +// CHECK: @j3 ={{.*}}addrspace(3) global %struct.s undef +// CHECK: @j4 ={{.*}}addrspace(4) global %struct.s undef +// CHECK: @j5 ={{.*}}addrspace(5) global %struct.s undef +// CHECK: @j99 ={{.*}}addrspace(99) global %struct.s undef s i __attribute__((loader_uninitialized)); +s j1 __attribute__((loader_uninitialized, address_space(1))); +s j2 __attribute__((loader_uninitialized, address_space(2))); +s j3 __attribute__((loader_uninitialized, address_space(3))); +s j4 __attribute__((loader_uninitialized, address_space(4))); +s j5 __attribute__((loader_uninitialized, address_space(5))); +s j99 __attribute__((loader_uninitialized, address_space(99))); // CHECK: @private_extern_ok = hidden global i32 undef __private_extern__ int private_extern_ok __attribute__((loader_uninitialized)); diff --git a/clang/test/OpenMP/declare_target_codegen.cpp b/clang/test/OpenMP/declare_target_codegen.cpp --- a/clang/test/OpenMP/declare_target_codegen.cpp +++ b/clang/test/OpenMP/declare_target_codegen.cpp @@ -37,6 +37,7 @@ // CHECK-DAG: @fff_decl_tgt_ref_ptr = weak global i32* null // CHECK-DAG: @eee_decl_tgt_ref_ptr = weak global i32* null // CHECK-DAG: @{{.*}}maini1{{.*}}aaa = internal global i64 23, +// CHECK-DAG: @pair = {{.*}}addrspace(3) global %struct.PAIR undef // CHECK-DAG: @b ={{ hidden | }}global i32 15, // CHECK-DAG: @d ={{ hidden | }}global i32 0, // CHECK-DAG: @c = external global i32, @@ -264,6 +265,15 @@ // DEV5-NOT: define {{.*}}void {{.*}}host_fun{{.*}} #endif // OMP5 +struct PAIR { + int a; + int b; +}; + +#pragma omp declare target +PAIR pair __attribute__((address_space(3), loader_uninitialized)); +#pragma omp end declare target + #endif // HEADER #ifdef LOAD diff --git a/clang/test/Sema/attr-loader-uninitialized.cpp b/clang/test/Sema/attr-loader-uninitialized.cpp --- a/clang/test/Sema/attr-loader-uninitialized.cpp +++ b/clang/test/Sema/attr-loader-uninitialized.cpp @@ -5,7 +5,6 @@ int hidden_ok __attribute__((visibility("hidden"))) __attribute__((loader_uninitialized)); const int still_cant_be_const __attribute__((loader_uninitialized)); -// expected-error@-1 {{default initialization of an object of const type}} extern int external_rejected __attribute__((loader_uninitialized)); // expected-error@-1 {{variable 'external_rejected' cannot be declared both 'extern' and with the 'loader_uninitialized' attribute}}