public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-366] Revert "[PATCH] libcpp: suppress builtin macro redefined warnings for __LINE__"
@ 2023-04-30 23:12 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-04-30 23:12 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:33b6b7919763d939a153fe6f4aa3250c107605ee

commit r14-366-g33b6b7919763d939a153fe6f4aa3250c107605ee
Author: Jeff Law <jlaw@ventanamicro>
Date:   Sun Apr 30 17:12:19 2023 -0600

    Revert "[PATCH] libcpp: suppress builtin macro redefined warnings for __LINE__"
    
    This reverts commit e7ce7c4905fd254760b1cd187752a03bc0c148ba.

Diff:
---
 gcc/testsuite/gcc.dg/builtin-redefine-1.c | 49 -------------------------------
 gcc/testsuite/gcc.dg/builtin-redefine.c   | 24 +++------------
 libcpp/init.cc                            |  2 +-
 3 files changed, 5 insertions(+), 70 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/builtin-redefine-1.c b/gcc/testsuite/gcc.dg/builtin-redefine-1.c
deleted file mode 100755
index c1e05b4fc7c..00000000000
--- a/gcc/testsuite/gcc.dg/builtin-redefine-1.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Test default warnings for redefining builtin macros.  */
-
-/* { dg-do compile } */
-/* { dg-options "-D__TIMESTAMP__=x -D__TIME__=x -D__DATE__=x -D__FILE__=x -D__FILE_NAME__=x -D__BASE_FILE__=x -D__LINE__=0" } */
-
-/* Check default behavior for builtin macros redefinition.  */
-
-/* { dg-message "\"__TIMESTAMP__\" redefined" "" {target "*-*-*"} 0 } */
-#ifndef __TIMESTAMP__
-#error "__TIMESTAMP__ builtin is not defined"
-/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */
-#endif
-
-/* { dg-message "\"__TIME__\" redefined" "" {target "*-*-*"} 0 } */
-#ifndef __TIME__
-#error "__TIME__ builtin is not defined"
-/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */
-#endif
-
-/* { dg-message "\"__DATE__\" redefined" "" {target "*-*-*"} 0 } */
-#ifndef __DATE__
-#error "__DATE__ builtin is not defined"
-/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */
-#endif
-
-/* { dg-message "\"__FILE__\" redefined" "" {target "*-*-*"} 0 } */
-#ifndef __FILE__
-#error "__FILE__ builtin is not defined"
-/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */
-#endif
-
-/* { dg-message "\"__FILE_NAME__\" redefined" "" {target "*-*-*"} 0 } */
-#ifndef __FILE_NAME__
-#error "__FILE_NAME__ builtin is not defined"
-/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */
-#endif
-
-/* { dg-message "\"__BASE_FILE__\" redefined" "" {target "*-*-*"} 0 } */
-#ifndef __BASE_FILE__
-#error "__BASE_FILE__ builtin is not defined"
-/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */
-#endif
-
-/* { dg-message "\"__LINE__\" redefined" "" {target "*-*-*"} 0 } */
-#ifndef __LINE__
-#error "__LINE__ builtin is not defined"
-/* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */
-#endif
-
diff --git a/gcc/testsuite/gcc.dg/builtin-redefine.c b/gcc/testsuite/gcc.dg/builtin-redefine.c
index fa27ee9aefc..882b2210992 100644
--- a/gcc/testsuite/gcc.dg/builtin-redefine.c
+++ b/gcc/testsuite/gcc.dg/builtin-redefine.c
@@ -1,9 +1,9 @@
 /* Test -Wno-builtin-macro-redefined warnings.  */
 
 /* { dg-do compile } */
-/* { dg-options "-Wno-builtin-macro-redefined -U__DATE__ -D__TIME__=X -D__LINE__=0" } */
+/* { dg-options "-Wno-builtin-macro-redefined -U__DATE__ -D__TIME__=X" } */
 
-/* Check date, time, datestamp and line built-ins warnings may be suppressed.  */
+/* Check date, time, and datestamp built-ins warnings may be suppressed.  */
 
 #if defined(__DATE__)
 #error "__DATE__ is defined, but should not be (-U command line error)"
@@ -15,11 +15,6 @@
 /* { dg-bogus "__TIME__ is not defined" "" { target *-*-* } .-1 } */
 #endif
 
-#if __LINE__ != 0
-#error "__LINE__ is not defined as expected (-D command line error)"
-/* { dg-bogus "__LINE__ is not defined" "" { target *-*-* } .-1 } */
-#endif
-
 #if !defined(__TIMESTAMP__)
 #error "__TIMESTAMP__ is not defined (built-in macro expectation error)"
 /* { dg-bogus "__TIMESTAMP__ is not defined" "" { target *-*-* } .-1 } */
@@ -58,18 +53,6 @@
 #undef __TIMESTAMP__         /* Undefine while defined.  */
 
 
-#undef __LINE__              /* Undefine while defined.  */
-#undef __LINE__              /* Undefine while already undefined.  */
-
-#define __LINE__ "1"         /* Define while undefined.  */
-#define __LINE__ "1"         /* Re-define while defined.  */ /* { dg-line line_prev } */
-
-#define __LINE__ "2"         /* { dg-warning "-:\"__LINE__\" redefined" } */
-/* { dg-message "-:previous definition" "" { target *-*-* } line_prev } */
-
-#undef __LINE__              /* Undefine while defined.  */
-
-
 /* Check other built-ins with warnings that may be suppressed.  */
 
 #if !defined(__FILE__) || !defined(__BASE_FILE__)
@@ -83,11 +66,12 @@
 
 /* Check selected built-ins not affected by warning suppression. */
 
-#if !defined(__INCLUDE_LEVEL__) || !defined(__COUNTER__)
+#if !defined(__LINE__) || !defined(__INCLUDE_LEVEL__) || !defined(__COUNTER__)
 #error "Expected built-in is not defined (built-in macro expectation error)"
 /* { dg-bogus "Expected built-in is not defined" "" { target *-*-* } .-1 } */
 #endif
 
+#define __LINE__ 0           /* { dg-warning "-:\"__LINE__\" redef" } */
 #define __INCLUDE_LEVEL__ 0  /* { dg-warning "-:\"__INCLUDE_LEVEL__\" redef" } */
 #define __COUNTER__ 0        /* { dg-warning "-:\"__COUNTER__\" redef" } */
 
diff --git a/libcpp/init.cc b/libcpp/init.cc
index bdeccffa029..c508f06112a 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -421,7 +421,7 @@ static const struct builtin_macro builtin_array[] =
   B("__FILE__",		 BT_FILE,          false),
   B("__FILE_NAME__",	 BT_FILE_NAME,     false),
   B("__BASE_FILE__",	 BT_BASE_FILE,     false),
-  B("__LINE__",		 BT_SPECLINE,      false),
+  B("__LINE__",		 BT_SPECLINE,      true),
   B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL, true),
   B("__COUNTER__",	 BT_COUNTER,       true),
   /* Make sure to update the list of built-in

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-30 23:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-30 23:12 [gcc r14-366] Revert "[PATCH] libcpp: suppress builtin macro redefined warnings for __LINE__" Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).