xref: /aosp_15_r20/external/clang/test/SemaCXX/pragma-init_seg.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32
2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++98 %s -triple x86_64-pc-win32
3*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++11 %s -triple x86_64-pc-win32
4*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple i386-apple-darwin13.3.0
5*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++98 %s -triple i386-apple-darwin13.3.0
6*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++11 %s -triple i386-apple-darwin13.3.0
7*67e74705SXin Li 
8*67e74705SXin Li #ifndef __APPLE__
9*67e74705SXin Li #pragma init_seg(L".my_seg") // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}
10*67e74705SXin Li #pragma init_seg( // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}}
11*67e74705SXin Li #pragma init_seg asdf // expected-warning {{missing '('}}
12*67e74705SXin Li #pragma init_seg) // expected-warning {{missing '('}}
13*67e74705SXin Li #pragma init_seg("a" "b") // no warning
14*67e74705SXin Li #pragma init_seg("a", "b") // expected-warning {{missing ')'}}
15*67e74705SXin Li #pragma init_seg("a") asdf // expected-warning {{extra tokens at end of '#pragma init_seg'}}
16*67e74705SXin Li #pragma init_seg("\x") // expected-error {{\x used with no following hex digits}}
17*67e74705SXin Li #pragma init_seg("a" L"b") // expected-warning {{expected non-wide string literal in '#pragma init_seg'}}
18*67e74705SXin Li 
19*67e74705SXin Li #pragma init_seg(compiler)
20*67e74705SXin Li #else
21*67e74705SXin Li #pragma init_seg(compiler) // expected-warning {{'#pragma init_seg' is only supported when targeting a Microsoft environment}}
22*67e74705SXin Li #endif
23*67e74705SXin Li 
24*67e74705SXin Li int f();
25*67e74705SXin Li int __declspec(thread) x = f(); // expected-error {{initializer for thread-local variable must be a constant expression}}
26*67e74705SXin Li #if __cplusplus >= 201103L
27*67e74705SXin Li // expected-note@-2 {{use 'thread_local' to allow this}}
28*67e74705SXin Li #endif
29