public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix parsing_nsdmi (PR c++/65127)
@ 2015-03-10 19:16 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2015-03-10 19:16 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

Hi!

current_class_ptr could be just NULL or a PARM_DECL in the past,
but now it can also be ADDR_EXPR of a PLACEHOLDER_EXPR, which obviously
doesn't have DECL_CONTEXT.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
Jason acked it in the PR, committed to trunk.

2015-03-10  Jakub Jelinek  <jakub@redhat.com>

	PR c++/65127
	* parser.c (parsing_nsdmi): Don't return true if current_class_ptr
	is not a PARM_DECL.

	* g++.dg/cpp0x/pr65127.C: New test.

--- gcc/cp/parser.c.jj	2015-03-10 07:37:56.000000000 +0100
+++ gcc/cp/parser.c	2015-03-10 18:12:10.652923617 +0100
@@ -18314,7 +18314,9 @@ parsing_nsdmi (void)
 {
   /* We recognize NSDMI context by the context-less 'this' pointer set up
      by the function above.  */
-  if (current_class_ptr && DECL_CONTEXT (current_class_ptr) == NULL_TREE)
+  if (current_class_ptr
+      && TREE_CODE (current_class_ptr) == PARM_DECL
+      && DECL_CONTEXT (current_class_ptr) == NULL_TREE)
     return true;
   return false;
 }
--- gcc/testsuite/g++.dg/cpp0x/pr65127.C.jj	2015-03-10 18:12:46.912341409 +0100
+++ gcc/testsuite/g++.dg/cpp0x/pr65127.C	2015-03-10 18:12:59.980131583 +0100
@@ -0,0 +1,16 @@
+// PR c++/65127
+// { dg-do compile { target c++11 } }
+
+template <int N>
+void
+foo ()
+{
+  static int i {100};
+  struct { int id {i++}; } j;
+}
+
+int
+main ()
+{
+  foo<0> ();
+}

	Jakub

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

only message in thread, other threads:[~2015-03-10 19:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-10 19:16 [committed] Fix parsing_nsdmi (PR c++/65127) Jakub Jelinek

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).