diff options
Diffstat (limited to 'gcc/ada/switch-c.adb')
-rw-r--r-- | gcc/ada/switch-c.adb | 177 |
1 files changed, 124 insertions, 53 deletions
diff --git a/gcc/ada/switch-c.adb b/gcc/ada/switch-c.adb index 2ac486bd30f..96416a5e546 100644 --- a/gcc/ada/switch-c.adb +++ b/gcc/ada/switch-c.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2013, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -147,6 +147,10 @@ package body Switch.C is First_Char : Positive; -- Marks start of switch to be stored + First_Ptr : Positive; + -- Save position of first character after -gnatd (for checking that + -- debug flags that must come first are first, in particular -gnatd.b), + begin Ptr := Switch_Chars'First; @@ -274,30 +278,31 @@ package body Switch.C is case C is + -- -gnata (assertions enabled) + when 'a' => Ptr := Ptr + 1; Assertions_Enabled := True; - Debug_Pragmas_Enabled := True; - -- Processing for A switch + -- -gnatA (disregard gnat.adc) when 'A' => Ptr := Ptr + 1; Config_File := False; - -- Processing for b switch + -- -gnatb (brief messages to stderr) when 'b' => Ptr := Ptr + 1; Brief_Output := True; - -- Processing for B switch + -- -gnatB (assume no invalid values) when 'B' => Ptr := Ptr + 1; Assume_No_Invalid_Values := True; - -- Processing for c switch + -- -gnatc (check syntax and semantics only) when 'c' => if not First_Switch then @@ -308,7 +313,7 @@ package body Switch.C is Ptr := Ptr + 1; Operating_Mode := Check_Semantics; - -- Processing for C switch + -- -gnatC (Generate CodePeer information) when 'C' => Ptr := Ptr + 1; @@ -326,11 +331,12 @@ package body Switch.C is Warning_Mode := Suppress; end if; - -- Processing for d switch + -- -gnatd (compiler debug options) when 'd' => Store_Switch := False; Dot := False; + First_Ptr := Ptr + 1; -- Note: for the debug switch, the remaining characters in this -- switch field must all be debug flags, since all valid switch @@ -347,9 +353,25 @@ package body Switch.C is C in 'a' .. 'z' or else C in 'A' .. 'Z' then + -- Case of dotted flag + if Dot then Set_Dotted_Debug_Flag (C); Store_Compilation_Switch ("-gnatd." & C); + + -- Special check, -gnatd.b must come first + + if C = 'b' + and then (Ptr /= First_Ptr + 1 + or else not First_Switch) + then + Osint.Fail + ("-gnatd.b must be first if combined " + & "with other switches"); + end if; + + -- Not a dotted flag + else Set_Debug_Flag (C); Store_Compilation_Switch ("-gnatd" & C); @@ -367,7 +389,7 @@ package body Switch.C is return; - -- Processing for D switch + -- -gnatD (debug expanded code) when 'D' => Ptr := Ptr + 1; @@ -403,6 +425,8 @@ package body Switch.C is -- -gnatea (initial delimiter of explicit switches) + -- This is an internal switch + -- All switches that come before -gnatea have been added by -- the GCC driver and are not stored in the ALI file. -- See also -gnatez below. @@ -562,6 +586,8 @@ package body Switch.C is -- -gnateO= (object path file) + -- This is an internal switch + when 'O' => Store_Switch := False; Ptr := Ptr + 1; @@ -570,7 +596,6 @@ package body Switch.C is if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then Bad_Switch ("-gnateO"); - else Object_Path_File_Name := new String'(Switch_Chars (Ptr + 1 .. Max)); @@ -621,12 +646,52 @@ package body Switch.C is Generate_SCO_Instance_Table := True; Ptr := Ptr + 1; - -- -gnatet (generate target dependent information) + -- -gnatet (write target dependent information) when 't' => - Generate_Target_Dependent_Info := True; + if not First_Switch then + Osint.Fail + ("-gnatet must not be combined with other switches"); + end if; + + -- Check for '=' + + Ptr := Ptr + 1; + + if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then + Bad_Switch ("-gnatet"); + else + Target_Dependent_Info_Write_Name := + new String'(Switch_Chars (Ptr + 1 .. Max)); + end if; + + return; + + -- -gnateT (read target dependent information) + + when 'T' => + if not First_Switch then + Osint.Fail + ("-gnateT must not be combined with other switches"); + end if; + + -- Check for '=' + Ptr := Ptr + 1; + if Ptr >= Max or else Switch_Chars (Ptr) /= '=' then + Bad_Switch ("-gnateT"); + else + -- This parameter was stored by Set_Targ earlier + + pragma Assert + (Target_Dependent_Info_Read_Name.all = + Switch_Chars (Ptr + 1 .. Max)); + null; + end if; + + return; + -- -gnateV (validity checks on parameters) when 'V' => @@ -641,6 +706,8 @@ package body Switch.C is -- -gnatez (final delimiter of explicit switches) + -- This is an internal switch + -- All switches that come after -gnatez have been added by -- the GCC driver and are not stored in the ALI file. See -- also -gnatea above. @@ -668,14 +735,14 @@ package body Switch.C is Ptr := Ptr + 1; All_Errors_Mode := True; - -- Processing for F switch + -- -gnatF (overflow of predefined float types) when 'F' => Ptr := Ptr + 1; External_Name_Exp_Casing := Uppercase; External_Name_Imp_Casing := Uppercase; - -- Processing for g switch + -- -gnatg (GNAT implementation mode) when 'g' => Ptr := Ptr + 1; @@ -683,6 +750,7 @@ package body Switch.C is Identifier_Character_Set := 'n'; System_Extend_Unit := Empty; Warning_Mode := Treat_As_Error; + Style_Check_Main := True; -- Set Ada 2012 mode explicitly. We don't want to rely on the -- implicit setting here, since for example, we want @@ -696,7 +764,7 @@ package body Switch.C is Set_GNAT_Mode_Warnings; Set_GNAT_Style_Check_Options; - -- Processing for G switch + -- -gnatG (output generated code) when 'G' => Ptr := Ptr + 1; @@ -709,13 +777,13 @@ package body Switch.C is Sprint_Line_Limit := Nat'Max (Sprint_Line_Limit, 40); end if; - -- Processing for h switch + -- -gnath (help information) when 'h' => Ptr := Ptr + 1; Usage_Requested := True; - -- Processing for i switch + -- -gnati (character set) when 'i' => if Ptr = Max then @@ -740,26 +808,26 @@ package body Switch.C is Bad_Switch ("-gnati" & Switch_Chars (Ptr .. Max)); end if; - -- Processing for I switch + -- -gnatI (ignore representation clauses) when 'I' => Ptr := Ptr + 1; Ignore_Rep_Clauses := True; - -- Processing for j switch + -- -gnatj (messages in limited length lines) when 'j' => Ptr := Ptr + 1; Scan_Nat (Switch_Chars, Max, Ptr, Error_Msg_Line_Length, C); - -- Processing for k switch + -- -gnatk (limit file name length) when 'k' => Ptr := Ptr + 1; Scan_Pos (Switch_Chars, Max, Ptr, Maximum_File_Name_Length, C); - -- Processing for l switch + -- -gnatl (output full source) when 'l' => Ptr := Ptr + 1; @@ -777,19 +845,19 @@ package body Switch.C is end if; end if; - -- Processing for L switch + -- -gnatL (corresponding source text) when 'L' => Ptr := Ptr + 1; Dump_Source_Text := True; - -- Processing for m switch + -- -gnatm (max number or errors/warnings) when 'm' => Ptr := Ptr + 1; Scan_Nat (Switch_Chars, Max, Ptr, Maximum_Messages, C); - -- Processing for n switch + -- -gnatn (enable pragma Inline) when 'n' => Ptr := Ptr + 1; @@ -806,14 +874,14 @@ package body Switch.C is end if; end if; - -- Processing for N switch + -- -gnatN (obsolescent) when 'N' => Ptr := Ptr + 1; Inline_Active := True; Front_End_Inlining := True; - -- Processing for o switch + -- -gnato (overflow checks) when 'o' => Ptr := Ptr + 1; @@ -852,14 +920,16 @@ package body Switch.C is end if; end if; - -- Processing for O switch + -- -gnatO (specify name of the object file) + + -- This is an internal switch when 'O' => Store_Switch := False; Ptr := Ptr + 1; Output_File_Name_Present := True; - -- Processing for p switch + -- -gnatp (suppress all checks) when 'p' => Ptr := Ptr + 1; @@ -890,32 +960,32 @@ package body Switch.C is Opt.Suppress_Checks := True; end if; - -- Processing for P switch + -- -gnatP (periodic poll) when 'P' => Ptr := Ptr + 1; Polling_Required := True; - -- Processing for q switch + -- -gnatq (don't quit) when 'q' => Ptr := Ptr + 1; Try_Semantics := True; - -- Processing for Q switch + -- -gnatQ (always write ALI file) when 'Q' => Ptr := Ptr + 1; Force_ALI_Tree_File := True; Try_Semantics := True; - -- Processing for r switch + -- -gnatr (restrictions as warnings) when 'r' => Ptr := Ptr + 1; Treat_Restrictions_As_Warnings := True; - -- Processing for R switch + -- -gnatR (list rep. info) when 'R' => Back_Annotate_Rep_Info := True; @@ -942,7 +1012,7 @@ package body Switch.C is Ptr := Ptr + 1; end loop; - -- Processing for s switch + -- -gnats (syntax check only) when 's' => if not First_Switch then @@ -953,44 +1023,44 @@ package body Switch.C is Ptr := Ptr + 1; Operating_Mode := Check_Syntax; - -- Processing for S switch + -- -gnatS (print package Standard) when 'S' => Print_Standard := True; Ptr := Ptr + 1; - -- Processing for t switch + -- -gnatt (output tree) when 't' => Ptr := Ptr + 1; Tree_Output := True; Back_Annotate_Rep_Info := True; - -- Processing for T switch + -- -gnatT (change start of internal table sizes) when 'T' => Ptr := Ptr + 1; Scan_Pos (Switch_Chars, Max, Ptr, Table_Factor, C); - -- Processing for u switch + -- -gnatu (list units for compilation) when 'u' => Ptr := Ptr + 1; List_Units := True; - -- Processing for U switch + -- -gnatU (unique tags) when 'U' => Ptr := Ptr + 1; Unique_Error_Tag := True; - -- Processing for v switch + -- -gnatv (verbose mode) when 'v' => Ptr := Ptr + 1; Verbose_Mode := True; - -- Processing for V switch + -- -gnatV (validity checks) when 'V' => Store_Switch := False; @@ -1020,7 +1090,7 @@ package body Switch.C is Ptr := Max + 1; - -- Processing for w switch + -- -gnatw (warning modes) when 'w' => Store_Switch := False; @@ -1060,7 +1130,7 @@ package body Switch.C is return; - -- Processing for W switch + -- -gnatW (wide character encoding method) when 'W' => Ptr := Ptr + 1; @@ -1085,13 +1155,13 @@ package body Switch.C is Ptr := Ptr + 1; - -- Processing for x switch + -- -gnatx (suppress cross-ref information) when 'x' => Ptr := Ptr + 1; Xref_Active := False; - -- Processing for X switch + -- -gnatX (language extensions) when 'X' => Ptr := Ptr + 1; @@ -1099,10 +1169,11 @@ package body Switch.C is Ada_Version := Ada_Version_Type'Last; Ada_Version_Explicit := Ada_Version_Type'Last; - -- Processing for y switch + -- -gnaty (style checks) when 'y' => Ptr := Ptr + 1; + Style_Check_Main := True; if Ptr > Max then Set_Default_Style_Check_Options; @@ -1145,7 +1216,7 @@ package body Switch.C is end; end if; - -- Processing for z switch + -- -gnatz (stub generation) when 'z' => @@ -1185,7 +1256,7 @@ package body Switch.C is Osint.Fail ("only one -gnatz* switch allowed"); end if; - -- Processing for Z switch + -- -gnatZ (obsolescent) when 'Z' => Ptr := Ptr + 1; @@ -1196,7 +1267,7 @@ package body Switch.C is -- version switch is added, Switch.M.Normalize_Compiler_Switches -- must be updated. - -- Processing for 83 switch + -- -gnat83 when '8' => if Ptr = Max then @@ -1213,7 +1284,7 @@ package body Switch.C is Ada_Version_Explicit := Ada_Version; end if; - -- Processing for 95 switch + -- -gnat95 when '9' => if Ptr = Max then @@ -1230,7 +1301,7 @@ package body Switch.C is Ada_Version_Explicit := Ada_Version; end if; - -- Processing for 05 switch + -- -gnat05 when '0' => if Ptr = Max then @@ -1247,7 +1318,7 @@ package body Switch.C is Ada_Version_Explicit := Ada_Version; end if; - -- Processing for 12 switch + -- -gnat12 when '1' => if Ptr = Max then @@ -1264,7 +1335,7 @@ package body Switch.C is Ada_Version_Explicit := Ada_Version; end if; - -- Processing for 2005 and 2012 switches + -- -gnat2005 and -gnat2012 when '2' => if Ptr > Max - 3 then |