diff --git a/gdb/testsuite/gdb.linespec/cpcompletion.exp b/gdb/testsuite/gdb.linespec/cpcompletion.exp
index 5522b19..25f7f81 100644
--- a/gdb/testsuite/gdb.linespec/cpcompletion.exp
+++ b/gdb/testsuite/gdb.linespec/cpcompletion.exp
@@ -190,37 +190,49 @@ proc_with_prefix overload-2 {} {
 # Test linespecs / locations using fully-qualified names.
 
 proc_with_prefix fqn {} {
-    set cmd_prefix "b -qualified"
 
-    test_gdb_complete_unique \
-	"$cmd_prefix overload2_func" \
-	"$cmd_prefix overload2_function(overload2_arg1)"
+    # "-qualified" works with both explicit locations and linespecs.
+    # Also test that combining a source file with a function name
+    # still results in a full match, with both linespecs and explicit
+    # locations.
+    foreach cmd_prefix {
+	"b -qualified "
+	"b -qualified -function "
+	"b -qualified cpls.cc:"
+	"b -qualified -source cpls.cc -function "
+	"b -source cpls.cc -qualified -function "
+    } {
+	test_gdb_complete_unique \
+	    "${cmd_prefix}overload2_func" \
+	    "${cmd_prefix}overload2_function(overload2_arg1)"
 
-    # Drill down until we find a unique completion.
-    test_gdb_complete_multiple "$cmd_prefix " "ns_overload2_test::" "" {
-	"ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
-	"ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
-	"ns_overload2_test::(anonymous namespace)::overload2_function(overload2_arg7)"
-	"ns_overload2_test::(anonymous namespace)::struct_overload2_test::overload2_function(overload2_arg8)"
-	"ns_overload2_test::overload2_function(overload2_arg5)"
-	"ns_overload2_test::struct_overload2_test::overload2_function(overload2_arg6)"
-    }
+	# Drill down until we find a unique completion.
+	test_gdb_complete_multiple "${cmd_prefix}" "ns_overload2_test::" "" {
+	    "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+	    "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
+	    "ns_overload2_test::(anonymous namespace)::overload2_function(overload2_arg7)"
+	    "ns_overload2_test::(anonymous namespace)::struct_overload2_test::overload2_function(overload2_arg8)"
+	    "ns_overload2_test::overload2_function(overload2_arg5)"
+	    "ns_overload2_test::struct_overload2_test::overload2_function(overload2_arg6)"
+	}
 
-    test_gdb_complete_multiple "$cmd_prefix " "ns_overload2_test::(anonymous namespace)::" "" {
-	"ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
-	"ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
-	"ns_overload2_test::(anonymous namespace)::overload2_function(overload2_arg7)"
-	"ns_overload2_test::(anonymous namespace)::struct_overload2_test::overload2_function(overload2_arg8)"
-    }
+	test_gdb_complete_multiple "${cmd_prefix}" "ns_overload2_test::(anonymous namespace)::" "" {
+	    "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+	    "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
+	    "ns_overload2_test::(anonymous namespace)::overload2_function(overload2_arg7)"
+	    "ns_overload2_test::(anonymous namespace)::struct_overload2_test::overload2_function(overload2_arg8)"
+	}
 
-    test_gdb_complete_multiple "$cmd_prefix " "ns_overload2_test::(anonymous namespace)::ns_overload2_test::" "" {
-	"ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
-	"ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
-    }
+	test_gdb_complete_multiple "${cmd_prefix}" "ns_overload2_test::(anonymous namespace)::ns_overload2_test::" "" {
+	    "ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+	    "ns_overload2_test::(anonymous namespace)::ns_overload2_test::struct_overload2_test::overload2_function(overload2_arga)"
+	}
 
-    test_gdb_complete_unique \
-	"$cmd_prefix ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_func" \
-	"$cmd_prefix ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+	test_gdb_complete_unique \
+	    "${cmd_prefix}ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_func" \
+	    "${cmd_prefix}ns_overload2_test::(anonymous namespace)::ns_overload2_test::overload2_function(overload2_arg9)"
+
+    }
 }
 
 # Check that a fully-qualified looked name don't match symbols in
diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 8fcdf62..1e7f0dc 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -409,40 +409,57 @@ namespace eval $testfile {
 	    "task"
 	    "thread"
 	}
-	foreach what { "-function" "-label" "-line" "-qualified" "-source" } {
-	    with_test_prefix "complete after $what" {
-		if {$what != "-line"} {
-		    test_gdb_complete_multiple \
-			"b $what argument " "" "" $completions_list
-		    test_gdb_complete_unique \
-			"b $what argument thr" \
-			"b $what argument thread"
-		    test_gdb_complete_unique \
-			"b $what argument -fun" \
-			"b $what argument -function"
-		} else {
-		    # After -line, we expect a number / offset.
-		    foreach line {"10" "+10" "-10"} {
-			test_gdb_complete_multiple \
-			    "b -line $line " "" "" $completions_list
-			test_gdb_complete_unique \
-			    "b -line $line thr" \
-			    "b -line $line thread"
-			test_gdb_complete_unique \
-			    "b -line $line -fun" \
-			    "b -line $line -function"
+	foreach what { "-function" "-label" "-line" "-source" } {
+	    # Also test with "-qualified" appearing before the
+	    # explicit location.
+	    foreach prefix {"" "-qualified "} {
+
+		# ... and with "-qualified" appearing after the
+		# explicit location.
+		foreach suffix {"" " -qualified"} {
+		    with_test_prefix "complete after $prefix$what$suffix" {
+			if {$what != "-line"} {
+			    set w "$prefix$what argument$suffix "
+			    test_gdb_complete_multiple \
+				"b $w" "" "" $completions_list
+			    test_gdb_complete_unique \
+				"b $w thr" \
+				"b $w thread"
+			    test_gdb_complete_unique \
+				"b $w -fun" \
+				"b $w -function"
+			} else {
+			    # After -line, we expect a number / offset.
+			    foreach line {"10" "+10" "-10"} {
+				set w "$prefix-line $line$suffix"
+				test_gdb_complete_multiple \
+				    "b $w " "" "" $completions_list
+				test_gdb_complete_unique \
+				    "b $w thr" \
+				    "b $w thread"
+				test_gdb_complete_unique \
+				    "b $w -fun" \
+				    "b $w -function"
+			    }
+
+			    # With an invalid -line argument, we don't get any
+			    # completions.
+			    test_gdb_complete_none "b $prefix-line argument$suffix "
+			}
+
 		    }
 
-		    # With an invalid -line argument, we don't get any
-		    # completions.
-		    test_gdb_complete_none "b -line argument "
 		}
 
-		# Don't complete a linespec keyword ("thread") or
-		# another option name when expecting an option
-		# argument.
-		test_gdb_complete_none "b $what thr"
-		test_gdb_complete_none "b $what -fun"
+		# These tests don't make sense with "-qualified" after
+		# the location.
+		with_test_prefix "complete after $prefix$what" {
+		    # Don't complete a linespec keyword ("thread") or
+		    # another option name when expecting an option
+		    # argument.
+		    test_gdb_complete_none "b $prefix$what thr"
+		    test_gdb_complete_none "b $prefix$what -fun"
+		}
 	    }
 	}
 
