]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/42010 ([C++0x] ICE: lang_* check: failed in discriminator_for_local_entity...
authorJason Merrill <jason@redhat.com>
Sat, 5 Dec 2009 01:51:46 +0000 (20:51 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 5 Dec 2009 01:51:46 +0000 (20:51 -0500)
PR c++/42010
* cp-tree.h (DECL_DISCRIMINATOR_SET_P): New.
* mangle.c (discriminator_for_local_entity): Check it.

From-SVN: r155007

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/mangle.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/abi/local2.C [new file with mode: 0644]

index 7ec27d402a1090db14e1166b5985b1190df2dcea..bb3f8f929322aee454b88f5330eb1bbe35964068 100644 (file)
@@ -1,5 +1,9 @@
 2009-12-04  Jason Merrill  <jason@redhat.com>
 
+       PR c++/42010
+       * cp-tree.h (DECL_DISCRIMINATOR_SET_P): New.
+       * mangle.c (discriminator_for_local_entity): Check it.
+
        PR c++/42277
        * semantics.c (finish_decltype_type): Defer handling of decltype
        of a non-dependent COMPONENT_REF in a template.
index dc563e2c15c946552e479262bfe43b5fb26a663c..21a914d4a865840c6134e12f9bf8067f2a00326a 100644 (file)
@@ -2052,6 +2052,10 @@ struct GTY(()) lang_decl {
 /* Discriminator for name mangling.  */
 #define DECL_DISCRIMINATOR(NODE) (LANG_DECL_U2_CHECK (NODE, 1)->discriminator)
 
+/* True iff DECL_DISCRIMINATOR is set for a DECL_DISCRIMINATOR_P decl.  */
+#define DECL_DISCRIMINATOR_SET_P(NODE) \
+  (DECL_LANG_SPECIFIC (NODE) && DECL_LANG_SPECIFIC (NODE)->u.base.u2sel == 1)
+
 /* The index of a user-declared parameter in its function, starting at 1.
    All artificial parameters will have index 0.  */
 #define DECL_PARM_INDEX(NODE) \
index cd2b7d7dc1ff9200d3b04b3852a347330eae3675..3afc0949cf8a0e9f5f99afd4b860d178aa1d2e13 100644 (file)
@@ -1577,11 +1577,11 @@ discriminator_for_local_entity (tree entity)
 {
   if (DECL_DISCRIMINATOR_P (entity))
     {
-      if (DECL_LANG_SPECIFIC (entity))
+      if (DECL_DISCRIMINATOR_SET_P (entity))
        return DECL_DISCRIMINATOR (entity);
       else
        /* The first entity with a particular name doesn't get
-          DECL_LANG_SPECIFIC/DECL_DISCRIMINATOR.  */
+          DECL_DISCRIMINATOR set up.  */
        return 0;
     }
   else if (TREE_CODE (entity) == TYPE_DECL)
index ed866cf019996a9979afd4bc22df75e757e79509..12a57bccd351bf3497a55dd7ea23d9e99619138a 100644 (file)
@@ -1,5 +1,8 @@
 2009-12-04  Jason Merrill  <jason@redhat.com>
 
+       PR c++/42010
+       * g++.dg/abi/local2.C: New.
+
        PR c++/42277
        * g++.dg/cpp0x/decltype20.C: New.
 
diff --git a/gcc/testsuite/g++.dg/abi/local2.C b/gcc/testsuite/g++.dg/abi/local2.C
new file mode 100644 (file)
index 0000000..f567016
--- /dev/null
@@ -0,0 +1,17 @@
+// PR c++/42010
+// { dg-final { scan-assembler "ZZN1A1fEvE1s" } }
+
+struct A {
+  static int f()
+  {
+    static struct {
+      int i;
+    } s;
+    return s.i;
+  }
+};
+
+int main()
+{
+  return A::f();
+}