xref: /aosp_15_r20/external/clang/test/SemaCXX/writable-strings-deprecated.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s -DWARNING
2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s -DWARNING
3*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-deprecated-writable-strings -verify %s
4*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-deprecated -Wdeprecated-increment-bool -verify %s
5*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -fwritable-strings -verify %s
6*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-write-strings -verify %s
7*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror=c++11-compat -verify %s -DERROR
8*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror=deprecated -Wno-error=deprecated-increment-bool -verify %s -DERROR
9*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -DWARNING
10*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wno-deprecated -Wdeprecated-increment-bool -DWARNING
11*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -pedantic-errors -DERROR
12*67e74705SXin Li // rdar://8827606
13*67e74705SXin Li 
fun(void)14*67e74705SXin Li char *fun(void)
15*67e74705SXin Li {
16*67e74705SXin Li    return "foo";
17*67e74705SXin Li #if defined(ERROR)
18*67e74705SXin Li #if __cplusplus >= 201103L
19*67e74705SXin Li    // expected-error@-3 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
20*67e74705SXin Li #else
21*67e74705SXin Li    // expected-error@-5 {{conversion from string literal to 'char *' is deprecated}}
22*67e74705SXin Li #endif
23*67e74705SXin Li #elif defined(WARNING)
24*67e74705SXin Li #if __cplusplus >= 201103L
25*67e74705SXin Li    // expected-warning@-9 {{ISO C++11 does not allow conversion from string literal to 'char *'}}
26*67e74705SXin Li #else
27*67e74705SXin Li    // expected-warning@-11 {{conversion from string literal to 'char *' is deprecated}}
28*67e74705SXin Li #endif
29*67e74705SXin Li #endif
30*67e74705SXin Li }
31*67e74705SXin Li 
test(bool b)32*67e74705SXin Li void test(bool b)
33*67e74705SXin Li {
34*67e74705SXin Li   ++b; // expected-warning {{incrementing expression of type bool is deprecated}}
35*67e74705SXin Li }
36