diff --git a/src/bin/psql/gen_tabcomplete.pl b/src/bin/psql/gen_tabcomplete.pl
index 9e4c977cc5..548891edf7 100644
--- a/src/bin/psql/gen_tabcomplete.pl
+++ b/src/bin/psql/gen_tabcomplete.pl
@@ -91,7 +91,7 @@ printf $outfh <<EOM;
 
 #define SWITCH_CONVERSION_APPLIED
 
-#line 1 "tab-complete.in.c"
+#line 1 "$ARGV[0]"
 EOM
 
 # Scan input file until we find the data-replacement label line.
@@ -114,7 +114,7 @@ my $last_case_label = 0;
 # with the line numbering of the original, to simplify compiler error message
 # reading and debugging.
 my $next_line_no = $. + 1;
-$output_code .= "#line ${next_line_no} \"tab-complete.in.c\"\n";
+$output_code .= "#line ${next_line_no} \"$ARGV[0]\"\n";
 
 # Scan until we find the BEGIN GEN_TABCOMPLETE line.
 # Add the scanned code to $output_code verbatim.
@@ -131,7 +131,7 @@ $output_code .= "\t{\n";
 
 # Keep line numbering in sync.
 $next_line_no = $. + 1;
-$output_code .= "#line ${next_line_no} \"tab-complete.in.c\"\n";
+$output_code .= "#line ${next_line_no} \"$ARGV[0]\"\n";
 
 # Scan input file, collecting outer-level else-if conditions
 # to pass to process_else_if.
@@ -190,7 +190,7 @@ $output_code .= "\t}\n";
 
 # Keep line numbering in sync.
 $next_line_no = $. + 1;
-$output_code .= "#line ${next_line_no} \"tab-complete.in.c\"\n";
+$output_code .= "#line ${next_line_no} \"$ARGV[0]\"\n";
 
 # Scan the rest, adding it to $output_code verbatim.
 while (<$infh>)
@@ -245,7 +245,7 @@ sub process_else_if
 		process_match($typ, $cs, $args, $else_if_lineno, $isfirst);
 		$isfirst = 0;
 		# approximate line positioning of AND'd condition
-		$output_code .= "#line ${end_lineno} \"tab-complete.in.c\"\n";
+		$output_code .= "#line ${end_lineno} \"$ARGV[0]\"\n";
 		$output_code .= "\tif ($else_if_line\n";
 	}
 	elsif ($else_if_line =~
@@ -269,7 +269,7 @@ sub process_else_if
 	if ($end_lineno != $else_if_lineno)
 	{
 		my $next_lineno = $end_lineno + 1;
-		$output_code .= "#line ${next_lineno} \"tab-complete.in.c\"\n";
+		$output_code .= "#line ${next_lineno} \"$ARGV[0]\"\n";
 	}
 }
 
