This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[pph] Fix x1mbstate_t.h (issue5872043)


Fix x1mbstate_t.h.

This patch fixes the parser segmentation fault caused by a name
lookup failure (details in
http://gcc.gnu.org/ml/gcc-patches/2012-03/msg01369.html).

I am not 100% sure that this is the right fix, but Jason seems to
think that the theory behind this is fine (parser does no allow a
USING_DECL to be set in the bindings of an identifier).  I left a
FIXME note to help future debugging.


2012-03-21   Diego Novillo  <dnovillo@google.com>

cp/ChangeLog.pph
	* name-lookup.c (pph_set_namespace_decl_binding): Ignore
	USING_DECLs.

testsuite/ChangeLog.pph
	* g++.dg/pph/x1mbstate_t.h: Mark fixed.

diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 947708d..1b33ce3 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -6271,7 +6271,11 @@ pph_set_namespace_decl_binding (tree decl, cp_binding_level *bl, int flags)
 {
   /* Set the namespace identifier binding for a single decl.  */
   tree id = DECL_NAME (decl);
-  if (id)
+  /* FIXME pph.  USING_DECLs do not seem to be used in bindings by
+     the parser. This was causing the SEGV in
+     testsuite/g++.dg/pph/x1mbstate_t.h.  It's unclear whether this is
+     the right fix.  */
+  if (id && TREE_CODE (decl) != USING_DECL)
     pph_set_identifier_binding (id, decl, bl, flags);
 }
 
diff --git a/gcc/testsuite/g++.dg/pph/x1mbstate_t.h b/gcc/testsuite/g++.dg/pph/x1mbstate_t.h
index c07a0cc..4d473e4 100644
--- a/gcc/testsuite/g++.dg/pph/x1mbstate_t.h
+++ b/gcc/testsuite/g++.dg/pph/x1mbstate_t.h
@@ -1,9 +1,8 @@
-// { dg-xfail-if "identifier bindings not set properly" { "*-*-*" } { "-fpph-map=pph.map"} }
-// { dg-bogus ".*Segmentation fault" "ICE trying to parse std::mbstate_t"  { xfail *-*-* } 0 }
 #ifndef _X1_MBSTATE_H
 #define _X1_MBSTATE_H
 #include "x0mbstate_t.h"
-// Name lookup for std::mbstate_t fails here.  Instead of returning the global
-// type_decl for mbstate_t, it returns the "usings ::mbstate_t" declaration.
+// Name lookup for std::mbstate_t was failingfails here.  Instead of returning
+// the global type_decl for mbstate_t, it was returning the
+// "usings ::mbstate_t" declaration.
 typedef std::mbstate_t state_type;
 #endif

--
This patch is available for review at http://codereview.appspot.com/5872043


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]