This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA 1/3] c++/13356: Remove "type checker"
- From: Keith Seitz <keiths at redhat dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Thu, 16 Aug 2012 13:13:55 -0700
- Subject: [RFA 1/3] c++/13356: Remove "type checker"
Hi,
For a very long time now, the documentation and the code have talked
about a "type checker." As far as I can tell, it was never fully
implemented, and, in fact, it is not used anywhere.
While working up a patch for c++/13356, Tom noticed that we had a
set/show command for "check type". Since this is not used (and doesn't
look like it ever was), we've decided to reclaim that setting and turn
it into something useful.
This first patch deals with the mechanical removal of all the dead code.
[The documentation and testsuite patches will follow.]
Comments/questions/concerns?
Keith
ChangeLog
2012-08-16 Keith Seitz <keiths@redhat.com>
* language.h (type_mode): Remove.
(type_check): Remove.
(struct language_defn): Remove la_type_check.
(STRICT_TYPE): Remove unused macro.
(type_error): Remove.
* language.c (set_type_range_case): Renamed to ...
(set_range_case): ... this. Update all callers.
Remove type_mode/type_check.
(type_mode): Remove.
(type_check): Remove.
(show_type_command): Remove.
(set_type_command): Remove.
(language_info): Remove type checking output.
(type_error): Remove unused function.
(range_error): Update comment.
(unknown_language_defn): Remove la_type_check.
(auto_language_defn): Likewise.
(local_language_defn): Likewise.
(_initialize_language): Remove "check type" subcommand.
* ada-lang.c (ada_language_defn): Remove la_type_check.
* c-lang.c (c_language_defn): Likewise.
(cplus_language_defn): Likewise.
(asm_language_defn): Likewise.
(minimal_language_defn): Likewise.
* d-lang.c (d_language_defn): Likewise.
* f-lang.c (f_language_defn): Likewise.
* go-lang.c (go_language_defn): Likewise.
* jv-lang.c (java_language_defn): Likewise.
* m2-lang.c (m2_language_defn): Likewise.
* objc-lang.c (objc_language_defn): Likewise.
* opencl-lang.c (opencl_language_defn): Likewise.
* p-lang.c (pascal_language_defn): Likewise.
diff --git a/gdb/language.h b/gdb/language.h
index 38c4830..fb63870 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -55,27 +55,6 @@ extern enum range_check
}
range_check;
-/* type_mode ==
- type_mode_auto: type_check set automatically to default of language.
- type_mode_manual: type_check set manually by user. */
-
-extern enum type_mode
- {
- type_mode_auto, type_mode_manual
- }
-type_mode;
-
-/* type_check ==
- type_check_on: Types are checked in GDB expressions, producing errors.
- type_check_warn: Types are checked, producing warnings.
- type_check_off: Types are not checked in GDB expressions. */
-
-extern enum type_check
- {
- type_check_off, type_check_warn, type_check_on
- }
-type_check;
-
/* case_mode ==
case_mode_auto: case_sensitivity set upon selection of scope.
case_mode_manual: case_sensitivity set only by user. */
@@ -162,10 +141,6 @@ struct language_defn
enum range_check la_range_check;
- /* Default type checking. */
-
- enum type_check la_type_check;
-
/* Default case sensitivity. */
enum case_sensitivity la_case_sensitivity;
@@ -422,9 +397,6 @@ struct type *language_lookup_primitive_type_by_name (const struct language_defn
/* These macros define the behaviour of the expression
evaluator. */
-/* Should we strictly type check expressions? */
-#define STRICT_TYPE (type_check != type_check_off)
-
/* Should we range check values against the domain of their type? */
#define RANGE_CHECK (range_check != range_check_off)
@@ -496,8 +468,6 @@ extern void binop_type_check (struct value *, struct value *, int);
/* Error messages */
-extern void type_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
-
extern void range_error (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
/* Data: Does this value represent "truth" to the current language? */
diff --git a/gdb/language.c b/gdb/language.c
index f0a8697..841f2d6 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -55,7 +55,7 @@ static void show_check (char *, int);
static void set_check (char *, int);
-static void set_type_range_case (void);
+static void set_range_case (void);
static void unk_lang_emit_char (int c, struct type *type,
struct ui_file *stream, int quoter);
@@ -81,8 +81,6 @@ extern const struct language_defn unknown_language_defn;
enum range_mode range_mode = range_mode_auto;
enum range_check range_check = range_check_off;
-enum type_mode type_mode = type_mode_auto;
-enum type_check type_check = type_check_off;
enum case_mode case_mode = case_mode_auto;
enum case_sensitivity case_sensitivity = case_sensitive_on;
@@ -174,7 +172,7 @@ set_language_command (char *ignore, int from_tty, struct cmd_list_element *c)
/* Enter manual mode. Set the specified language. */
language_mode = language_mode_manual;
current_language = languages[i];
- set_type_range_case ();
+ set_range_case ();
expected_language = current_language;
return;
}
@@ -186,79 +184,6 @@ set_language_command (char *ignore, int from_tty, struct cmd_list_element *c)
language);
}
-/* Show command. Display a warning if the type setting does
- not match the current language. */
-static void
-show_type_command (struct ui_file *file, int from_tty,
- struct cmd_list_element *c, const char *value)
-{
- if (type_mode == type_mode_auto)
- {
- char *tmp = NULL;
-
- switch (type_check)
- {
- case type_check_on:
- tmp = "on";
- break;
- case type_check_off:
- tmp = "off";
- break;
- case type_check_warn:
- tmp = "warn";
- break;
- default:
- internal_error (__FILE__, __LINE__,
- "Unrecognized type check setting.");
- }
-
- fprintf_filtered (gdb_stdout,
- _("Type checking is \"auto; currently %s\".\n"),
- tmp);
- }
- else
- fprintf_filtered (gdb_stdout, _("Type checking is \"%s\".\n"),
- value);
-
- if (type_check != current_language->la_type_check)
- warning (_("the current type check setting"
- " does not match the language.\n"));
-}
-
-/* Set command. Change the setting for type checking. */
-static void
-set_type_command (char *ignore, int from_tty, struct cmd_list_element *c)
-{
- if (strcmp (type, "on") == 0)
- {
- type_check = type_check_on;
- type_mode = type_mode_manual;
- }
- else if (strcmp (type, "warn") == 0)
- {
- type_check = type_check_warn;
- type_mode = type_mode_manual;
- }
- else if (strcmp (type, "off") == 0)
- {
- type_check = type_check_off;
- type_mode = type_mode_manual;
- }
- else if (strcmp (type, "auto") == 0)
- {
- type_mode = type_mode_auto;
- set_type_range_case ();
- return;
- }
- else
- internal_error (__FILE__, __LINE__,
- _("Unrecognized type check setting: \"%s\""), type);
-
- if (type_check != current_language->la_type_check)
- warning (_("the current type check setting"
- " does not match the language.\n"));
-}
-
/* Show command. Display a warning if the range setting does
not match the current language. */
static void
@@ -320,7 +245,7 @@ set_range_command (char *ignore, int from_tty, struct cmd_list_element *c)
else if (strcmp (range, "auto") == 0)
{
range_mode = range_mode_auto;
- set_type_range_case ();
+ set_range_case ();
return;
}
else
@@ -389,7 +314,7 @@ set_case_command (char *ignore, int from_tty, struct cmd_list_element *c)
else if (strcmp (case_sensitive, "auto") == 0)
{
case_mode = case_mode_auto;
- set_type_range_case ();
+ set_range_case ();
return;
}
else
@@ -409,14 +334,11 @@ set_case_command (char *ignore, int from_tty, struct cmd_list_element *c)
If SHOW is non-zero, then print out the current language,
type and range checking status. */
static void
-set_type_range_case (void)
+set_range_case (void)
{
if (range_mode == range_mode_auto)
range_check = current_language->la_range_check;
- if (type_mode == type_mode_auto)
- type_check = current_language->la_type_check;
-
if (case_mode == case_mode_auto)
case_sensitivity = current_language->la_case_sensitivity;
}
@@ -437,7 +359,7 @@ set_language (enum language lang)
if (languages[i]->la_language == lang)
{
current_language = languages[i];
- set_type_range_case ();
+ set_range_case ();
break;
}
}
@@ -461,8 +383,6 @@ language_info (int quietly)
if (!quietly)
{
- printf_unfiltered (_("Type checking: %s\n"), type);
- show_type_command (NULL, 1, NULL, NULL);
printf_unfiltered (_("Range checking: %s\n"), range);
show_range_command (NULL, 1, NULL, NULL);
printf_unfiltered (_("Case sensitivity: %s\n"), case_sensitive);
@@ -500,38 +420,11 @@ value_true (struct value *val)
error messages that occur during type- and range-
checking. */
-/* These are called when a language fails a type- or range-check. The
+/* This is called when a language fails a range-check. The
first argument should be a printf()-style format string, and the
- rest of the arguments should be its arguments. If
- [type|range]_check is [type|range]_check_on, an error is printed;
- if [type|range]_check_warn, a warning; otherwise just the
- message. */
-
-void
-type_error (const char *string,...)
-{
- va_list args;
-
- va_start (args, string);
- switch (type_check)
- {
- case type_check_warn:
- vwarning (string, args);
- break;
- case type_check_on:
- verror (string, args);
- break;
- case type_check_off:
- /* FIXME: cagney/2002-01-30: Should this function print anything
- when type error is off? */
- vfprintf_filtered (gdb_stderr, string, args);
- fprintf_filtered (gdb_stderr, "\n");
- break;
- default:
- internal_error (__FILE__, __LINE__, _("bad switch"));
- }
- va_end (args);
-}
+ rest of the arguments should be its arguments. If range_check is
+ range_check_on, an error is printed; if range_check_warn, a warning;
+ otherwise just the message. */
void
range_error (const char *string,...)
@@ -902,7 +795,6 @@ const struct language_defn unknown_language_defn =
"unknown",
language_unknown,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
@@ -946,7 +838,6 @@ const struct language_defn auto_language_defn =
"auto",
language_auto,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
@@ -988,7 +879,6 @@ const struct language_defn local_language_defn =
"local",
language_auto,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
@@ -1135,13 +1025,6 @@ _initialize_language (void)
add_alias_cmd ("c", "check", no_class, 1, &showlist);
add_alias_cmd ("ch", "check", no_class, 1, &showlist);
- add_setshow_enum_cmd ("type", class_support, type_or_range_names, &type,
- _("Set type checking. (on/warn/off/auto)"),
- _("Show type checking. (on/warn/off/auto)"),
- NULL, set_type_command,
- show_type_command,
- &setchecklist, &showchecklist);
-
add_setshow_enum_cmd ("range", class_support, type_or_range_names,
&range,
_("Set range checking. (on/warn/off/auto)"),
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index aa090af..38bc637 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12499,7 +12499,6 @@ const struct language_defn ada_language_defn = {
"ada", /* Language name */
language_ada,
range_check_off,
- type_check_off,
case_sensitive_on, /* Yes, Ada is case-insensitive, but
that's not quite what this means. */
array_row_major,
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index b5135d5..84830be 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -831,7 +831,6 @@ const struct language_defn c_language_defn =
"c", /* Language name */
language_c,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
@@ -955,7 +954,6 @@ const struct language_defn cplus_language_defn =
"c++", /* Language name */
language_cplus,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
@@ -997,7 +995,6 @@ const struct language_defn asm_language_defn =
"asm", /* Language name */
language_asm,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
@@ -1044,7 +1041,6 @@ const struct language_defn minimal_language_defn =
"minimal", /* Language name */
language_minimal,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 121040a..7b2c322 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -240,7 +240,6 @@ static const struct language_defn d_language_defn =
"d",
language_d,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 7492149..adab736 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -274,7 +274,6 @@ const struct language_defn f_language_defn =
"fortran",
language_fortran,
range_check_on,
- type_check_on,
case_sensitive_off,
array_column_major,
macro_expansion_no,
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 147a922..21f2427 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -562,7 +562,6 @@ static const struct language_defn go_language_defn =
"go",
language_go,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index a7cfb76..6b865dc 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -1167,7 +1167,6 @@ const struct language_defn java_language_defn =
"java", /* Language name */
language_java,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_no,
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index 8faa6c1..a87039c 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -370,7 +370,6 @@ const struct language_defn m2_language_defn =
"modula-2",
language_m2,
range_check_on,
- type_check_on,
case_sensitive_on,
array_row_major,
macro_expansion_no,
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 1a07c33..e42a03c 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -509,7 +509,6 @@ const struct language_defn objc_language_defn = {
"objective-c", /* Language name */
language_objc,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index 54075a4..b8fd9b7 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -993,7 +993,6 @@ const struct language_defn opencl_language_defn =
"opencl", /* Language name */
language_opencl,
range_check_off,
- type_check_off,
case_sensitive_on,
array_row_major,
macro_expansion_c,
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index c59ba0b..114efbc 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -429,7 +429,6 @@ const struct language_defn pascal_language_defn =
"pascal", /* Language name */
language_pascal,
range_check_on,
- type_check_on,
case_sensitive_on,
array_row_major,
macro_expansion_no,