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]

[Ada] Improve error msgs for Ada 2012 feature not in Ada 2012 mode


Previously if an Ada 2012 feature was used in an earlier Ada mode, the
error message always advised the use of the -gnat2012 switch. But that
is not helpful if the mode was set by an explicit use of pragma Ada_xx.
This patch improves the error message in this case by pointing to the
relevant pragma.

     1. pragma Ada_2005;
     2. package Pr0512 is
     3.    x : integer := (if true then 1 else 2);
                           |
        >>> if expression is an Ada 2012 feature
        >>> incompatible with Ada version set at line 1

     4. end Pr0512;

The following is compiled with pragma Ada_95 in gnat.adc

     1. package Pr0512a is
     2.    x : integer := (if true then 1 else 2);
                           |
        >>> if expression is an Ada 2012 feature
        >>> incompatible with Ada version set at gnat.adc:1

     3. end Pr0512a;

If this same program is compiled without a gnat.adc file,
but using the switch -gnat2005, we get:

     1. package Pr0512a is
     2.    x : integer := (if true then 1 else 2);
                           |
        >>> if expression is an Ada 2012 feature
        >>> unit must be compiled with -gnat2012 switch

     3. end Pr0512a;

Tested on x86_64-pc-linux-gnu, committed on trunk

2013-09-10  Robert Dewar  <dewar@adacore.com>

	* errout.adb (Error_Msg_Ada_2012_Feature): New procedure.
	* errout.ads (Error_Msg_Ada_2012_Feature): New procedure.
	* inline.ads: Save/Restore Ada_Version_Pragma.
	* opt.adb: Save/Restore Ada_Version_Pragma.
	* opt.ads (Ada_Version_Pragma): New variable.
	* par-ch11.adb, par-ch12.adb, par-ch13.adb, par-ch4.adb, par-ch5.adb,
	par-ch6.adb, par-ch8.adb, par-prag.adb: Use Error_Msg_Ada_2012_Feature.
	* prj.adb: Initialize Ada_Version_Pragma.
	* sem_attr.adb: Use Error_Msg_Ada_2012_Feature.
	* sem_ch12.adb, sem_ch8.adb: Save/restore Ada_Version_Pragma.
	* sem_prag.adb (Analyze_Pragma, cases Ada_xx): Set Ada_Version_Pragma.
	* switch-c.adb: Initialize Ada_Version_Pragma.
	* sem_ch12.adb: Minor reformatting.

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]