Add pedwarn.
(c_parser_postfix_expression) <case RID_PRETTY_FUNCTION_NAME>:
Likewise.
(c_parser_postfix_expression) <case RID_C99_FUNCTION_NAME>: Likewise.
* gcc.dg/concat.c: Add dg-options.
* gcc.dg/func-outside-2.c: Add __extension__.
* gcc.dg/pr19967.c: Use -std=c99.
* gcc.dg/pr22458-1.c: Add dg-options.
* gcc.dg/pr33676.c: Add dg-options.
* gcc.dg/gnu-predef-1.c: New test.
* gcc.dg/c90-func-1.c: New test.
* gcc.dg/c90-func-2.c: New test.
* gcc.dg/c90-func-2.h: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@213875
138bc75d-0d04-0410-961f-
82ee72b054a4
+2014-08-12 Marek Polacek <polacek@redhat.com>
+
+ * c-parser.c (c_parser_postfix_expression) <case RID_FUNCTION_NAME>:
+ Add pedwarn.
+ (c_parser_postfix_expression) <case RID_PRETTY_FUNCTION_NAME>:
+ Likewise.
+ (c_parser_postfix_expression) <case RID_C99_FUNCTION_NAME>: Likewise.
+
2014-08-10 Marek Polacek <polacek@redhat.com>
PR c/51849
switch (c_parser_peek_token (parser)->keyword)
{
case RID_FUNCTION_NAME:
+ pedwarn (loc, OPT_Wpedantic, "ISO C does not support "
+ "%<__FUNCTION__%> predefined identifier");
+ expr.value = fname_decl (loc,
+ c_parser_peek_token (parser)->keyword,
+ c_parser_peek_token (parser)->value);
+ c_parser_consume_token (parser);
+ break;
case RID_PRETTY_FUNCTION_NAME:
+ pedwarn (loc, OPT_Wpedantic, "ISO C does not support "
+ "%<__PRETTY_FUNCTION__%> predefined identifier");
+ expr.value = fname_decl (loc,
+ c_parser_peek_token (parser)->keyword,
+ c_parser_peek_token (parser)->value);
+ c_parser_consume_token (parser);
+ break;
case RID_C99_FUNCTION_NAME:
+ pedwarn_c90 (loc, OPT_Wpedantic, "ISO C90 does not support "
+ "%<__func__%> predefined identifier");
expr.value = fname_decl (loc,
c_parser_peek_token (parser)->keyword,
c_parser_peek_token (parser)->value);
+2014-08-12 Marek Polacek <polacek@redhat.com>
+
+ * gcc.dg/concat.c: Add dg-options.
+ * gcc.dg/func-outside-2.c: Add __extension__.
+ * gcc.dg/pr19967.c: Use -std=c99.
+ * gcc.dg/pr22458-1.c: Add dg-options.
+ * gcc.dg/pr33676.c: Add dg-options.
+ * gcc.dg/gnu-predef-1.c: New test.
+ * gcc.dg/c90-func-1.c: New test.
+ * gcc.dg/c90-func-2.c: New test.
+ * gcc.dg/c90-func-2.h: New test.
+
2014-08-12 Janis Johnson <janisjo@codesourcery.com>
* lib/target/supports.exp
--- /dev/null
+/* Test that we diagnose the __func__ predefined identifier in
+ C90 pedantic mode. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+void
+foo (void)
+{
+ const char *s = __func__; /* { dg-error " ISO C90 does not support .__func__. predefined identifier" } */
+}
--- /dev/null
+/* Test that we don't pedwarn about __func__ predefined identifier in
+ a system header in C90 pedantic mode. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+#include "c90-func-2.h"
+
+void
+foo (void)
+{
+ const char *s = FN;
+}
--- /dev/null
+#pragma GCC system_header
+#define FN __func__
/* Copyright (C) 2001 Free Software Foundation, Inc. */
/* { dg-do compile } */
+/* { dg-options "" } */
/* Test we output an error for concatenation of artificial strings.
/* { dg-do compile } */
/* { dg-options "-pedantic-errors" } */
-const char *a = __func__; /* { dg-error "'__func__' is not defined outside of function scope" "undef" } */
-const char *b = __FUNCTION__;
-const char *c = __PRETTY_FUNCTION__;
+__extension__ const char *a = __func__; /* { dg-error "'__func__' is not defined outside of function scope" "undef" } */
+__extension__ const char *b = __FUNCTION__;
+__extension__ const char *c = __PRETTY_FUNCTION__;
be const char *. */
/* { dg-do compile } */
-/* { dg-options "-pedantic" } */
+/* { dg-options "-pedantic -std=c99" } */
char *strchr(const char *, int);
char *strrchr(const char *, int);
/* { dg-error "expected declaration or statement" "" { target *-*-* } 0 } */
+/* { dg-options "" } */
+
void foo()
{
__PRETTY_FUNCTION__;
/* { dg-do run } */
+/* { dg-options "" } */
/* { dg-options "-O0 -mtune=i386 -fomit-frame-pointer" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
__attribute__((noreturn,noinline)) void abrt (const char *fi, const char *fu)