xref: /aosp_15_r20/external/clang/test/Sema/predef.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s
2*67e74705SXin Li 
abcdefghi12(void)3*67e74705SXin Li void abcdefghi12(void) {
4*67e74705SXin Li  const char (*ss)[12] = &__func__;
5*67e74705SXin Li  static int arr[sizeof(__func__)==12 ? 1 : -1];
6*67e74705SXin Li }
7*67e74705SXin Li 
8*67e74705SXin Li char *X = __func__; // expected-warning {{predefined identifier is only valid}} \
9*67e74705SXin Li                        expected-warning {{initializing 'char *' with an expression of type 'const char [1]' discards qualifiers}}
10*67e74705SXin Li 
a()11*67e74705SXin Li void a() {
12*67e74705SXin Li   __func__[0] = 'a';  // expected-error {{variable is not assignable}}
13*67e74705SXin Li }
14*67e74705SXin Li 
15*67e74705SXin Li // rdar://6097892 - GCC permits this insanity.
16*67e74705SXin Li const char *b = __func__;  // expected-warning {{predefined identifier is only valid}}
17*67e74705SXin Li const char *c = __FUNCTION__; // expected-warning {{predefined identifier is only valid}}
18*67e74705SXin Li const char *d = __PRETTY_FUNCTION__; // expected-warning {{predefined identifier is only valid}}
19*67e74705SXin Li 
20