aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2008-04-14 12:11:06 +0000
committerSamuel Tardieu <sam@gcc.gnu.org>2008-04-14 12:11:06 +0000
commitb039b10e28c986b8099ad6e013d6426387667a48 (patch)
tree3f275bf15cb26d5dd46bb90a5dd417c790a7ed3d /gcc/ada
parentcb572b755dcc64f8e5581f8734e5b1034381d41b (diff)
downloadgcc-b039b10e28c986b8099ad6e013d6426387667a48.zip
gcc-b039b10e28c986b8099ad6e013d6426387667a48.tar.gz
gcc-b039b10e28c986b8099ad6e013d6426387667a48.tar.bz2
re PR ada/16098 (Illegal program not detected, RM 13.1(6))
gcc/ada/ PR ada/16098 * sem_prag.adb (Error_Pragma_Ref): New. (Process_Convention): Specialized message for non-local subprogram renaming. Detect the problem in homonyms as well. gcc/testsuite/ PR ada/16098 * gnat.dg/specs/renamings.ads: New. From-SVN: r134262
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/sem_prag.adb29
2 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 9905b15..cdfcdfe 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,12 @@
2008-04-14 Samuel Tardieu <sam@rfc1149.net>
+ PR ada/16098
+ * sem_prag.adb (Error_Pragma_Ref): New.
+ (Process_Convention): Specialized message for non-local
+ subprogram renaming. Detect the problem in homonyms as well.
+
+2008-04-14 Samuel Tardieu <sam@rfc1149.net>
+
PR ada/15915
* sem_util.ads, sem_util.adb (Denotes_Variable): New function.
* sem_ch12.adb (Instantiate_Object): Use it.
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index b98e004..8a9a2e9 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -521,6 +521,13 @@ package body Sem_Prag is
-- reference the identifier. After placing the message, Pragma_Exit
-- is raised.
+ procedure Error_Pragma_Ref (Msg : String; Ref : Entity_Id);
+ pragma No_Return (Error_Pragma_Ref);
+ -- Outputs error message for current pragma. The message may contain
+ -- a % that will be replaced with the pragma name. The parameter Ref
+ -- must be an entity whose name can be referenced by & and sloc by #.
+ -- After placing the message, Pragma_Exit is raised.
+
function Find_Lib_Unit_Name return Entity_Id;
-- Used for a library unit pragma to find the entity to which the
-- library unit pragma applies, returns the entity found.
@@ -1700,6 +1707,18 @@ package body Sem_Prag is
raise Pragma_Exit;
end Error_Pragma_Arg_Ident;
+ ----------------------
+ -- Error_Pragma_Ref --
+ ----------------------
+
+ procedure Error_Pragma_Ref (Msg : String; Ref : Entity_Id) is
+ begin
+ Error_Msg_Name_1 := Pname;
+ Error_Msg_Sloc := Sloc (Ref);
+ Error_Msg_NE (Msg, N, Ref);
+ raise Pragma_Exit;
+ end Error_Pragma_Ref;
+
------------------------
-- Find_Lib_Unit_Name --
------------------------
@@ -2414,6 +2433,10 @@ package body Sem_Prag is
if Nkind (Parent (Declaration_Node (E))) =
N_Subprogram_Renaming_Declaration
then
+ if Scope (E) /= Scope (Alias (E)) then
+ Error_Pragma_Ref
+ ("cannot apply pragma% to non-local renaming&#", E);
+ end if;
E := Alias (E);
elsif Nkind (Parent (E)) = N_Full_Type_Declaration
@@ -2547,6 +2570,12 @@ package body Sem_Prag is
and then Nkind (Original_Node (Parent (E1))) /=
N_Full_Type_Declaration
then
+ if Present (Alias (E1))
+ and then Scope (E1) /= Scope (Alias (E1))
+ then
+ Error_Pragma_Ref
+ ("cannot apply pragma% to non-local renaming&#", E1);
+ end if;
Set_Convention_From_Pragma (E1);
if Prag_Id = Pragma_Import then