predef.c 776 B

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