This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch adds aa warning when a formal fixed point type is instantiated with a type that has a user-defined arithmetic operations, but the generic has no corresponding formal functions. This is worth a warning because of the special semantics of fixed-point operators, in particular multiplying operators. Compiling procfix.adb must yield: procfix.adb:23:28: warning: instance does not use primitive operation "*" at line 5 The warning disappears if a formal subprogram declaration is added to the generic: with function "*" (X, Y :Fix) return Fix is <>; --- with Text_IO; use Text_IO; procedure Procfix is package P is type T is delta 0.1 range -10.0 .. 10.0; function "*" (X, Y: T) return T; end P; use P; package body P is function "*" (X, Y: T) return T is begin return (X + Y) / 2.0; end; end P; generic type Fix is delta <>; package Try is X : Fix := 3.0; Y : Fix := X * X; end; package Inst is new Try (T); use Inst; begin Put_Line (T'Image (Inst.Y)); end; Tested on x86_64-pc-linux-gnu, committed on trunk 2016-07-06 Ed Schonberg <schonberg@adacore.com> * sem_ch12.adb (Check_Fixed_Point_Actual): Add a warning when a formal fixed point type is instantiated with a type that has a user-defined arithmetic operations, but the generic has no corresponding formal functions. This is worth a warning because of the special semantics of fixed-point operators.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |