demangle.h (DMGL_RET_POSTFIX): Extend the comment.
authorJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 13 Jun 2011 22:32:40 +0000 (22:32 +0000)
committerJan Kratochvil <jkratoch@gcc.gnu.org>
Mon, 13 Jun 2011 22:32:40 +0000 (22:32 +0000)
include/
* demangle.h (DMGL_RET_POSTFIX): Extend the comment.
(DMGL_RET_DROP): New.

libiberty/
* cp-demangle.c (d_print_comp) <DEMANGLE_COMPONENT_FUNCTION_TYPE>: Do
not pass DMGL_RET_POSTFIX or DMGL_RET_DROP.  Support DMGL_RET_DROP.
* testsuite/demangle-expected: New testcases for --ret-drop.
* testsuite/test-demangle.c: Document --ret-drop in a comment.
(main): New variable ret_drop, fill it, call cplus_demangle with it.

From-SVN: r175000

include/ChangeLog
include/demangle.h
libiberty/ChangeLog
libiberty/cp-demangle.c
libiberty/testsuite/demangle-expected
libiberty/testsuite/test-demangle.c

index 7ad246e44a700f6dc7338917901a6d86231bc1e7..fa0dfac51f3993d9b06d570e350e03e480e4cf4d 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * demangle.h (DMGL_RET_POSTFIX): Extend the comment.
+       (DMGL_RET_DROP): New.
+
 2011-04-30  Jakub Jelinek  <jakub@redhat.com>
 
        * dwarf2.h (DW_OP_GNU_const_type, DW_OP_GNU_regval_type,
index c0624559ee2055d995a1e98109a13359ba363cf8..53f6c54f52466b0e8073b3b5e208d66668359d1c 100644 (file)
@@ -45,7 +45,13 @@ extern "C" {
 #define DMGL_VERBOSE    (1 << 3)       /* Include implementation details.  */
 #define DMGL_TYPES      (1 << 4)       /* Also try to demangle type encodings.  */
 #define DMGL_RET_POSTFIX (1 << 5)       /* Print function return types (when
-                                           present) after function signature */
+                                          present) after function signature.
+                                          It applies only to the toplevel
+                                          function type.  */
+#define DMGL_RET_DROP   (1 << 6)       /* Suppress printing function return
+                                          types, even if present.  It applies
+                                          only to the toplevel function type.
+                                          */
 
 #define DMGL_AUTO       (1 << 8)
 #define DMGL_GNU        (1 << 9)
index c2d49664f8f8ae74d98b830f368edb6192e3865c..8e1fa521db61f44c1b2f72fd9eda867ef2767e49 100644 (file)
@@ -1,3 +1,11 @@
+2011-06-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * cp-demangle.c (d_print_comp) <DEMANGLE_COMPONENT_FUNCTION_TYPE>: Do
+       not pass DMGL_RET_POSTFIX or DMGL_RET_DROP.  Support DMGL_RET_DROP.
+       * testsuite/demangle-expected: New testcases for --ret-drop.
+       * testsuite/test-demangle.c: Document --ret-drop in a comment.
+       (main): New variable ret_drop, fill it, call cplus_demangle with it.
+
 2011-06-13  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        * cp-demangle.c (struct d_print_info): Remove field options.
index 0ac90f1a62523438b268139302ed1f681ecae5da..da6d7979f2c44348e38f9523cc17a3d361400f6a 100644 (file)
@@ -3917,10 +3917,12 @@ d_print_comp (struct d_print_info *dpi, int options,
     case DEMANGLE_COMPONENT_FUNCTION_TYPE:
       {
        if ((options & DMGL_RET_POSTFIX) != 0)
-         d_print_function_type (dpi, options, dc, dpi->modifiers);
+         d_print_function_type (dpi,
+                                options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP),
+                                dc, dpi->modifiers);
 
        /* Print return type if present */
-       if (d_left (dc) != NULL)
+       if (d_left (dc) != NULL && (options & DMGL_RET_DROP) == 0)
          {
            struct d_print_mod dpm;
 
@@ -3932,7 +3934,8 @@ d_print_comp (struct d_print_info *dpi, int options,
            dpm.printed = 0;
            dpm.templates = dpi->templates;
 
-           d_print_comp (dpi, options, d_left (dc));
+           d_print_comp (dpi, options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP),
+                         d_left (dc));
 
            dpi->modifiers = dpm.next;
 
@@ -3946,7 +3949,9 @@ d_print_comp (struct d_print_info *dpi, int options,
          }
 
        if ((options & DMGL_RET_POSTFIX) == 0)
-         d_print_function_type (dpi, options, dc, dpi->modifiers);
+         d_print_function_type (dpi,
+                                options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP),
+                                dc, dpi->modifiers);
 
        return;
       }
