===================================================================
@@ -919,6 +919,9 @@
Err : Boolean;
-- Error flag for Scan_Wide call
+ String_Start : Source_Ptr;
+ -- Point to first character of string
+
procedure Error_Bad_String_Char;
-- Signal bad character in string/character literal. On entry
-- Scan_Ptr points to the improper character encountered during the
@@ -966,6 +969,8 @@
-------------------------------
procedure Error_Unterminated_String is
+ S : Source_Ptr;
+
begin
-- An interesting little refinement. Consider the following
-- examples:
@@ -973,6 +978,7 @@
-- A := "this is an unterminated string;
-- A := "this is an unterminated string &
-- P(A, "this is a parameter that didn't get terminated);
+ -- P("this is a parameter that didn't get terminated, A);
-- We fiddle a little to do slightly better placement in these
-- cases also if there is white space at the end of the line we
@@ -1012,6 +1018,8 @@
return;
end if;
+ -- Backup over semicolon or right-paren/semicolon sequence
+
if Source (Scan_Ptr - 1) = ';' then
Scan_Ptr := Scan_Ptr - 1;
Unstore_String_Char;
@@ -1022,6 +1030,25 @@
end if;
end if;
+ -- See if there is a comma in the string, if so, guess that
+ -- the first comma terminates the string.
+
+ S := String_Start;
+ while S < Scan_Ptr loop
+ if Source (S) = ',' then
+ while Scan_Ptr > S loop
+ Scan_Ptr := Scan_Ptr - 1;
+ Unstore_String_Char;
+ end loop;
+
+ exit;
+ end if;
+
+ S := S + 1;
+ end loop;
+
+ -- Now we have adjusted the scan pointer, give message
+
Error_Msg_S -- CODEFIX
("missing string quote");
end Error_Unterminated_String;
@@ -1161,6 +1188,8 @@
-- quote). The latter case is an error detected by the character
-- literal circuit.
+ String_Start := Scan_Ptr;
+
Delimiter := Source (Scan_Ptr);
Accumulate_Checksum (Delimiter);
This patch improves the positioning for the case of a missing string quote when a comma is the likely intended end of the string, as shown by this example: 1. procedure mquote is 2. begin 3. Error_Msg_NE ("this is a string with missing quote, N, E); | >>> missing string quote 4. end; Previously the flag was placed on the right paren. this improves quick fix processing in GPS for this case as well. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-05 Robert Dewar <dewar@adacore.com> * scng.adb (Error_Unterminated_String): Improve flag position when comma present.