diff mbox

Fix lazy fp hex value handling (PR preprocessor/45457)

Message ID 20100831161815.GJ1269@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Aug. 31, 2010, 4:18 p.m. UTC
Hi!

pfile->cb.user_builtin_macro is only called for NODE_BUILTIN NT_MACROs
when NODE_USED is being set on them.  Unfortunately I've missed 3 places
which can make them NODE_USED (#ifdef/#ifndef/defined()), but wouldn't
call this hook, which means it wouldn't be called when actually using
the macros either.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux.
Ok for trunk?

2010-08-31  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/45457
	* expr.c (parse_defined): Call pfile->cb.user_builtin_macro hook if
	needed.
	* directives.c (do_ifdef, do_ifndef): Likewise.

	* c-c++-common/cpp/pr45457.c: New test.


	Jakub

Comments

Tom Tromey Aug. 31, 2010, 10:31 p.m. UTC | #1
>>>>> "Jakub" == Jakub Jelinek <jakub@redhat.com> writes:

Jakub> 2010-08-31  Jakub Jelinek  <jakub@redhat.com>
Jakub> 	PR preprocessor/45457
Jakub> 	* expr.c (parse_defined): Call pfile->cb.user_builtin_macro hook if
Jakub> 	needed.
Jakub> 	* directives.c (do_ifdef, do_ifndef): Likewise.
Jakub> 	* c-c++-common/cpp/pr45457.c: New test.

This is ok.  Thanks.

Tom
diff mbox

Patch

--- libcpp/expr.c.jj	2010-04-08 08:49:41.000000000 +0200
+++ libcpp/expr.c	2010-08-31 12:56:01.000000000 +0200
@@ -700,6 +700,9 @@  parse_defined (cpp_reader *pfile)
 	  node->flags |= NODE_USED;
 	  if (node->type == NT_MACRO)
 	    {
+	      if ((node->flags & NODE_BUILTIN)
+		  && pfile->cb.user_builtin_macro)
+		pfile->cb.user_builtin_macro (pfile, node);
 	      if (pfile->cb.used_define)
 		pfile->cb.used_define (pfile, pfile->directive_line, node);
 	    }
--- libcpp/directives.c.jj	2010-04-08 08:49:41.000000000 +0200
+++ libcpp/directives.c	2010-08-31 12:54:58.000000000 +0200
@@ -1,7 +1,7 @@ 
 /* CPP Library. (Directive handling.)
    Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
    1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007, 2008, 2009 Free Software Foundation, Inc.
+   2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Per Bothner, 1994-95.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -1804,6 +1804,9 @@  do_ifdef (cpp_reader *pfile)
 	      node->flags |= NODE_USED;
 	      if (node->type == NT_MACRO)
 		{
+		  if ((node->flags & NODE_BUILTIN)
+		      && pfile->cb.user_builtin_macro)
+		    pfile->cb.user_builtin_macro (pfile, node);
 		  if (pfile->cb.used_define)
 		    pfile->cb.used_define (pfile, pfile->directive_line, node);
 		}
@@ -1842,6 +1845,9 @@  do_ifndef (cpp_reader *pfile)
 	      node->flags |= NODE_USED;
 	      if (node->type == NT_MACRO)
 		{
+		  if ((node->flags & NODE_BUILTIN)
+		      && pfile->cb.user_builtin_macro)
+		    pfile->cb.user_builtin_macro (pfile, node);
 		  if (pfile->cb.used_define)
 		    pfile->cb.used_define (pfile, pfile->directive_line, node);
 		}
--- gcc/testsuite/c-c++-common/cpp/pr45457.c.jj	2010-08-31 12:59:34.000000000 +0200
+++ gcc/testsuite/c-c++-common/cpp/pr45457.c	2010-08-31 12:53:11.000000000 +0200
@@ -0,0 +1,18 @@ 
+/* PR preprocessor/45457 */
+/* { dg-do compile } */
+
+const char *a =
+#ifdef __DBL_DENORM_MIN__                                                                                                                         
+"a"
+#endif                                                                                                                                            
+#if defined(__DBL_EPSILON__)
+"b"
+#endif
+#ifndef __DBL_MAX__
+"c"
+#endif
+#if !defined(__DBL_MIN__)
+"d"
+#endif
+;
+double b = __DBL_DENORM_MIN__ + __DBL_EPSILON__ + __DBL_MAX__ + __DBL_MIN__;