]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix cut-n-paste-o comment in compile_cplus_instance::leave_scope.
authorKeith Seitz <keiths@redhat.com>
Wed, 19 Apr 2017 17:18:23 +0000 (10:18 -0700)
committerKeith Seitz <keiths@redhat.com>
Wed, 19 Apr 2017 17:18:23 +0000 (10:18 -0700)
Also add tests for (real) anonymous struct and union. Introduces six new
FAILs.

gdb/compile/compile-cplus-types.c
gdb/testsuite/gdb.compile/cp-simple-anonymous.cc
gdb/testsuite/gdb.compile/cp-simple-anonymous.exp

index 084d94d0754e3e33e9bce4fde86285296e2612a1..a91ac5b94bf6df9235b321acda87bba4a1bea316 100644 (file)
@@ -370,8 +370,7 @@ compile_cplus_instance::leave_scope ()
       if (debug_compile_cplus_scopes)
        printf_unfiltered ("leaving scope %p\n", current);
 
-      /* Pop namespaces.  Do not push the last scope_component -- that's
-        the type we are converting, not a namespace.  */
+      /* Pop namespaces.  */
       std::for_each
        (current.begin (),current.end () - 1, [this] (const auto &comp) {
          gdb_assert (TYPE_CODE (SYMBOL_TYPE (comp.bsymbol.symbol))
@@ -1631,8 +1630,6 @@ ccp_convert_namespace (compile_cplus_instance *instance,
 
   if (TYPE_NAME (type) != NULL)
     name = cp_func_name (TYPE_NAME (type));
-  else
-    name = xstrdup ("");       // !!keiths: anonymous namespace?!
 
   /* Push scope.  */
   instance->enter_scope (scope);
index d604339feb6daf6032e9c6698c45015351e9c702..c797058689360dd0a7eaafebb61d846eab0d9e9a 100644 (file)
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-static enum {ABC = 1, DEF, GHI, JKL} anon_e = GHI;
-static union
-{
-  char aa;
-  int bb;
-  float ff;
-  double dd;
-  void *pp;
-} anon_u = { 'a' };
-
-static struct
-{
-  char *ptr;
-  int len;
-} anon_s = {"abracadabra", 11};
-
-struct A
-{
-  A (void) : e (AA)
+namespace {
+  static enum {ABC = 1, DEF, GHI, JKL} anon_e = GHI;
+  static union
   {
-    this->u.b = 0;
-    this->s.ptr = "hello";
-    this->s.len = 5;
-  }
+    char aa;
+    int bb;
+    float ff;
+    double dd;
+    void *pp;
+  } anon_u = { 'a' };
 
-  enum {AA = 10, BB, CC, DD} e;
-  union
-  {
-    char a;
-    int b;
-    float f;
-    double d;
-    void *p;
-  } u;
-  struct
+  static struct
   {
     char *ptr;
     int len;
-  } s;
+    struct
+    {
+      unsigned MAGIC;
+    };
+    union
+    {
+      int ua;
+      char *ub;
+    };
+  } anon_s = {"abracadabra", 11, 0xdead, 0xbeef};
+
+  struct A
+  {
+    A (void) : e (AA)
+    {
+      this->u.b = 0;
+      this->s.ptr = "hello";
+      this->s.len = 5;
+    }
+
+    enum {AA = 10, BB, CC, DD} e;
+    union
+    {
+      char a;
+      int b;
+      float f;
+      double d;
+      void *p;
+    } u;
+    struct
+    {
+      char *ptr;
+      int len;
+    } s;
+  };
 };
 
 int
index 259caebc4259b4fb4abe1ad715404fc686116ddf..90f921f2e3c35f5913e7fb4309d68f2ea19c02b8 100644 (file)
@@ -48,6 +48,8 @@ CompileExpression::new "var"
 CompileExpression::test "anon_e" {(3|GHI)}
 CompileExpression::test "anon_u.aa" {97( 'a')?}
 CompileExpression::test "anon_s.len" 11
+CompileExpression::test "anon_s.MAGIC" "57005"
+CompileExpression::test "anon_s.ua" "48879"
 CompileExpression::test "a.u.b" 0
 CompileExpression::test "a.s.len" 5
 CompileExpression::test "a.e" {(10|A::AA)}