+2017-09-04 Simon Marchi <simon.marchi@ericsson.com>
+
+ * cli/cli-script.c (build_command_line): For if/while commands,
+ check whether args is empty.
+
2017-09-04 Simon Marchi <simon.marchi@ericsson.com>
* cli/cli-script.h (enum misc_command_type): Move from defs.h.
{
struct command_line *cmd;
- if (args == NULL && (type == if_control || type == while_control))
+ if ((args == NULL || *args == '\0')
+ && (type == if_control || type == while_control))
error (_("if/while commands require arguments."));
gdb_assert (args != NULL);
+2017-09-04 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.base/commands.exp: Call new procedure.
+ (define_if_without_arg_test): New procedure.
+
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.base/list-ambiguous.exp: New file.
gdb_test "bt" "hibob" "execute bt command"
}
+# Test using "if" and "while" without args when building a command list.
+
+proc define_if_without_arg_test {} {
+ foreach cmd {if while} {
+ set test "define some_command_$cmd"
+ gdb_test_multiple $test $test {
+ -re "End with" {
+ pass $test
+ }
+ }
+
+ gdb_test "$cmd" "if/while commands require arguments." "type $cmd without args"
+ }
+}
+
# Test an input line split with a continuation character (backslash)
# while entering a multi-line command (in a secondary prompt).
error_clears_commands_left
redefine_hook_test
backslash_in_multi_line_command_test
+define_if_without_arg_test
# This one should come last, as it redefines "backtrace".
redefine_backtrace_test