* gdbarch.sh (gdbarch_data): Add gdbarch parameter.
[deliverable/binutils-gdb.git] / gdb / c-lang.c
index 308f8d46c6bc1cfe1349a07e577fc2c141bac9d8..f98548a63afedea3927746d554e19988dddee845 100644 (file)
@@ -1,5 +1,6 @@
 /* C language support routines for GDB, the GNU debugger.
-   Copyright 1992, 1993, 1994 Free Software Foundation, Inc.
+   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "parser-defs.h"
 #include "language.h"
 #include "c-lang.h"
+#include "valprint.h"
 
-extern void _initialize_c_language PARAMS ((void));
-static void c_emit_char PARAMS ((int c, GDB_FILE * stream, int quoter));
+extern void _initialize_c_language (void);
+static void c_emit_char (int c, struct ui_file * stream, int quoter);
 
 /* Print the character C on STREAM as part of the contents of a literal
    string whose delimiter is QUOTER.  Note that that format for printing
    characters and strings is language specific. */
 
 static void
-c_emit_char (c, stream, quoter)
-     register int c;
-     GDB_FILE *stream;
-     int quoter;
+c_emit_char (register int c, struct ui_file *stream, int quoter)
 {
   c &= 0xFF;                   /* Avoid sign bit follies */
 
@@ -68,12 +67,18 @@ c_emit_char (c, stream, quoter)
        case '\r':
          fputs_filtered ("\\r", stream);
          break;
+        case '\013':
+          fputs_filtered ("\\v", stream);
+          break;
        case '\033':
          fputs_filtered ("\\e", stream);
          break;
        case '\007':
          fputs_filtered ("\\a", stream);
          break;
+        case '\0':
+          fputs_filtered ("\\0", stream);
+          break;
        default:
          fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
          break;
@@ -82,9 +87,7 @@ c_emit_char (c, stream, quoter)
 }
 
 void
-c_printchar (c, stream)
-     int c;
-     GDB_FILE *stream;
+c_printchar (int c, struct ui_file *stream)
 {
   fputc_filtered ('\'', stream);
   LA_EMIT_CHAR (c, stream, '\'');
@@ -98,27 +101,22 @@ c_printchar (c, stream)
    printing LENGTH characters, or if FORCE_ELLIPSES.  */
 
 void
-c_printstr (stream, string, length, width, force_ellipses)
-     GDB_FILE *stream;
-     char *string;
-     unsigned int length;
-     int width;
-     int force_ellipses;
+c_printstr (struct ui_file *stream, char *string, unsigned int length,
+           int width, int force_ellipses)
 {
   register unsigned int i;
   unsigned int things_printed = 0;
   int in_quotes = 0;
   int need_comma = 0;
   extern int inspect_it;
-  extern int repeat_count_threshold;
-  extern int print_max;
 
   /* If the string was not truncated due to `set print elements', and
      the last byte of it is a null, we don't print that, in traditional C
      style.  */
   if (!force_ellipses
       && length > 0
-  && extract_unsigned_integer (string + (length - 1) * width, width) == '\0')
+      && (extract_unsigned_integer (string + (length - 1) * width, width)
+          == '\0'))
     length--;
 
   if (length == 0)
@@ -224,9 +222,7 @@ c_printstr (stream, string, length, width, force_ellipses)
    debugging information supplied by the compiler.  fnf@cygnus.com */
 
 struct type *
-c_create_fundamental_type (objfile, typeid)
-     struct objfile *objfile;
-     int typeid;
+c_create_fundamental_type (struct objfile *objfile, int typeid)
 {
   register struct type *type = NULL;
 
@@ -251,13 +247,11 @@ c_create_fundamental_type (objfile, typeid)
       type = init_type (TYPE_CODE_BOOL,
                        TARGET_CHAR_BIT / TARGET_CHAR_BIT,
                        0, "bool", objfile);
-
       break;
     case FT_CHAR:
       type = init_type (TYPE_CODE_INT,
                        TARGET_CHAR_BIT / TARGET_CHAR_BIT,
-                       0, "char", objfile);
-      TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN;
+                       TYPE_FLAG_NOSIGN, "char", objfile);
       break;
     case FT_SIGNED_CHAR:
       type = init_type (TYPE_CODE_INT,
@@ -344,11 +338,34 @@ c_create_fundamental_type (objfile, typeid)
                        TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
                        0, "long double", objfile);
       break;
+    case FT_COMPLEX:
+      type = init_type (TYPE_CODE_FLT,
+                       2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+                       0, "complex float", objfile);
+      TYPE_TARGET_TYPE (type)
+       = init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+                    0, "float", objfile);
+      break;
+    case FT_DBL_PREC_COMPLEX:
+      type = init_type (TYPE_CODE_FLT,
+                       2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
+                       0, "complex double", objfile);
+      TYPE_TARGET_TYPE (type)
+       = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
+                    0, "double", objfile);
+      break;
+    case FT_EXT_PREC_COMPLEX:
+      type = init_type (TYPE_CODE_FLT,
+                       2 * TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
+                       0, "complex long double", objfile);
+      TYPE_TARGET_TYPE (type)
+       = init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
+                    0, "long double", objfile);
+      break;
     case FT_TEMPLATE_ARG:
       type = init_type (TYPE_CODE_TEMPLATE_ARG,
                        0,
                        0, "<template arg>", objfile);
