Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 36/40] Add comprehensive C++ operator linespec/location/completion tests
Date: Fri, 02 Jun 2017 12:23:00 -0000	[thread overview]
Message-ID: <1496406158-12663-37-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1496406158-12663-1-git-send-email-palves@redhat.com>

This exercises the special handling C++ operators require in several
places in the linespec parser, both the linespec and explicit location
completers, symbol lookup, etc.  Particularly, makes sure all that
works without quoting.

Note that despite the apparent smallish size, this adds thousands of
tests to the testsuite, due to combination explosion (linespecs,
explicit locations, tab completion, complete command, completion at
different points in each function, etc.)

Grows the gdb.linespec/ tests like this:

 -# of expected passes           4458
 +# of expected passes           8817

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* gdb.linespec/cpls-ops.cc: New file.
	* gdb.linespec/cpls-ops.exp: New file.
---
 gdb/testsuite/gdb.linespec/cpls-ops.cc  | 253 ++++++++++++++
 gdb/testsuite/gdb.linespec/cpls-ops.exp | 567 ++++++++++++++++++++++++++++++++
 2 files changed, 820 insertions(+)
 create mode 100644 gdb/testsuite/gdb.linespec/cpls-ops.cc
 create mode 100644 gdb/testsuite/gdb.linespec/cpls-ops.exp

