mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-10 12:16:08 +00:00

Summary: I saw the same changes in the following review: https://reviews.llvm.org/D17438 I don't know in that way I could determine that atomic variable was initialized by macro ATOMIC_VAR_INIT. Anyway I added check that atomic variables can be initialize only in global scope. I think that we can discuss this change. Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D30643 llvm-svn: 299537
13 lines
740 B
Common Lisp
13 lines
740 B
Common Lisp
// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s
|
|
|
|
global atomic_int a1 = 0;
|
|
|
|
kernel void test_atomic_initialization() {
|
|
a1 = 1; // expected-error {{atomic variable can be assigned to a variable only in global address space}}
|
|
atomic_int a2 = 0; // expected-error {{atomic variable can be initialized to a variable only in global address space}}
|
|
private atomic_int a3 = 0; // expected-error {{atomic variable can be initialized to a variable only in global address space}}
|
|
local atomic_int a4 = 0; // expected-error {{'__local' variable cannot have an initializer}}
|
|
global atomic_int a5 = 0; // expected-error {{function scope variable cannot be declared in global address space}}
|
|
static global atomic_int a6 = 0;
|
|
}
|