Hi

This patch make -D and -U work in the spec language, bug pr48524.
Tested on x86_64-unknown-linux-gnu snapshot 4.7-20111217

Magnus.

2011-12-18  Magnus Granberg  <zo...@gentoo.org>

                        pr48524
                        * gcc/gcc.c     (switch_matches) Support switches with 
separated 
                        form, -D and -U.
                        * gcc/testsuite/gcc.dg/pr48524.c        New testcase.
                        * gcc/testsuite/gcc.dg/pr48524.spec     New spec file 
for the testcase.

----
--- a/gcc/gcc.c	2011-11-03 15:46:26.000000000 +0100
+++ b/gcc/gcc.c	2011-12-17 21:05:02.353999101 +0100
@@ -5445,6 +5445,21 @@
 	&& check_live_switch (i, plen))
       return true;
 
+    /* Check if a switch with separated form matching the atom.
+	We check -D and -U switches. */
+    else if (switches[i].args != 0)
+      {
+	if ((*switches[i].part1 == 'D' || *switches[i].part1 == 'U')
+	    && *switches[i].part1 == atom[0])
+	  {
+	    if (!strncmp (switches[i].args[0], &atom[1], len -1)
+		&& (starred || (switches[i].part1[1]== '\0'
+		&& switches[i].args[0][len -1] == '\0'))
+		&& check_live_switch (i, (starred ? 1 : -1)))
+	      return true;
+	  }
+      }
+
   return false;
 }
 
--- a/gcc/testsuite/gcc.dg/pr48524.c	2011-12-18 16:34:59.592259140 +0100
+++ b/gcc/testsuite/gcc.dg/pr48524.c	2011-12-18 02:11:22.000000000 +0100
@@ -0,0 +1,6 @@
+/* { dg-do preprocess } */
+/* { dg-options "-specs=${srcdir}/gcc.dg/pr48524.spec -D_TEST_D" } */
+# ifdef _FOO
+# error works /* { dg-error "works" } */
+# endif
+
--- a/gcc/testsuite/gcc.dg/pr48524.spec	2011-12-18 16:35:21.120259782 +0100
+++ b/gcc/testsuite/gcc.dg/pr48524.spec	2011-12-18 00:44:32.000000000 +0100
@@ -0,0 +1,5 @@
+*cpp_options:
+%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
+ %{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*}\
+ %{undef} %{save-temps*:-fpch-preprocess} %{D_TEST_D:-D_FOO}
+

Reply via email to