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 implements dimension analysis for array, extension and record aggregates, and also for calls. Moreover, the compiler warns whenever a numeric literal is used as a default value of a dimensioned subtype object (object declaration, component declaration and formal parameter). The test presented below illustrates some of the new additions, in particular the dimension anlysis of aggregates. ------------ -- Source -- ------------ with Ada.Text_IO; use Ada.Text_IO; with System.Dim.Mks; use System.Dim.Mks; with System.Dim.Mks_IO; use System.Dim.Mks_IO; procedure Main is subtype Axis is Integer range 1 .. 3; type Position is array (Axis) of Length; type Particle is record Q: Mass := 0.0; R: Position := (Axis => 0.0 * m); end record; P : Particle := (Q => 1.0 * g, R => (Axis => 0.0 * m)); begin Put (P.Q, Aft => 2, Exp => 0); New_Line; for C of P.R loop Put (C, Aft => 2, Exp => 0); New_Line; end loop; end Main; ----------------------------- -- Compilation & Execution -- ----------------------------- $ gnatmake -q -gnat12 main.adb $ ./main main.adb:10:21: warning: assumed to be "0.0 kg" 0.00 kg 0.00 m 0.00 m 0.00 m Tested on x86_64-pc-linux-gnu, committed on trunk 2012-10-01 Vincent Pucci <pucci@adacore.com> * exp_ch6.adb (Expand_Call): Remove call to Remove_Dimension_In_Call. * sem_aggr.adb (Resolve_Array_Aggregate): Analyze dimension of components in array aggregate. (Resolve_Aggr_Expr): Propagate dimensions from the original expression Expr to the new created expression New_Expr when resolving the expression of a component in record aggregates. (Resolve_Record_Aggregate): Analyze dimension of components in record (or extension) aggregate. * sem_ch6.adb (Analyze_Subprogram_Specification): Analyze dimension of formals with default expressions in subprogram specification. * sem_ch8.adb (Analyze_Expanded_Name): Analyze dimension of expanded names. (Find_Selected_Component): Analyze dimension of selected component. * sem_dim.adb: Several dimension error messages reformatting. (Dimensions_Msg_Of): New flag Description_Needed in order to differentiate two different sort of dimension error messages. (Dim_Warning_For_Numeric_Literal): New routine. (Exists): New routine. (Move_Dimensions): Routine spec moved to spec file. * sem_dim.ads (String_From_Numeric_Literal): New routine. (Analyze_Dimension): Analyze dimension only when the node comes from source. Dimension analysis for expanded names added. (Analyze_Dimension_Array_Aggregate): New routine. (Analyze_Dimension_Call): New routine. (Analyze_Dimension_Component_Declaration): Warning if default expression is a numeric literal. (Analyze_Dimension_Extension_Or_Record_Aggregate): New routine. (Analyze_Dimension_Formals): New routine. (Analyze_Dimension_Object_Declaration): Warning if default expression is a numeric literal. (Symbol_Of): Return either the dimension subtype symbol or the dimension symbol built by From_Dim_To_Str_Of_Unit_Symbols. * sem_dim.ads (Analyze_Dimension_Array_Aggregate): New routine. (Analyze_Dimension_Call): New routine. (Analyze_Dimension_Extension_Or_Record_Aggregate): New routine. (Analyze_Dimension_Formals): New routine. (Move_Dimensions): Moved from sem_dim.adb. * s-dimmks.ads: Turn off the warnings for dimensioned object declaration. Dimensioned subtypes sorted in alphabetical order. New subtypes Area, Speed, Volume. * s-dmotpr.ads: Turn off the warnings for dimensioned object declaration. * sem_res.adb (Resolve_Call): Analyze dimension for calls.
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] |