aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_attr.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2017-04-25 10:33:18 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2017-04-25 10:33:18 +0200
commit2bb988bb1cb15663ce9d01368d31d66161183b41 (patch)
treeef7d98dc387ce923dcfce2f345cce20be82944bd /gcc/ada/sem_attr.adb
parentb03d3f7390b5744c5fdf54a73fec6a28a8849a1b (diff)
downloadgcc-2bb988bb1cb15663ce9d01368d31d66161183b41.zip
gcc-2bb988bb1cb15663ce9d01368d31d66161183b41.tar.gz
gcc-2bb988bb1cb15663ce9d01368d31d66161183b41.tar.bz2
[multiple changes]
2017-04-25 Hristian Kirtchev <kirtchev@adacore.com> * sem_aggr.adb, inline.adb, einfo.adb, einfo.ads, scng.adb, sem_prag.adb: Minor reformatting. 2017-04-25 Bob Duff <duff@adacore.com> * sem_attr.adb (Type_Key): Add code in the recursive Compute_Type_Key to protect against fetching the source code for Standard, in case a component of the type is declared in Standard. There was already code to do this for the original type, but not for its components. From-SVN: r247147
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r--gcc/ada/sem_attr.adb41
1 files changed, 26 insertions, 15 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index bb719d3..40ee462 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -6256,6 +6256,21 @@ package body Sem_Attr is
return;
end if;
+ -- If the type is declared in Standard, there is no source, so
+ -- just use its name.
+
+ if Scope (T) = Standard_Standard then
+ declare
+ Name : constant String := Get_Name_String (Chars (T));
+ begin
+ for J in Name'Range loop
+ System.CRC32.Update (CRC, Name (J));
+ end loop;
+ end;
+
+ return;
+ end if;
+
Sloc_Range (Enclosing_Declaration (T), P_Min, P_Max);
SFI := Get_Source_File_Index (P_Min);
Buffer := Source_Text (SFI);
@@ -6318,25 +6333,21 @@ package body Sem_Attr is
Store_String_Char (Get_String_Char (Full_Name, Pos (J)));
end loop;
- -- For standard types return the name of the type, as there is no
- -- explicit source declaration to use. Otherwise compute CRC and
- -- convert it to string one character at a time, so as not to use
- -- Image within the compiler.
+ -- Compute CRC and convert it to string one character at a time, so
+ -- as not to use Image within the compiler.
- if Scope (Entity (P)) /= Standard_Standard then
- Initialize (CRC);
- Compute_Type_Key (Entity (P));
-
- if not Is_Frozen (Entity (P)) then
- Error_Msg_N ("premature usage of Type_Key?", N);
- end if;
+ Initialize (CRC);
+ Compute_Type_Key (Entity (P));
- while CRC > 0 loop
- Store_String_Char (Character'Val (48 + (CRC rem 10)));
- CRC := CRC / 10;
- end loop;
+ if not Is_Frozen (Entity (P)) then
+ Error_Msg_N ("premature usage of Type_Key?", N);
end if;
+ while CRC > 0 loop
+ Store_String_Char (Character'Val (48 + (CRC rem 10)));
+ CRC := CRC / 10;
+ end loop;
+
Rewrite (N, Make_String_Literal (Loc, End_String));
Analyze_And_Resolve (N, Standard_String);
end Type_Key;