-
       break;
     }
   return (type);
@@ -389,31 +406,29 @@ const struct op_print c_op_print_tab[] =
   {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
   {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
   {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
-    /* C++  */
-  {"::", BINOP_SCOPE, PREC_PREFIX, 0},
   {NULL, 0, 0, 0}
 };
 \f
-struct type **CONST_PTR (c_builtin_types[]) =
+struct type **const (c_builtin_types[]) =
 {
   &builtin_type_int,
-    &builtin_type_long,
-    &builtin_type_short,
-    &builtin_type_char,
-    &builtin_type_float,
-    &builtin_type_double,
-    &builtin_type_void,
-    &builtin_type_long_long,
-    &builtin_type_signed_char,
-    &builtin_type_unsigned_char,
-    &builtin_type_unsigned_short,
-    &builtin_type_unsigned_int,
-    &builtin_type_unsigned_long,
-    &builtin_type_unsigned_long_long,
-    &builtin_type_long_double,
-    &builtin_type_complex,
-    &builtin_type_double_complex,
-    0
+  &builtin_type_long,
+  &builtin_type_short,
+  &builtin_type_char,
+  &builtin_type_float,
+  &builtin_type_double,
+  &builtin_type_void,
+  &builtin_type_long_long,
+  &builtin_type_signed_char,
+  &builtin_type_unsigned_char,
+  &builtin_type_unsigned_short,
+  &builtin_type_unsigned_int,
+  &builtin_type_unsigned_long,
+  &builtin_type_unsigned_long_long,
+  &builtin_type_long_double,
+  &builtin_type_complex,
+  &builtin_type_double_complex,
+  0
 };
 
 const struct language_defn c_language_defn =
@@ -423,6 +438,7 @@ const struct language_defn c_language_defn =
   c_builtin_types,
   range_check_off,
   type_check_off,
+  case_sensitive_on,
   c_parse,
   c_error,
   evaluate_subexp_standard,
@@ -447,24 +463,24 @@ const struct language_defn c_language_defn =
 struct type **const (cplus_builtin_types[]) =
 {
   &builtin_type_int,
-    &builtin_type_long,
-    &builtin_type_short,
-    &builtin_type_char,
-    &builtin_type_float,
-    &builtin_type_double,
-    &builtin_type_void,
-    &builtin_type_long_long,
-    &builtin_type_signed_char,
-    &builtin_type_unsigned_char,
-    &builtin_type_unsigned_short,
-    &builtin_type_unsigned_int,
-    &builtin_type_unsigned_long,
-    &builtin_type_unsigned_long_long,
-    &builtin_type_long_double,
-    &builtin_type_complex,
-    &builtin_type_double_complex,
-    &builtin_type_bool,
-    0
+  &builtin_type_long,
+  &builtin_type_short,
+  &builtin_type_char,
+  &builtin_type_float,
+  &builtin_type_double,
+  &builtin_type_void,
+  &builtin_type_long_long,
+  &builtin_type_signed_char,
+  &builtin_type_unsigned_char,
+  &builtin_type_unsigned_short,
+  &builtin_type_unsigned_int,
+  &builtin_type_unsigned_long,
+  &builtin_type_unsigned_long_long,
+  &builtin_type_long_double,
+  &builtin_type_complex,
+  &builtin_type_double_complex,
+  &builtin_type_bool,
+  0
 };
 
 const struct language_defn cplus_language_defn =
@@ -474,6 +490,7 @@ const struct language_defn cplus_language_defn =
   cplus_builtin_types,
   range_check_off,
   type_check_off,
+  case_sensitive_on,
   c_parse,
   c_error,
   evaluate_subexp_standard,
@@ -502,6 +519,7 @@ const struct language_defn asm_language_defn =
   c_builtin_types,
   range_check_off,
   type_check_off,
+  case_sensitive_on,
   c_parse,
   c_error,
   evaluate_subexp_standard,
@@ -524,7 +542,7 @@ const struct language_defn asm_language_defn =
 };
 
 void
-_initialize_c_language ()
+_initialize_c_language (void)
 {
   add_language (&c_language_defn);
   add_language (&cplus_language_defn);
This page took 0.040112 seconds and 4 git commands to generate.