| 1 |
-- { dg-do compile } |
| 2 |
-- { dg-options "-O -gnatn -fdump-tree-optimized" } |
| 3 |
|
| 4 |
package body Opt103 is |
| 5 |
|
| 6 |
function Read return Mode is |
| 7 |
S : String := Get; |
| 8 |
M : Mode; |
| 9 |
|
| 10 |
begin |
| 11 |
-- There should be a single call to Value_Enumeration_Pos after inlining |
| 12 |
|
| 13 |
if Mode'Valid_Value (S) then |
| 14 |
M := Mode'Value (S); |
| 15 |
else |
| 16 |
raise Program_Error; |
| 17 |
end if; |
| 18 |
|
| 19 |
return M; |
| 20 |
end; |
| 21 |
|
| 22 |
function Translate (S : String) return Mode is |
| 23 |
M : Mode; |
| 24 |
|
| 25 |
begin |
| 26 |
-- There should be a single call to Value_Enumeration_Pos after inlining |
| 27 |
|
| 28 |
if Mode'Valid_Value (S) then |
| 29 |
M := Mode'Value (S); |
| 30 |
else |
| 31 |
raise Program_Error; |
| 32 |
end if; |
| 33 |
|
| 34 |
return M; |
| 35 |
end; |
| 36 |
|
| 37 |
end Opt103; |
| 38 |
|
| 39 |
-- { dg-final { scan-tree-dump-times ".value_enumeration_pos" 2 "optimized" } } |