diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-01-11 08:52:51 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-01-11 08:52:51 +0000 |
commit | 07733aa11e136aa6e1fa24e12e662489a9225bf2 (patch) | |
tree | bef2bd4163e1a57b20b9fa51114a96eb89d0ac2a /gcc/ada | |
parent | 78cac7386e2dc48ec5adb4ff0c9a94eed958c9fc (diff) | |
download | gcc-07733aa11e136aa6e1fa24e12e662489a9225bf2.zip gcc-07733aa11e136aa6e1fa24e12e662489a9225bf2.tar.gz gcc-07733aa11e136aa6e1fa24e12e662489a9225bf2.tar.bz2 |
[Ada] Warning on use of predefined operations on an actual fixed-point type
The compiler warns when a generic actual is a fixed-point type, because
arithmetic operations in the instance will use the predefined operations on
it, even if the type has user-defined primitive operations (unless formsl
surprograms for these operations appear in the generic). This patch refines
this warning to exclude the case where the formsal type is private, because
in this case there can be no suspicious arithmetic operastions in the generic
unit.
2018-01-11 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch12.adb (Check_Fixed_Point_Type): Do not apply check if the
formsl type corresponding to the actual fixed point type is private,
because in this case there can be no suspicious arithmetic operations
in the generic unless they reference a formal subprogram. Clarify
warning.
gcc/testsuite/
* gnat.dg/fixedpnt2.adb, gnat.dg/fixedpnt2.ads: New testcase.
From-SVN: r256504
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/sem_ch12.adb | 14 |
2 files changed, 20 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0123986..ec9eeaa 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2018-01-11 Ed Schonberg <schonberg@adacore.com> + + * sem_ch12.adb (Check_Fixed_Point_Type): Do not apply check if the + formsl type corresponding to the actual fixed point type is private, + because in this case there can be no suspicious arithmetic operations + in the generic unless they reference a formal subprogram. Clarify + warning. + 2018-01-11 Javier Miranda <miranda@adacore.com> * exp_util.adb (Remove_Side_Effects): No action done for functions diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 0cfb411..b2f4db1 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -1279,7 +1279,8 @@ package body Sem_Ch12 is if No (Formal) then Error_Msg_Sloc := Sloc (Node (Elem)); Error_Msg_NE - ("?instance does not use primitive operation&#", + ("?instance uses predefined operation, " + & "not primitive operation&#", Actual, Node (Elem)); end if; end if; @@ -1717,7 +1718,16 @@ package body Sem_Ch12 is (Formal, Match, Analyzed_Formal, Assoc_List), Assoc_List); - if Is_Fixed_Point_Type (Entity (Match)) then + -- Warn when an actual is a fixed-point with user- + -- defined promitives. The warning is superfluous + -- if the fornal is private, because there can be + -- no arithmetic operations in the generic so there + -- no danger of confusion. + + if Is_Fixed_Point_Type (Entity (Match)) + and then not Is_Private_Type + (Defining_Identifier (Analyzed_Formal)) + then Check_Fixed_Point_Actual (Match); end if; |