OSDN Git Service

*** empty log message ***
[pf3gnuchains/sourceware.git] / gdb / c-typeprint.c
index 0cb1e90..c70fa4b 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for printing C and C++ types for GDB, the GNU debugger.
    Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
-   1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2010
+   1999, 2000, 2001, 2002, 2003, 2006, 2007, 2008, 2009, 2010, 2011
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -81,7 +81,7 @@ c_print_type (struct type *type,
       fputs_filtered (varstring, stream);
 
       /* For demangled function names, we have the arglist as part of
-         the name, so don't print an additional pair of ()'s */
+         the name, so don't print an additional pair of ()'s */
 
       demangled_args = strchr (varstring, '(') != NULL;
       c_type_print_varspec_suffix (type, stream, show,
@@ -388,9 +388,12 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
 /* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD
    or TYPE_CODE_FUNC, to STREAM.  Artificial arguments, such as "this"
    in non-static methods, are displayed if SHOW_ARTIFICIAL is
-   non-zero.  LANGUAGE is the language in which TYPE was defined.
-   This is a necessary evil since this code is used by the C, C++, and
-   Java backends.  */
+   non-zero.  If SHOW_ARTIFICIAL is zero and LANGUAGE is language_cplus
+   the topmost parameter types get removed their possible const and volatile
+   qualifiers to match demangled linkage name parameters part of such function
+   type.  LANGUAGE is the language in which TYPE was defined.  This is
+   a necessary evil since this code is used by the C, C++, and Java backends.
+   */
 
 void
 c_type_print_args (struct type *type, struct ui_file *stream,
@@ -406,6 +409,8 @@ c_type_print_args (struct type *type, struct ui_file *stream,
 
   for (i = 0; i < TYPE_NFIELDS (type); i++)
     {
+      struct type *param_type;
+
       if (TYPE_FIELD_ARTIFICIAL (type, i) && !show_artificial)
        continue;
 
@@ -415,12 +420,24 @@ c_type_print_args (struct type *type, struct ui_file *stream,
          wrap_here ("    ");
        }
 
+      param_type = TYPE_FIELD_TYPE (type, i);
+
+      if (language == language_cplus && !show_artificial)
+       {
+         /* C++ standard, 13.1 Overloadable declarations, point 3, item:
+            - Parameter declarations that differ only in the presence or
+              absence of const and/or volatile are equivalent.
+
+            And the const/volatile qualifiers are not present in the mangled
+            names as produced by GCC.  */
+
+         param_type = make_cv_type (0, 0, param_type, NULL);
+       }
+
       if (language == language_java)
-       java_print_type (TYPE_FIELD_TYPE (type, i),
-                        "", stream, -1, 0);
+       java_print_type (param_type, "", stream, -1, 0);
       else
-       c_print_type (TYPE_FIELD_TYPE (type, i),
-                     "", stream, -1, 0);
+       c_print_type (param_type, "", stream, -1, 0);
       printed_any = 1;
     }
 
@@ -509,10 +526,10 @@ is_type_conversion_operator (struct type *type, int i, int j)
 static char *
 remove_qualifiers (char *qid)
 {
-  int quoted = 0;      /* zero if we're not in quotes;
+  int quoted = 0;      /* Zero if we're not in quotes;
                           '"' if we're in a double-quoted string;
                           '\'' if we're in a single-quoted string.  */
-  int depth = 0;       /* number of unclosed parens we've seen */
+  int depth = 0;       /* Number of unclosed parens we've seen.  */
   char *parenstack = (char *) alloca (strlen (qid));
   char *scan;
   char *last = 0;      /* The character after the rightmost
@@ -843,7 +860,8 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                    {
                      len = TYPE_FN_FIELDLIST_LENGTH (type, j);
                      for (i = 0; i < len; i++)
-                       if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, j), i))
+                       if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type,
+                                                                       j), i))
                          {
                            need_access_label = 1;
                            break;
@@ -873,8 +891,11 @@ c_type_print_base (struct type *type, struct ui_file *stream,
                      QUIT;
                      len = TYPE_FN_FIELDLIST_LENGTH (type, j);
                      for (i = 0; i < len; i++)
-                       if (TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, j), i)
-                           || TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type, j), i))
+                       if (TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type,
+                                                                        j), i)
+                           || TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type,
+                                                                         j),
+                                                     i))
                          {
                            need_access_label = 1;
                            break;
@@ -970,7 +991,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
          if (real_len > 0 && section_type != s_none)
            fprintf_filtered (stream, "\n");
 
-         /* C++: print out the methods */
+         /* C++: print out the methods */
          for (i = 0; i < len; i++)
            {
              struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
@@ -1203,7 +1224,7 @@ c_type_print_base (struct type *type, struct ui_file *stream,
       break;
 
     case TYPE_CODE_RANGE:
-      /* This should not occur */
+      /* This should not occur */
       fprintf_filtered (stream, _("<range type>"));
       break;