* [Ada] Implement new flag Has_Wide_Wide_Character
@ 2009-11-30 14:11 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2009-11-30 14:11 UTC (permalink / raw)
To: gcc-patches; +Cc: Robert Dewar
[-- Attachment #1: Type: text/plain, Size: 754 bytes --]
This patch implements a new flag Has_Wide_Wide_Character on string
literal nodes, and also fixes the bug of Has_Wide_Character flag
being sticky (never got reset). No test, because no functional
effect (Has_Wide_Character was not used, and Has_Wide_Wide_Character
is not yet used).
Tested on x86_64-pc-linux-gnu, committed on trunk
2009-11-30 Robert Dewar <dewar@adacore.com>
* scans.ads (Wide_Wide_Character_Found): New flag
* scn.adb (Post_Scan): Set new flag Has_Wide_Wide_Character
* scng.adb (Set_String): Set new flag Wide_Wide_Character_Found
(Set_String): Fix failure to reset Wide_Character_Found
* sinfo.adb (Has_Wide_Wide_Character): New flag in N_String_Literal
* sinfo.ads (Has_Wide_Wide_Character): New flag in N_String_Literal
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 8092 bytes --]
Index: sinfo.adb
===================================================================
--- sinfo.adb (revision 154803)
+++ sinfo.adb (working copy)
@@ -1481,6 +1481,14 @@ package body Sinfo is
return Flag11 (N);
end Has_Wide_Character;
+ function Has_Wide_Wide_Character
+ (N : Node_Id) return Boolean is
+ begin
+ pragma Assert (False
+ or else NT (N).Nkind = N_String_Literal);
+ return Flag13 (N);
+ end Has_Wide_Wide_Character;
+
function Hidden_By_Use_Clause
(N : Node_Id) return Elist_Id is
begin
@@ -4351,6 +4359,14 @@ package body Sinfo is
Set_Flag11 (N, Val);
end Set_Has_Wide_Character;
+ procedure Set_Has_Wide_Wide_Character
+ (N : Node_Id; Val : Boolean := True) is
+ begin
+ pragma Assert (False
+ or else NT (N).Nkind = N_String_Literal);
+ Set_Flag13 (N, Val);
+ end Set_Has_Wide_Wide_Character;
+
procedure Set_Hidden_By_Use_Clause
(N : Node_Id; Val : Elist_Id) is
begin
Index: sinfo.ads
===================================================================
--- sinfo.ads (revision 154803)
+++ sinfo.ads (working copy)
@@ -1149,7 +1149,13 @@ package Sinfo is
-- Has_Wide_Character (Flag11-Sem)
-- Present in string literals, set if any wide character (i.e. character
- -- code outside the Character range) appears in the string.
+ -- code outside the Character range but within Wide_Character range)
+ -- appears in the string. Used to implement pragma preference rules.
+
+ -- Has_Wide_Wide_Character (Flag13-Sem)
+ -- Present in string literals, set if any wide character (i.e. character
+ -- code outside the Wide_Character range) appears in the string. Used to
+ -- implement pragma preference rules.
-- Hidden_By_Use_Clause (Elist4-Sem)
-- An entity list present in use clauses that appear within
@@ -1179,7 +1185,7 @@ package Sinfo is
-- to the node for the spec of the instance, inserted as part of the
-- semantic processing for instantiations in Sem_Ch12.
- -- Is_Accessibility_Actual (Flag13-Sem)
+ -- Is_Accessibility_Actual (Flag12-Sem)
-- Present in N_Parameter_Association nodes. True if the parameter is
-- an extra actual that carries the accessibility level of the actual
-- for an access parameter, in a function that dispatches on result and
@@ -1937,6 +1943,7 @@ package Sinfo is
-- Sloc points to literal
-- Strval (Str3) contains Id of string value
-- Has_Wide_Character (Flag11-Sem)
+ -- Has_Wide_Wide_Character (Flag13-Sem)
-- Is_Folded_In_Parser (Flag4)
-- plus fields for expression
@@ -8059,6 +8066,9 @@ package Sinfo is
function Has_Wide_Character
(N : Node_Id) return Boolean; -- Flag11
+ function Has_Wide_Wide_Character
+ (N : Node_Id) return Boolean; -- Flag13
+
function Hidden_By_Use_Clause
(N : Node_Id) return Elist_Id; -- Elist4
@@ -8974,6 +8984,9 @@ package Sinfo is
procedure Set_Has_Wide_Character
(N : Node_Id; Val : Boolean := True); -- Flag11
+ procedure Set_Has_Wide_Wide_Character
+ (N : Node_Id; Val : Boolean := True); -- Flag13
+
procedure Set_Hidden_By_Use_Clause
(N : Node_Id; Val : Elist_Id); -- Elist4
@@ -11274,6 +11287,7 @@ package Sinfo is
pragma Inline (Has_Task_Info_Pragma);
pragma Inline (Has_Task_Name_Pragma);
pragma Inline (Has_Wide_Character);
+ pragma Inline (Has_Wide_Wide_Character);
pragma Inline (Hidden_By_Use_Clause);
pragma Inline (High_Bound);
pragma Inline (Identifier);
@@ -11575,6 +11589,7 @@ package Sinfo is
pragma Inline (Set_Has_Task_Info_Pragma);
pragma Inline (Set_Has_Task_Name_Pragma);
pragma Inline (Set_Has_Wide_Character);
+ pragma Inline (Set_Has_Wide_Wide_Character);
pragma Inline (Set_Hidden_By_Use_Clause);
pragma Inline (Set_High_Bound);
pragma Inline (Set_Identifier);
Index: scng.adb
===================================================================
--- scng.adb (revision 154755)
+++ scng.adb (working copy)
@@ -785,12 +785,12 @@ package body Scng is
procedure Set_String;
-- Procedure used to distinguish between string and operator symbol.
- -- On entry the string has been scanned out, and its characters
- -- start at Token_Ptr and end one character before Scan_Ptr. On exit
- -- Token is set to Tok_String_Literal or Tok_Operator_Symbol as
- -- appropriate, and Token_Node is appropriately initialized. In
- -- addition, in the operator symbol case, Token_Name is
- -- appropriately set.
+ -- On entry the string has been scanned out, and its characters start
+ -- at Token_Ptr and end one character before Scan_Ptr. On exit Token
+ -- is set to Tok_String_Literal/Tok_Operator_Symbol as appropriate,
+ -- and Token_Node is appropriately initialized. In addition, in the
+ -- operator symbol case, Token_Name is appropriately set, and the
+ -- flags [Wide_]Wide_Character_Found are set appropriately.
---------------------------
-- Error_Bad_String_Char --
@@ -1016,7 +1016,10 @@ package body Scng is
Delimiter := Source (Scan_Ptr);
Accumulate_Checksum (Delimiter);
+
Start_String;
+ Wide_Character_Found := False;
+ Wide_Wide_Character_Found := False;
Scan_Ptr := Scan_Ptr + 1;
-- Loop to scan out characters of string literal
@@ -1096,7 +1099,11 @@ package body Scng is
Store_String_Char (Code);
if not In_Character_Range (Code) then
- Wide_Character_Found := True;
+ if In_Wide_Character_Range (Code) then
+ Wide_Character_Found := True;
+ else
+ Wide_Wide_Character_Found := True;
+ end if;
end if;
end loop;
Index: scans.ads
===================================================================
--- scans.ads (revision 154755)
+++ scans.ads (working copy)
@@ -428,7 +428,13 @@ package Scans is
-- Valid only when Token = Tok_String_Literal or Tok_Operator_Symbol.
Wide_Character_Found : Boolean := False;
- -- Set True if wide character found.
+ -- Set True if wide character found (i.e. a character that does not fit
+ -- in Character, but fits in Wide_Wide_Character).
+ -- Valid only when Token = Tok_String_Literal.
+
+ Wide_Wide_Character_Found : Boolean := False;
+ -- Set True if wide wide character found (i.e. a character that does
+ -- not fit in Character or Wide_Character).
-- Valid only when Token = Tok_String_Literal.
Special_Character : Character;
Index: scn.adb
===================================================================
--- scn.adb (revision 154755)
+++ scn.adb (working copy)
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -383,7 +383,10 @@ package body Scn is
when Tok_String_Literal =>
Token_Node := New_Node (N_String_Literal, Token_Ptr);
- Set_Has_Wide_Character (Token_Node, Wide_Character_Found);
+ Set_Has_Wide_Character
+ (Token_Node, Wide_Character_Found);
+ Set_Has_Wide_Wide_Character
+ (Token_Node, Wide_Wide_Character_Found);
Set_Strval (Token_Node, String_Literal_Id);
when Tok_Operator_Symbol =>
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-11-30 14:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-30 14:11 [Ada] Implement new flag Has_Wide_Wide_Character Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).