]> gcc.gnu.org Git - gcc.git/commitdiff
re PR preprocessor/35061 (#pragma pop_macro causes ICE if no macro value on stack)
authorDanny Smith <dannysmith@users.sourceforge.net>
Thu, 14 Feb 2008 21:41:40 +0000 (21:41 +0000)
committerDanny Smith <dannysmith@gcc.gnu.org>
Thu, 14 Feb 2008 21:41:40 +0000 (21:41 +0000)
PR preprocessor/35061
gcc
* c-pragma.c (handle_pragma_pop_macro): Check that
pushed_macro_table has been allocated.
testsuite
* gcc.dg/cpp/pragma_pop_macro-1.c:  New file

From-SVN: r132322

gcc/ChangeLog
gcc/c-pragma.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/pragma-pop_macro-1.c [new file with mode: 0644]

index d3dfe7ad70f2aca694cc883605309a3c95931fd3..ab1a89bd8d27f604d67aa3bb21ecce91d6ffb9bc 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-14  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       PR preprocessor/35061
+       * c-pragma.c (handle_pragma_pop_macro): Check that
+       pushed_macro_table has been allocated.
+
 2008-02-14  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR middle-end/35136
index 28b44353b226b2c0ea3b364a2244fd06f555dcd3..f7da67622ce47841f405a5f29612e240a29149cb 100644 (file)
@@ -341,7 +341,7 @@ handle_pragma_pop_macro (cpp_reader *reader)
   enum cpp_ttype token;
   struct def_pragma_macro dummy, *c;
   const char *macroname;
-  void **slot;
+  void **slot = NULL;
 
   if (pragma_lex (&x) != CPP_OPEN_PAREN)
     GCC_BAD ("missing %<(%> after %<#pragma pop_macro%> - ignored");
@@ -367,8 +367,9 @@ handle_pragma_pop_macro (cpp_reader *reader)
 
   dummy.hash = htab_hash_string (macroname);
   dummy.name = macroname;
-  slot = htab_find_slot_with_hash (pushed_macro_table, &dummy,
-                                  dummy.hash, NO_INSERT);
+  if (pushed_macro_table)
+    slot = htab_find_slot_with_hash (pushed_macro_table, &dummy,
+                                    dummy.hash, NO_INSERT);
   if (slot == NULL)
     return;
   c = *slot;
index 7a4d5bb4d8712640494ba55043f62438ec9e37ae..4c1c8b8705cd9d27085e7acba06aabb4cfa315d1 100644 (file)
@@ -1,3 +1,8 @@
+2008-02-14  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       PR preprocessor/35061
+       * gcc.dg/cpp/pragma_pop_macro-1.c:  New test.
+
 2008-02-14  Paolo Carlini  <pcarlini@suse.de>
 
         PR c++/28743
diff --git a/gcc/testsuite/gcc.dg/cpp/pragma-pop_macro-1.c b/gcc/testsuite/gcc.dg/cpp/pragma-pop_macro-1.c
new file mode 100644 (file)
index 0000000..82beefc
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR preprocessor/35061 */
+/* Do nothing if there is nothing on the macro stack to pop.  */
+
+/* { dg do-preprocess { target *-*-mingw*  *-*-cygwin* } } */
+
+#define X  1
+/* # pragma push_macro("X") */
+# undef X
+# pragma pop_macro("X")
+#ifdef X
+#error X is defined
+#endif
This page took 0.128156 seconds and 5 git commands to generate.