index 5ce0377b13bf57f6c38b2b862ff3baa9ba6d6c2f..63a3e24ba4193799b92282a15054bc3abb2c6081 100644 (file)
@@ -3959,6 +3959,24 @@ f(decltype(nullptr))
 --format=gnu-v3
 _ZN5aaaaa6bbbbbb5cccccIN23ddddddddddddddddddddddd3eeeENS2_4ffff16ggggggggggggggggENS0_9hhhhhhhhhES6_S6_S6_S6_S6_S6_S6_EE
 aaaaa::bbbbbb::ccccc<ddddddddddddddddddddddd::eee, ddddddddddddddddddddddd::ffff::gggggggggggggggg, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh, aaaaa::bbbbbb::hhhhhhhhh>
+--format=gnu-v3
+_Z5outerIsEcPFilE
+char outer<short>(int (*)(long))
+--format=gnu-v3
+_Z5outerPFsiEl
+outer(short (*)(int), long)
+--format=gnu-v3
+_Z6outer2IsEPFilES1_
+int (*outer2<short>(int (*)(long)))(long)
+--format=gnu-v3 --ret-drop
+_Z5outerIsEcPFilE
+outer<short>(int (*)(long))
+--format=gnu-v3 --ret-drop
+_Z5outerPFsiEl
+outer(short (*)(int), long)
+--format=gnu-v3 --ret-drop
+_Z6outer2IsEPFilES1_
+outer2<short>(int (*)(long))
 #
 # Ada (GNAT) tests.
 #
index 1c982d6ef20cabb742575bb7ba300f51a19fc6bc..11d9729999b80259cb82189012d08bd449e58f5f 100644 (file)
@@ -159,6 +159,7 @@ exp: %s\n",
                          output is an integer representing ctor_kind.
      --is-v3-dtor        Likewise, but for dtors.
      --ret-postfix       Passes the DMGL_RET_POSTFIX option
+     --ret-drop          Passes the DMGL_RET_DROP option
 
    For compatibility, just in case it matters, the options line may be
    empty, to mean --format=auto.  If it doesn't start with --, then it
@@ -174,7 +175,7 @@ main(argc, argv)
   int no_params;
   int is_v3_ctor;
   int is_v3_dtor;
-  int ret_postfix;
+  int ret_postfix, ret_drop;
   struct line format;
   struct line input;
   struct line expect;
@@ -209,6 +210,7 @@ main(argc, argv)
 
       no_params = 0;
       ret_postfix = 0;
+      ret_drop = 0;
       is_v3_ctor = 0;
       is_v3_dtor = 0;
       if (format.data[0] == '\0')
@@ -265,6 +267,8 @@ main(argc, argv)
                is_v3_dtor = 1;
              else if (strcmp (opt, "--ret-postfix") == 0)
                ret_postfix = 1;
+             else if (strcmp (opt, "--ret-drop") == 0)
+               ret_drop = 1;
              else
                {
                  printf ("FAIL at line %d: unrecognized option %s\n",
@@ -307,9 +311,9 @@ main(argc, argv)
 
       cplus_demangle_set_style (style);
 
-      result = cplus_demangle (inp,
-                              DMGL_PARAMS|DMGL_ANSI|DMGL_TYPES
-                              |(ret_postfix ? DMGL_RET_POSTFIX : 0));
+      result = cplus_demangle (inp, (DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES
+                                    | (ret_postfix ? DMGL_RET_POSTFIX : 0)
+                                    | (ret_drop ? DMGL_RET_DROP : 0)));
 
       if (result
          ? strcmp (result, expect.data)