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] |
Tested on i686-linux, committed on trunk The warning for non-local exception propagating (warning that the last chance handler will be entered), which is generated by -gnatw.x if the restriction No_Exception_Propagation is in effect, is now off by default. It caused too many unexpected warnings if set on. So the following program: pragma Restrictions (No_Exception_Propagation); procedure z is function Ident (M : Integer) return integer is begin return M; end; subtype r is integer range 1 .. 10; rr : r; begin rr := Ident (11); end; Generates warnings for last chance handler being entered: 11. rr := Ident (11); | >>> warning: pragma Restrictions (No_Exception_Propagation) in effect, "Constraint_Error" may result in unhandled exception if -gnatwa or -gnatw.x is specified, but is quiet in default mode. -- This patch also adds a new switch -gnatI (with appropriate updates to usage and switch-c) to set a new flag in opt.ads, which, if set disables all rep clauses, treating them as comments. This is useful in initial stages of porting code (where you want to ignore rep clause problems initially), and when compiling foreign code for use with ASIS where you are not interested in rep clauses. See gnat.dg/specs/gnati.ads -- Now, consider this program: procedure a is type r is array (0 .. 7) of Boolean; for r'size use 8; begin null; end; This is illegal because the default layout of r uses 8 bits per element, so a size of 64 is required. If the array is explicitly packed then everything is OK. Some Ada 83 compilers caused implicit packing in this situation, and the failure of GNAT to do this causes problems porting legacy software. However, the failure is quite deliberate, since, for good reasons (having to do with avoiding expensive implicit conversions if a size clause is given after a type deriviation), the RM specifically recommends that Size clauses not be allowed to change the internal layout of a composite type (RM 13.3(53)). So if you compile the above, you get: 1. procedure a is 2. type r is array (0 .. 7) of Boolean; 3. for r'size use 8; | >>> size given for "r" too small >>> explicit pragma Pack is required 4. begin 5. null; 6. end; To help with porting legacy code, this patch introduces a configuration pragma Implicit_Packing which allows a Size clause to cause implicit packing. Adding this pragma, we can compile the above program: 1. pragma Implicit_Packing; 2. procedure a is 3. type r is array (0 .. 7) of Boolean; 4. for r'size use 8; 5. begin 6. null; 7. end; with no errors. The original program without the pragma now generates: 1. procedure a is 2. type r is array (0 .. 7) of Boolean; 3. for r'size use 8; | >>> size given for "r" too small >>> use explicit pragma Pack or use pragma Implicit_Packing 4. begin 5. null; 6. end; -- This patch also enables a warning (under control of -gnatwz) for the case of unchecked conversion of pointers of different conventions: 1. with Unchecked_Conversion; 2. package p is 3. type X is access all Integer; 4. pragma Convention (Ada, X); 5. 6. type Y is access all Integer; 7. pragma Convention (C, Y); 8. 9. function UX is new Unchecked_Conversion (X, Y); | >>> warning: conversion between pointers with different conventions 10. function UY is new Unchecked_Conversion (Y, X); | >>> warning: conversion between pointers with different conventions 11. end p; Finally, this patch improves error messages displayed when a compiler switch is not recognized. For example, if switch -gnate is used, the error message is now: invalid switch: -gnate instead of invalid switch: e 2007-08-14 Robert Dewar <dewar@adacore.com> Ed Schonberg <schonberg@adacore.com> * opt.ads: Warning for non-local exception propagation now off by default New switch -gnatI to disable representation clauses Implement new pragma Implicit_Packing * usage.adb: Warning for non-local exception propagation now off by default Add warning for unchecked conversion of pointers wi different conventions. New switch -gnatI to disable representation clauses * usage.adb: new switch -gnatyS * gnat_ugn.texi: For the gnatcheck Non_Qualified_Aggregates rule add a note that aggregates of anonymous array types are not flagged. -gnatwc now includes membership tests optimized away -gnatw.x warnings are now off by default Added conditional compilation Appendix Add documentation of -gnatI Add documentation for new -gnatyS style check Update documentation about SAL and auto-init on Windows. * gnat_rm.texi: Add documentation for pragma Check_Name and 'Enabled attribute Document that Eliminate on dispatching operation is ignored Document IDE attributes VCS_Repository_Root and VCS_Patch_Root. Document pragma Main Document pragma Implicit_Packing * sem_ch13.adb: Add warning for unchecked conversion of pointers wi different conventions New switch -gnatI to disable representation clauses * switch-c.adb (Scan_Front_End_Switches): When a -gnat switch is not recognized, report the invalid characters including "-gnat" instead of just the first character in the switch. New switch -gnatI to disable representation clauses Set Warn_On_Object_Renames_Function true for -gnatg * vms_data.ads: Add doc for /IGNORE_REP_CLAUSES Add STATEMENTS_AFTER_THEN_ELSE as synonym for -gnatyS Add qualifier /ADD_PROJECT_SEARCH_DIR= for different tools, equivalent to switch -aP (add directory to project search dir). * par-prag.adb: Implement new pragma Implicit_Packing * sem_prag.adb (Analyze_Pragma, case Complex_Representation): Mark the type as having a non-standard representation, to force expansion on conversion to related types. (Analyze_Pragma): Warn on misspelled pragma (Analyze_Pragma, case Convention_Identifier): Fix checking of second arg Ensure consistent use of # in error messages Implement pragma Implicit_Packing
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] |