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] Fix missed cases for No_Wide_Characters restriction


This patch fixes a number of missed checks for the No_Wide_Characters
restriction. The following comprehensive test case now gets properly
flagged on every expected line:


Compiling: no_wide_characters.adb

     1. pragma Restrictions (No_Wide_Characters);
     2. procedure No_Wide_Characters is
     3.    W_Char_1   : Wide_Character := 'a';             --  FLAG
                        |
        >>> violation of restriction "No_Wide_Characters" at line 1

     4.    W_String_1 : Wide_String := "a";                --  FLAG
                        |
        >>> violation of restriction "No_Wide_Characters" at line 1

     5.
     6.    subtype My_Wide_Character is Wide_Character;    --  FLAG
                                        |
        >>> violation of restriction "No_Wide_Characters" at line 1

     7.    subtype My_Wide_String is Wide_String (1 .. 5); --  FLAG
                                     |
        >>> violation of restriction "No_Wide_Characters" at line 1

     8.
     9.    W_Char_2   : My_Wide_Character := 'a';          --  FLAG
                        |
        >>> violation of restriction "No_Wide_Characters" at line 1

    10.    W_String_2 : My_Wide_String := "12345";         --  FLAG
                        |
        >>> violation of restriction "No_Wide_Characters" at line 1

    11.
    12.    type My_Array_1
    13.      is array (Wide_Character'First ..             --  FLAG
                       |
        >>> violation of restriction "No_Wide_Characters" at line 1

    14.                Wide_Character'Last) of Integer;    --  FLAG
                       |
        >>> violation of restriction "No_Wide_Characters" at line 1

    15.
    16.    procedure Proc
    17.      (W_Ch  : Standard.Wide_Character;             --  FLAG
                              |
        >>> violation of restriction "No_Wide_Characters" at line 1

    18.       W_Str : Wide_String)                         --  FLAG
                      |
        >>> violation of restriction "No_Wide_Characters" at line 1

    19.    is
    20.    begin
    21.       null;
    22.    end;
    23.
    24.    function Fun_W_Ch
    25.      (Ch   : Character)
    26.       return Standard.Wide_Character               --  FLAG
                             |
        >>> violation of restriction "No_Wide_Characters" at line 1

    27.    is
    28.    begin
    29.       return '["1234"]';                           --  FLAG
                     |
        >>> violation of restriction "No_Wide_Characters" at line 1

    30.    end;
    31.
    32.    function Fun_W_Str
    33.      (Str  : String)
    34.       return Wide_String                           --  FLAG
                     |
        >>> violation of restriction "No_Wide_Characters" at line 1

    35.    is
    36.    begin
    37.       return "["1234"]";                           --  FLAG
                     |
        >>> violation of restriction "No_Wide_Characters" at line 1

    38.    end;
    39.
    40.    type R is ('a', '["1234"]');                    --  FLAG
                           |
        >>> violation of restriction "No_Wide_Characters" at line 1

    41.
    42. begin
    43.       null;
    44. end No_Wide_Characters;

 44 lines: 15 errors

As a side effect the list of possible restrictions now accurately
includes No_Wide_Characters if and only if this is correct.

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

2010-09-09  Robert Dewar  <dewar@adacore.com>

	* restrict.ads, restrict.adb (Check_Wide_Character_Restriction): New
	procedure.
	* sem_ch3.adb: Use Check_Wide_Character_Restriction
	(Enumeration_Type_Declaration): Check violation of No_Wide_Characters
	* sem_ch8.adb (Find_Direct_Name): Check violation of No_Wide_Characters
	(Find_Expanded_Name): Check violation of No_Wide_Characters

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]