diff --git a/gdb/testsuite/gdb.linespec/cpls-ops.cc b/gdb/testsuite/gdb.linespec/cpls-ops.cc
new file mode 100644
index 0000000..c1156f1
--- /dev/null
+++ b/gdb/testsuite/gdb.linespec/cpls-ops.cc
@@ -0,0 +1,253 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <cstddef>
+
+/* Code for operator() tests.  */
+
+struct test_unique_op_call
+{
+  void operator() (int);
+};
+
+void
+test_unique_op_call::operator() (int)
+{}
+
+struct test_op_call
+{
+  void operator() ();
+  void operator() (int);
+  void operator() (long);
+
+  template<typename T>
+  void operator() (T *);
+};
+
+void
+test_op_call::operator() (int)
+{}
+
+void
+test_op_call::operator() ()
+{}
+
+void
+test_op_call::operator() (long)
+{}
+
+template<typename T>
+void
+test_op_call::operator() (T *t)
+{
+}
+
+/* Code for operator[] tests.  */
+
+struct test_unique_op_array
+{
+  void operator[] (int);
+};
+
+void
+test_unique_op_array::operator[] (int)
+{}
+
+struct test_op_array
+{
+  void operator[] (int);
+  void operator[] (long);
+
+  template<typename T>
+  void operator[] (T *);
+};
+
+void
+test_op_array::operator[] (int)
+{}
+
+void
+test_op_array::operator[] (long)
+{}
+
+template<typename T>
+void
+test_op_array::operator[] (T *t)
+{}
+
+/* Code for operator new tests.  */
+
+struct test_op_new
+{
+  void *operator new (size_t);
+};
+
+void *
+test_op_new::operator new (size_t)
+{
+  return NULL;
+}
+
+/* Code for operator delete tests.  */
+
+struct test_op_delete
+{
+  void operator delete (void *);
+};
+
+void
+test_op_delete::operator delete (void *)
+{
+}
+
+/* Code for operator new[] tests.  */
+
+struct test_op_new_array
+{
+  void *operator new[] (size_t);
+};
+
+void *
+test_op_new_array::operator new[] (size_t)
+{
+  return NULL;
+}
+
+/* Code for operator delete[] tests.  */
+
+struct test_op_delete_array
+{
+  void operator delete[] (void *);
+};
+
+void
+test_op_delete_array::operator delete[] (void *)
+{
+}
+
+/* Code for user-defined conversion tests.  */
+
+struct test_op_conversion_res;
+
+struct test_op_conversion
+{
+  operator const volatile test_op_conversion_res **() const volatile;
+};
+
+test_op_conversion::operator const volatile test_op_conversion_res **() const volatile
+{
+  return NULL;
+}
+
+/* Code for the assignment operator tests.  */
+
+struct test_op_assign
+{
+  test_op_assign operator= (const test_op_assign &);
+};
+
+test_op_assign
+test_op_assign::operator= (const test_op_assign &)
+{
+  return test_op_assign ();
+}
+
+/* Code for the arrow operator tests.  */
+
+struct test_op_arrow
+{
+  test_op_arrow operator-> ();
+};
+
+test_op_arrow
+test_op_arrow::operator-> ()
+{
+  return test_op_arrow ();
+}
+
+/* Code for the logical/arithmetic operators tests.  */
+
+struct E
+{
+};
+
+#define GEN_OP(NS, ...)				\
+  namespace test_ops {				\
+    void operator __VA_ARGS__ {}		\
+  }						\
+  namespace test_op_ ## NS {			\
+    void operator __VA_ARGS__ {}		\
+  }
+
+GEN_OP (PLUS_A,    +=  (E, E)  )
+GEN_OP (PLUS,      +   (E, E)  )
+GEN_OP (MINUS_A,   -=  (E, E)  )
+GEN_OP (MINUS,     -   (E, E)  )
+GEN_OP (MOD_A,     %=  (E, E)  )
+GEN_OP (MOD,       %   (E, E)  )
+GEN_OP (EQ,        ==  (E, E)  )
+GEN_OP (NEQ,       !=  (E, E)  )
+GEN_OP (LAND,      &&  (E, E)  )
+GEN_OP (LOR,       ||  (E, E)  )
+GEN_OP (SL_A,      <<= (E, E)  )
+GEN_OP (SR_A,      >>= (E, E)  )
+GEN_OP (SL,        <<  (E, E)  )
+GEN_OP (SR,        >>  (E, E)  )
+GEN_OP (OE,        |=  (E, E)  )
+GEN_OP (BIT_O,     |   (E, E)  )
+GEN_OP (XOR_A,     ^=  (E, E)  )
+GEN_OP (XOR,       ^   (E, E)  )
+GEN_OP (BIT_AND_A, &=  (E, E)  )
+GEN_OP (BIT_AND,   &   (E, E)  )
+GEN_OP (LT,        <   (E, E)  )
+GEN_OP (LTE,       <=  (E, E)  )
+GEN_OP (GTE,       >=  (E, E)  )
+GEN_OP (GT,        >   (E, E)  )
+GEN_OP (MUL_A,     *=  (E, E)  )
+GEN_OP (MUL,       *   (E, E)  )
+GEN_OP (DIV_A,     /=  (E, E)  )
+GEN_OP (DIV,       /   (E, E)  )
+GEN_OP (NEG,       ~   (E)      )
+GEN_OP (NOT,       !   (E)      )
+GEN_OP (PRE_INC,   ++  (E)      )
+GEN_OP (POST_INC,  ++  (E, int) )
+GEN_OP (PRE_DEC,   --  (E)      )
+GEN_OP (POST_DEC,  --  (E, int) )
+GEN_OP (COMMA,     ,   (E, E)  )
+
+int
+main ()
+{
+  test_op_call opcall;
+  opcall ();
+  opcall (1);
+  opcall (1l);
+  opcall ((int *) 0);
+
+  test_unique_op_call opcall2;
+  opcall2 (1);
+
+  test_op_array op_array;
+  op_array[1];
+  op_array[1l];
+  op_array[(int *) 0];
+
+  test_unique_op_array unique_op_array;
+  unique_op_array[1];
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.linespec/cpls-ops.exp b/gdb/testsuite/gdb.linespec/cpls-ops.exp
new file mode 100644
index 0000000..5e173d4
--- /dev/null
+++ b/gdb/testsuite/gdb.linespec/cpls-ops.exp
@@ -0,0 +1,567 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite.
+
+load_lib completion-support.exp
+
+standard_testfile cpls-ops.cc
+
+if {[prepare_for_testing "failed to prepare" $testfile \
+	 [list $srcfile] {debug}]} {
+    return -1
+}
+
+gdb_test_no_output "set max-completions unlimited"
+
+set timeout 5
+
+# Check that the explicit location completer manages to find the next
+# option name after a "-function function" option.  A useful test when
+# the -function options's argument is a C++ operator, which can
+# include characters like '-'.
+
+proc check_explicit_skips_function_argument {function} {
+    test_gdb_complete_unique \
+	"b -function $function -sour" \
+	"b -function $function -source"
+}
+
+# Helper function for the operator new/new[] tests.  CLASS_NAME is the
+# name of the class that contains the operator we're testing.
+# BRACKETS is set to [] if testing operator new[], and to empty if
+# testing operator new.
+
+proc test_operator_new {class_name brackets} {
+    # The type size_t is typedef-ed to.
+    set size_t "unsigned long"
+
+    # Complete all prefixes between "operato" and the full prototype.
+    foreach cmd_prefix {"b" "b -function"} {
+	set location "${class_name}::operator new${brackets}($size_t)"
+	set line "$cmd_prefix $location"
+	set start [index_after "operato" $line]
+	test_complete_prefix_range $line $start
+	check_bp_locations_match_list "$cmd_prefix $location" [list $location]
+
+	# Same, but with extra spaces.  Note that the original spaces in
+	# the input line are preserved after completion.
+
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator new " \
+	    "$cmd_prefix ${class_name}::operator new ${brackets}($size_t)"
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator new ${brackets} (" \
+	    "$cmd_prefix ${class_name}::operator new ${brackets} ($size_t)"
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator new ${brackets} ( $size_t " \
+	    "$cmd_prefix ${class_name}::operator new ${brackets} ( $size_t )"
+
+	check_setting_bp_fails "$cmd_prefix ${class_name}::operator"
+
+	set location_list \
+	    [list \
+		 "${class_name}::operator new${brackets}" \
+		 "${class_name}::operator new${brackets} ($size_t)" \
+		 "${class_name}::operator new ${brackets} ( $size_t )"]
+	foreach linespec $location_list {
+	    check_bp_locations_match_list \
+		"$cmd_prefix $linespec" [list $location]
+	}
+    }
+
+    # Check that the explicit location completer manages to find the
+    # option name after -function, when the -function's argument is a
+    # C++ operator new / new[].
+    check_explicit_skips_function_argument \
+	"${class_name}::operator new ${brackets} ( $size_t )"
+}
+
+proc_with_prefix operator-new {} {
+    test_operator_new test_op_new ""
+}
+
+proc_with_prefix operator-new\[\] {} {
+    test_operator_new test_op_new_array "\[\]"
+}
+
+# Helper function for the operator delete/delete[] tests.  CLASS_NAME
+# is the name of the class that contains the operator we're testing.
+# BRACKETS is set to "[]" if testing operator delete[], and to empty
+# if testing operator delete.
+
+proc test_operator_delete {class_name brackets} {
+    # Complete all prefixes between "operato" and the full prototype.
+    foreach cmd_prefix {"b" "b -function"} {
+	set location "${class_name}::operator delete${brackets}(void*)"
+	set line "$cmd_prefix $location"
+	set start [index_after "operato" $line]
+	test_complete_prefix_range $line $start
+	check_bp_locations_match_list "$cmd_prefix $location" [list $location]
+
+	# Same, but with extra spaces.  Note that the original spaces in
+	# the input line are preserved after completion.
+
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator delete " \
+	    "$cmd_prefix ${class_name}::operator delete ${brackets}(void*)"
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator delete ${brackets} (" \
+	    "$cmd_prefix ${class_name}::operator delete ${brackets} (void*)"
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator delete ${brackets} ( void* " \
+	    "$cmd_prefix ${class_name}::operator delete ${brackets} ( void* )"
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator delete ${brackets} ( void * " \
+	    "$cmd_prefix ${class_name}::operator delete ${brackets} ( void * )"
+
+	check_setting_bp_fails "$cmd_prefix ${class_name}::operator"
+
+	set location_list \
+	    [list \
+		 "${class_name}::operator delete${brackets}" \
+		 "${class_name}::operator delete${brackets}(void *)" \
+		 "${class_name}::operator delete ${brackets} ( void * )"]
+	foreach linespec $location_list {
+	    check_bp_locations_match_list \
+		"$cmd_prefix $linespec" [list $location]
+	}
+    }
+
+    # Check that the explicit location completer manages to find the
+    # option name after -function, when the -function's argument is a
+    # C++ operator delete / delete[].
+    check_explicit_skips_function_argument \
+	"${class_name}::operator delete ${brackets} ( void * )"
+}
+
+proc_with_prefix operator-delete {} {
+    test_operator_delete test_op_delete ""
+}
+
+proc_with_prefix operator-delete\[\] {} {
+    test_operator_delete test_op_delete_array "\[\]"
+}
+
+# Helper for testing both operator() and operator[].  Tests completion
+# when the operator match is unique.  CLASS_NAME is the class that
+# holds the operator to test.  OPN and CLS are the open and close
+# characters ("()" or "[]").
+
+proc test_operator_unique {class_name opn cls} {
+    # Complete all prefixes between "oper" and the full prototype.
+    foreach cmd_prefix {"b" "b -function"} {
+	set location "${class_name}::operator${opn}${cls}(int)"
+	set line "$cmd_prefix $location"
+	set start [index_after "${class_name}" $line]
+	test_complete_prefix_range $line $start
+	check_bp_locations_match_list "$cmd_prefix $location" [list $location]
+
+	# Same, but with extra spaces.  Note that the original spaces in
+	# the input line are preserved after completion.
+
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( int " \
+	    "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( int )"
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator ${opn} ${cls}" \
+	    "$cmd_prefix ${class_name}::operator ${opn} ${cls}(int)"
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator ${opn}${cls}" \
+	    "$cmd_prefix ${class_name}::operator ${opn}${cls}(int)"
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator ${opn}" \
+	    "$cmd_prefix ${class_name}::operator ${opn}${cls}(int)"
+
+	check_setting_bp_fails "$cmd_prefix ${class_name}::operator"
+
+	set location_list \
+	    [list \
+		 "${class_name}::operator${opn}${cls}" \
+		 "${class_name}::operator ${opn}${cls}" \
+		 "${class_name}::operator ${opn}${cls}(int)" \
+		 "${class_name}::operator ${opn} ${cls} ( int )"]
+	foreach linespec $location_list {
+	    check_bp_locations_match_list \
+		"$cmd_prefix $linespec" [list $location]
+	}
+    }
+
+    # Check that the explicit location completer manages to find the
+    # option name after -function, when the -function's argument is a
+    # C++ operator().
+    check_explicit_skips_function_argument \
+	"${class_name}::operator ${opn} ${cls} ( int )"
+}
+
+# Helper for testing both operator() and operator[].  Tests completion
+# when the operator match is ambiguous.  CLASS_NAME is the class that
+# holds the operator to test.  OPN and CLS are the open and close
+# characters ("()" or "[]").
+
+proc test_operator_ambiguous {class_name opn cls} {
+    foreach cmd_prefix {"b" "b -function"} {
+	check_setting_bp_fails "$cmd_prefix ${class_name}::operator"
+
+	set linespec_noparams "${class_name}::operator${opn}${cls}"
+
+	set location_list \
+	    [list \
+		 "${class_name}::operator${opn}${cls}(int)" \
+		 "${class_name}::operator${opn}${cls}(long)" \
+		 "${class_name}::operator${opn}${cls}<int>(int*)"]
+	# The operator[] test can't have a "()" overload, since that
+	# wouldn't compile.
+	if {$opn == "("} {
+	    set location_list \
+		[concat \
+		     [list "${class_name}::operator${opn}${cls}()"] \
+		     $location_list]
+	}
+	test_gdb_complete_multiple \
+	    "$cmd_prefix " "$linespec_noparams" "" $location_list
+
+	# Setting the breakpoint doesn't create a breakpoint location
+	# for the template, because immediately after
+	# "operator()/operator[]" we have the template parameters, not
+	# the parameter list.
+	set location_list \
+	    [list \
+		 "${class_name}::operator${opn}${cls}(int)" \
+		 "${class_name}::operator${opn}${cls}(long)"]
+	if {$opn == "("} {
+	    set location_list \
+		[concat \
+		     [list "${class_name}::operator${opn}${cls}()"] \
+		     $location_list]
+	}
+	check_bp_locations_match_list "$cmd_prefix $linespec_noparams" \
+	    $location_list
+	check_bp_locations_match_list "$cmd_prefix $linespec_noparams<int>" \
+	    [list "${class_name}::operator${opn}${cls}<int>(int*)"]
+
+	# Test the template version.  Test both with and without
+	# return type.
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator${opn}${cls}<int>(in" \
+	    "$cmd_prefix ${class_name}::operator${opn}${cls}<int>(int*)"
+	check_bp_locations_match_list \
+	    "$cmd_prefix ${class_name}::operator${opn}${cls}<int>(int*)" \
+	    [list "${class_name}::operator${opn}${cls}<int>(int*)"]
+	test_gdb_complete_unique \
+	    "$cmd_prefix void ${class_name}::operator${opn}${cls}<int>(in" \
+	    "$cmd_prefix void ${class_name}::operator${opn}${cls}<int>(int*)"
+	check_bp_locations_match_list \
+	    "$cmd_prefix void ${class_name}::operator${opn}${cls}<int>(int*)" \
+	    [list "${class_name}::operator${opn}${cls}<int>(int*)"]
+
+	# Add extra spaces.
+	test_gdb_complete_unique \
+	    "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( in" \
+	    "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( int)"
+	check_bp_locations_match_list \
+	    "$cmd_prefix ${class_name}::operator ${opn} ${cls} ( int )" \
+	    [list "${class_name}::operator${opn}${cls}(int)"]
+    }
+}
+
+proc_with_prefix operator()-unique {} {
+    test_operator_unique test_unique_op_call "(" ")"
+}
+
+proc_with_prefix operator\[\]-unique {} {
+    test_operator_unique test_unique_op_array "\[" "\]"
+}
+
+proc_with_prefix operator()-ambiguous {} {
+    test_operator_ambiguous test_op_call "(" ")"
+}
+
+proc_with_prefix operator\[\]-ambiguous {} {
+    test_operator_ambiguous test_op_array "\[" "\]"
+}
+
+# Test arithmetic/logical operators.  Test completing all C++
+# arithmetic/logical operators, when all the operators are in the same
+# class.
+
+proc_with_prefix ops-valid-ambiguous {} {
+    set locations {
+	"test_ops::operator!(E)"
+	"test_ops::operator!=(E, E)"
+	"test_ops::operator%(E, E)"
+	"test_ops::operator%=(E, E)"
+	"test_ops::operator&&(E, E)"
+	"test_ops::operator&(E, E)"
+	"test_ops::operator&=(E, E)"
+	"test_ops::operator*(E, E)"
+	"test_ops::operator*=(E, E)"
+	"test_ops::operator+(E, E)"
+	"test_ops::operator++(E)"
+	"test_ops::operator++(E, int)"
+	"test_ops::operator+=(E, E)"
+	"test_ops::operator,(E, E)"
+	"test_ops::operator-(E, E)"
+	"test_ops::operator--(E)"
+	"test_ops::operator--(E, int)"
+	"test_ops::operator-=(E, E)"
+	"test_ops::operator/(E, E)"
+	"test_ops::operator/=(E, E)"
+	"test_ops::operator<(E, E)"
+	"test_ops::operator<<(E, E)"
+	"test_ops::operator<<=(E, E)"
+	"test_ops::operator<=(E, E)"
+	"test_ops::operator==(E, E)"
+	"test_ops::operator>(E, E)"
+	"test_ops::operator>=(E, E)"
+	"test_ops::operator>>(E, E)"
+	"test_ops::operator>>=(E, E)"
+	"test_ops::operator^(E, E)"
+	"test_ops::operator^=(E, E)"
+	"test_ops::operator|(E, E)"
+	"test_ops::operator|=(E, E)"
+	"test_ops::operator||(E, E)"
+	"test_ops::operator~(E)"
+    }
+    foreach linespec $locations {
+	foreach cmd_prefix {"b" "b -function"} {
+	    test_gdb_complete_unique \
+		"$cmd_prefix $linespec" \
+		"$cmd_prefix $linespec"
+
+	}
+
+	check_explicit_skips_function_argument "$linespec"
+    }
+
+    foreach cmd_prefix {"b" "b -function"} {
+	test_gdb_complete_multiple \
+	    "$cmd_prefix " "test_ops::operator" "" $locations
+    }
+}
+
+# Test completing all C++ operators, with and without spaces.  The
+# test without spaces makes sure the completion matches exactly the
+# expected prototype.  The version with whitespace is a bit more lax
+# for simplicity.  In that case, we only make sure we get back the
+# terminating ')'.  Each operator is defined in a separate class so
+# that we can exercise unique completion matches.
+
+proc_with_prefix ops-valid-unique {} {
+    set locations {
+	"test_op_BIT_AND::operator&(E, E)"
+	"test_op_BIT_AND_A::operator&=(E, E)"
+	"test_op_BIT_O::operator|(E, E)"
+	"test_op_COMMA::operator,(E, E)"
+	"test_op_DIV::operator/(E, E)"
+	"test_op_DIV_A::operator/=(E, E)"
+	"test_op_EQ::operator==(E, E)"
+	"test_op_GT::operator>(E, E)"
+	"test_op_GTE::operator>=(E, E)"
+	"test_op_LAND::operator&&(E, E)"
+	"test_op_LOR::operator||(E, E)"
+	"test_op_LT::operator<(E, E)"
+	"test_op_LTE::operator<=(E, E)"
+	"test_op_MINUS::operator-(E, E)"
+	"test_op_MINUS_A::operator-=(E, E)"
+	"test_op_MOD::operator%(E, E)"
+	"test_op_MOD_A::operator%=(E, E)"
+	"test_op_MUL::operator*(E, E)"
+	"test_op_MUL_A::operator*=(E, E)"
+	"test_op_NEG::operator~(E)"
+	"test_op_NEQ::operator!=(E, E)"
+	"test_op_NOT::operator!(E)"
+	"test_op_OE::operator|=(E, E)"
+	"test_op_PLUS::operator+(E, E)"
+	"test_op_PLUS_A::operator+=(E, E)"
+	"test_op_POST_DEC::operator--(E, int)"
+	"test_op_POST_INC::operator++(E, int)"
+	"test_op_PRE_DEC::operator--(E)"
+	"test_op_PRE_INC::operator++(E)"
+	"test_op_SL::operator<<(E, E)"
+	"test_op_SL_A::operator<<=(E, E)"
+	"test_op_SR::operator>>(E, E)"
+	"test_op_SR_A::operator>>=(E, E)"
+	"test_op_XOR::operator^(E, E)"
+	"test_op_XOR_A::operator^=(E, E)"
+    }
+    set linespecs_ws {
+	"test_op_BIT_AND::operator & ( E , E )"
+	"test_op_BIT_AND_A::operator &= ( E , E )"
+	"test_op_BIT_O::operator | (E , E )"
+	"test_op_COMMA::operator , ( E , E )"
+	"test_op_DIV::operator / (E , E )"
+	"test_op_DIV_A::operator /= ( E , E )"
+	"test_op_EQ::operator == ( E , E )"
+	"test_op_GT::operator > ( E , E )"
+	"test_op_GTE::operator >= ( E , E )"
+	"test_op_LAND::operator && ( E , E )"
+	"test_op_LOR::operator || ( E , E )"
+	"test_op_LT::operator < ( E , E )"
+	"test_op_LTE::operator <= ( E , E )"
+	"test_op_MINUS::operator - ( E , E )"
+	"test_op_MINUS_A::operator -= ( E , E )"
+	"test_op_MOD::operator % ( E , E )"
+	"test_op_MOD_A::operator %= ( E , E )"
+	"test_op_MUL::operator * ( E , E )"
+	"test_op_MUL_A::operator *= ( E , E )"
+	"test_op_NEG::operator ~ ( E )"
+	"test_op_NEQ::operator != ( E , E )"
+	"test_op_NOT::operator ! ( E )"
+	"test_op_OE::operator |= ( E , E )"
+	"test_op_PLUS::operator + ( E , E )"
+	"test_op_PLUS_A::operator += ( E , E )"
+	"test_op_POST_DEC::operator -- ( E , int )"
+	"test_op_POST_INC::operator ++ ( E , int )"
+	"test_op_PRE_DEC::operator -- ( E )"
+	"test_op_PRE_INC::operator ++ ( E )"
+	"test_op_SL::operator << ( E , E )"
+	"test_op_SL_A::operator <<= ( E , E )"
+	"test_op_SR::operator >> ( E , E )"
+	"test_op_SR_A::operator >>= ( E , E )"
+	"test_op_XOR::operator ^ ( E , E )"
+	"test_op_XOR_A::operator ^= ( E , E )"
+    }
+    foreach linespec $locations linespec_ws $linespecs_ws {
+	foreach cmd_prefix {"b" "b -function"} {
+	    with_test_prefix "no-whitespace" {
+		set line "$cmd_prefix $linespec"
+		set start [index_after "::operato" $line]
+		test_complete_prefix_range $line $start
+	    }
+
+	    with_test_prefix "whitespace" {
+		set line_ws "$cmd_prefix $linespec_ws"
+		set start_ws [index_after "::operator " $line_ws]
+		test_complete_prefix_range_input \
+		    $line_ws "$cmd_prefix test_op_.*::operator .*\\\)" $start_ws
+	    }
+	}
+
+	check_explicit_skips_function_argument "$linespec"
+	check_explicit_skips_function_argument "$linespec_ws"
+    }
+}
+
+# Test completing an invalid (whitespace at the wrong place) operator
+# name.
+
+proc_with_prefix ops-invalid {} {
+    foreach linespec {
+	"test_op_BIT_AND_A::operator& =(E, E)"
+	"test_op_DIV_A::operator/ =(E, E)"
+	"test_op_EQ::operator= =(E, E)"
+	"test_op_GTE::operator> =(E, E)"
+	"test_op_LAND::operator& &(E, E)"
+	"test_op_LOR::operator| |(E, E)"
+	"test_op_LTE::operator< =(E, E)"
+	"test_op_MINUS_A::operator- =(E, E)"
+	"test_op_MOD_A::operator% =(E, E)"
+	"test_op_MUL_A::operator* =(E, E)"
+	"test_op_NEQ::operator! =(E, E)"
+	"test_op_OE::operator| =(E, E)"
+	"test_op_PLUS_A::operator+ =(E, E)"
+	"test_op_POST_DEC::operator- -(E, int)"
+	"test_op_POST_INC::operator+ +(E, int)"
+	"test_op_PRE_DEC::operator- -(E)"
+	"test_op_PRE_INC::operator+ +(E)"
+	"test_op_SL::operator< <(E, E)"
+	"test_op_SL_A::operator< < =(E, E)"
+	"test_op_SR::operator> >(E, E)"
+	"test_op_SR_A::operator> > =(E, E)"
+	"test_op_XOR_A::operator^ =(E, E)"
+    } {
+	foreach cmd_prefix {"b" "b -function"} {
+	    test_gdb_complete_tab_none "$cmd_prefix $linespec"
+	    check_setting_bp_fails "$cmd_prefix $linespec"
+	}
+    }
+}
+
+# Test completing function/method FUNCTION.  Completion is tested at
+# every point starting after START_AFTER.  FUNCTION_WS is a version of
+# FUNCTION with extra (but valid) whitespace.  FUNCTION_INVALID is a
+# version of FUNCTION with invalid whitespace.  Tests that completion
+# of FUNCTION_WS completes to self, and that a completion of
+# FUNCTION_INVALID fails.
+
+proc test_function {function start_after function_ws {function_invalid ""}} {
+    foreach cmd_prefix {"b" "b -function"} {
+	set line "$cmd_prefix $function"
+	set start [index_after $start_after $line]
+	test_complete_prefix_range $line $start
+    }
+
+    check_explicit_skips_function_argument $function
+    check_explicit_skips_function_argument $function_ws
+
+    foreach cmd_prefix {"b" "b -function"} {
+	test_gdb_complete_unique \
+	    "$cmd_prefix $function_ws" \
+	    "$cmd_prefix $function_ws"
+	if {$function_invalid != ""} {
+	    test_gdb_complete_tab_none "$cmd_prefix $function_invalid"
+	    check_setting_bp_fails "$cmd_prefix $function_invalid"
+	}
+    }
+}
+
+# Test completing a user-defined conversion operator.
+
+proc_with_prefix conversion-operator {} {
+    test_function \
+	"test_op_conversion::operator test_op_conversion_res const volatile**() const volatile" \
+	"test_op_conversio" \
+	"test_op_conversion::operator test_op_conversion_res const volatile * * ( ) const volatile"}
+
+# Test completing an assignment operator.
+
+proc_with_prefix assignment-operator {} {
+    test_function \
+	"test_op_assign::operator=(test_op_assign const&)" \
+	"test_op_assig" \
+	"test_op_assign::operator = ( test_op_assign const & )" \
+}
+
+# Test completing an arrow operator.
+
+proc_with_prefix arrow-operator {} {
+    test_function \
+	"test_op_arrow::operator->()" \
+	"test_op_arro" \
+	"test_op_arrow::operator -> ( )" \
+	"test_op_arrow::operator - > ( )"
+}
+
+# The testcase driver.  Calls all test procedures.
+
+proc test_driver {} {
+    operator-delete
+    operator-delete\[\]
+    operator-new
+    operator-new\[\]
+    operator()-unique
+    operator()-ambiguous
+    operator\[\]-unique
+    operator\[\]-ambiguous
+    ops-valid-ambiguous
+    ops-valid-unique
+    ops-invalid
+    conversion-operator
+    assignment-operator
+    arrow-operator
+}
+
+test_driver
-- 
2.5.5


  parent reply	other threads:[~2017-06-02 12:23 UTC|newest]

Thread overview: 182+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-02 12:22 [PATCH 00/40] C++ debugging improvements: breakpoints, TAB completion, more Pedro Alves
2017-06-02 12:22 ` [PATCH 06/40] Expression completer should not match explicit location options Pedro Alves
2017-06-29  8:29   ` Yao Qi
2017-06-29 10:56     ` Pedro Alves
2017-06-29 11:08       ` Pedro Alves
2017-06-29 15:23         ` Pedro Alves
2017-06-29 11:24       ` Yao Qi
2017-06-29 15:25         ` Pedro Alves
2017-06-02 12:22 ` [PATCH 08/40] completion_list_add_name wrapper functions Pedro Alves
2017-06-27 12:56   ` Yao Qi
2017-06-27 15:35     ` Pedro Alves
2017-06-02 12:22 ` [PATCH 02/40] Eliminate make_cleanup_obstack_free, introduce auto_obstack Pedro Alves
2017-06-26 13:47   ` Yao Qi
2017-06-27 10:25     ` Pedro Alves
2017-06-28 10:36   ` Yao Qi
2017-06-28 14:39     ` Pedro Alves
2017-06-28 21:33       ` Yao Qi
2017-06-02 12:22 ` [PATCH 03/40] Fix gdb.base/completion.exp with --target_board=dwarf4-gdb-index Pedro Alves
2017-07-13 20:28   ` Keith Seitz
2017-07-14 16:02     ` Pedro Alves
2017-06-02 12:22 ` [PATCH 01/40] Make gdb.base/dmsym.exp independent of "set language ada" Pedro Alves
2017-07-18 19:42   ` Simon Marchi
2017-07-20 17:00     ` Pedro Alves
2017-06-02 12:22 ` [PATCH 14/40] Introduce CP_OPERATOR_STR/CP_OPERATOR_LEN and use throughout Pedro Alves
2017-07-14 18:04   ` Keith Seitz
2017-07-17 14:55     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 37/40] Fix completing an empty string Pedro Alves
2017-08-09 18:01   ` Keith Seitz
2017-11-25  0:28     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 27/40] Make cp_remove_params return a unique_ptr Pedro Alves
2017-08-08 20:35   ` Keith Seitz
2017-10-09 15:13     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 10/40] Clean up "completer_handle_brkchars" callback handling Pedro Alves
2017-07-13 21:08   ` Keith Seitz
2017-07-17 11:14     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 34/40] Make strcmp_iw NOT ignore whitespace in the middle of tokens Pedro Alves
2017-08-09 15:48   ` Keith Seitz
2017-11-24 23:38     ` [pushed] " Pedro Alves
2017-06-02 12:23 ` [PATCH 15/40] Rewrite/enhance explicit locations completer, parse left->right Pedro Alves
2017-07-14 20:55   ` Keith Seitz
2017-07-17 19:24     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 39/40] Breakpoints in symbols with ABI tags (PR c++/19436) Pedro Alves
2017-08-09 19:34   ` Keith Seitz
2017-11-27 17:14     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 35/40] Comprehensive C++ linespec/completer tests Pedro Alves
2017-08-09 17:30   ` Keith Seitz
2017-11-24 16:25     ` Pedro Alves
2017-06-02 12:23 ` Pedro Alves [this message]
2017-08-09 17:59   ` [PATCH 36/40] Add comprehensive C++ operator linespec/location/completion tests Keith Seitz
2017-11-25  0:18     ` [pushed] " Pedro Alves
2017-11-30 15:43       ` Yao Qi
2017-11-30 16:06         ` Pedro Alves
2017-11-30 16:35           ` [pushed] Fix gdb.linespec/cpls-ops.exp on 32-bit (Re: [pushed] Re: [PATCH 36/40] Add comprehensive C++ operator linespec/location/completion tests) Pedro Alves
2017-06-02 12:23 ` [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction Pedro Alves
2017-07-14 17:23   ` Keith Seitz
2017-07-17 13:56     ` Pedro Alves
2017-07-18  8:23       ` Christophe Lyon
     [not found]         ` <845f435e-d3d5-b327-4e3a-ce9434bd6ffd@redhat.com>
2017-07-18 10:42           ` [pushed] Fix GDB builds that include the simulator (Re: [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction) Pedro Alves
2018-03-05 21:43   ` [PATCH 11/40] Introduce class completion_tracker & rewrite completion<->readline interaction Simon Marchi
2017-06-02 12:23 ` [PATCH 38/40] Use TOLOWER in SYMBOL_HASH_NEXT Pedro Alves
2017-08-09 19:25   ` Keith Seitz
2017-11-25  0:35     ` [pushed] " Pedro Alves
2017-06-02 12:23 ` [PATCH 13/40] Introduce strncmp_iw Pedro Alves
2017-06-29  8:42   ` Yao Qi
2017-07-17 19:16     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 09/40] Rename make_symbol_completion_list_fn -> symbol_completer Pedro Alves
2017-06-28 21:40   ` Yao Qi
2017-07-13 20:46   ` Keith Seitz
2017-07-17 11:00     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 40/40] Document breakpoints / linespec & co improvements (manual + NEWS) Pedro Alves
2017-06-02 13:01   ` Eli Zaretskii
2017-06-02 13:33     ` Pedro Alves
2017-06-21 15:50       ` Pedro Alves
2017-06-21 19:14         ` Pedro Alves
2017-06-22 19:45           ` Eli Zaretskii
2017-06-22 19:42         ` Eli Zaretskii
2017-06-21 13:32     ` Pedro Alves
2017-06-21 18:26       ` Eli Zaretskii
2017-06-21 19:01         ` Pedro Alves
2017-06-22 19:43           ` Eli Zaretskii
2017-06-02 12:23 ` [PATCH 19/40] Fix cp_find_first_component_aux bug Pedro Alves
2017-07-17 19:17   ` Keith Seitz
2017-07-17 19:50     ` Pedro Alves
2017-07-17 21:38       ` Keith Seitz
2017-07-20 17:03         ` Pedro Alves
2017-06-02 12:23 ` [PATCH 28/40] lookup_name_info::make_ignore_params Pedro Alves
2017-08-08 20:55   ` Keith Seitz
2017-11-08 16:18     ` Pedro Alves
2017-06-02 12:23 ` [PATCH 18/40] A smarter linespec completer Pedro Alves
2017-07-15  0:07   ` Keith Seitz
2017-07-17 18:21     ` Pedro Alves
2017-07-17 19:02       ` Keith Seitz
2017-07-17 19:33         ` Pedro Alves
2017-06-02 12:28 ` [PATCH 24/40] Per-language symbol name hashing algorithm Pedro Alves
2017-07-18 17:33   ` Keith Seitz
2017-07-20 18:53     ` Pedro Alves
2017-11-08 16:08       ` Pedro Alves
2017-06-02 12:29 ` [PATCH 21/40] Use SYMBOL_MATCHES_SEARCH_NAME some more Pedro Alves
2017-07-17 21:39   ` Keith Seitz
2017-07-20 17:08     ` Pedro Alves
2017-06-02 12:29 ` [PATCH 05/40] command.h: Include scoped_restore_command.h Pedro Alves
2017-06-27 11:30   ` Yao Qi
2017-06-27 11:45     ` Pedro Alves
2017-06-27 11:52       ` Pedro Alves
2017-06-27 12:03         ` Pedro Alves
2017-06-27 15:46           ` [PATCH 05/40] command.h: Include common/scoped_restore.h Pedro Alves
2017-06-28  7:54             ` Yao Qi
2017-06-28 14:20               ` Pedro Alves
2017-06-02 12:29 ` [PATCH 07/40] objfile_per_bfd_storage non-POD Pedro Alves
2017-06-27 12:00   ` Yao Qi
2017-06-27 15:30     ` Pedro Alves
2017-06-02 12:29 ` [PATCH 16/40] Explicit locations -label completer Pedro Alves
2017-07-14 21:32   ` Keith Seitz
2017-06-02 12:29 ` [PATCH 17/40] Linespec lexing and C++ operators Pedro Alves
2017-07-14 21:45   ` Keith Seitz
2017-07-17 19:34     ` Pedro Alves
2017-06-02 12:29 ` [PATCH 12/40] "complete" command and completion word break characters Pedro Alves
2017-07-14 17:50   ` Keith Seitz
2017-07-17 14:36     ` Pedro Alves
2017-06-02 12:29 ` [PATCH 33/40] Make the linespec/location completer ignore data symbols Pedro Alves
2017-08-09 15:42   ` Keith Seitz
2017-11-08 16:22     ` Pedro Alves
2017-06-02 12:30 ` [PATCH 32/40] Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching] Pedro Alves
2017-08-08 23:48   ` Keith Seitz
2017-11-22 16:48     ` Pedro Alves
2017-11-24 16:48       ` Pedro Alves
2017-11-24 16:57         ` Pedro Alves
2017-11-28  0:39         ` Keith Seitz
2017-11-28  0:02       ` Keith Seitz
2017-11-28  0:21         ` Pedro Alves
2017-11-28  0:42           ` Keith Seitz
2017-06-02 12:30 ` [PATCH 30/40] Use search_domain::FUNCTIONS_DOMAIN when setting breakpoints Pedro Alves
2017-08-08 21:07   ` Keith Seitz
2017-11-08 16:20     ` Pedro Alves
2017-06-02 12:30 ` [PATCH 20/40] Eliminate block_iter_name_* Pedro Alves
2017-07-17 19:47   ` Keith Seitz
2017-07-20 17:05     ` Pedro Alves
2017-06-02 12:31 ` [PATCH 22/40] get_int_var_value Pedro Alves
2017-07-17 22:11   ` Keith Seitz
2017-07-20 17:15     ` Pedro Alves
2017-06-02 12:31 ` [PATCH 29/40] Simplify completion_list_add_name | remove sym_text / sym_text_len Pedro Alves
2017-08-08 20:59   ` Keith Seitz
2017-11-08 16:19     ` Pedro Alves
2017-06-02 12:31 ` [PATCH 04/40] Fix TAB-completion + .gdb_index slowness (generalize filename_seen_cache) Pedro Alves
2017-07-13 20:41   ` Keith Seitz
2017-07-14 19:40     ` Pedro Alves
2017-07-17 10:51       ` Pedro Alves
2017-06-02 12:33 ` [PATCH 31/40] Handle custom completion match prefix / LCD Pedro Alves
2017-08-08 21:28   ` Keith Seitz
2017-11-27 17:11     ` Pedro Alves
2017-06-02 12:39 ` [PATCH 26/40] Optimize .gdb_index symbol name searching Pedro Alves
2017-08-08 20:32   ` Keith Seitz
2017-11-08 16:14     ` Pedro Alves
2017-11-08 16:16       ` [pushed] Reorder/reindent dw2_expand_symtabs_matching & friends (Re: [PATCH 26/40] Optimize .gdb_index symbol name searching) Pedro Alves
2017-11-18  5:23   ` [PATCH 26/40] Optimize .gdb_index symbol name searching Simon Marchi
2017-11-20  0:33     ` Pedro Alves
2017-11-20  0:42       ` [PATCH 1/3] 0xff chars in name components table; cp-name-parser lex UTF-8 identifiers Pedro Alves
2017-11-20  1:38         ` Simon Marchi
2017-11-20 11:56           ` Pedro Alves
2017-11-20 16:50             ` Simon Marchi
2017-11-21  0:11               ` Pedro Alves
2017-11-20  0:42       ` [PATCH 3/3] Fix mapped_index::find_name_components_bounds upper bound computation Pedro Alves
2017-11-20  3:17         ` Simon Marchi
2017-11-20  0:42       ` [PATCH 2/3] Unit test name-component bounds searching directly Pedro Alves
2017-11-20  3:16         ` Simon Marchi
2017-11-20 14:17           ` Pedro Alves
2017-06-02 12:39 ` [PATCH 23/40] Make language_def O(1) Pedro Alves
2017-07-17 23:03   ` Keith Seitz
2017-07-20 17:40     ` Pedro Alves
2017-07-20 18:12       ` Get rid of "set language local"? (was: Re: [PATCH 23/40] Make language_def O(1)) Pedro Alves
2017-07-20 23:44         ` Matt Rice
2017-06-02 12:39 ` [PATCH 25/40] Introduce lookup_name_info and generalize Ada's FULL/WILD name matching Pedro Alves
2017-07-18 20:14   ` Keith Seitz
2017-07-18 22:31     ` Pedro Alves
2017-07-20 19:00       ` Pedro Alves
2017-07-20 19:06         ` Pedro Alves
2017-08-08 20:29           ` Keith Seitz
2017-10-19 17:36             ` Pedro Alves
2017-11-01 15:38               ` Joel Brobecker
2017-11-08 16:10                 ` Pedro Alves
2017-11-08 22:15                   ` Joel Brobecker
2017-06-02 15:26 ` [PATCH 00/40] C++ debugging improvements: breakpoints, TAB completion, more Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1496406158-12663-37-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox