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
Ada 2005 introduces several new operations in predefined packages.
These operations should not be visible when compiling in Ada 95 mode.
The following must compile quietly:
gcc -c -gnat95 -gnatws main.adb
--
package P is
function Get_Line return String;
end P;
--
with P; use P;
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
X: constant String := Get_Line;
begin
null;
end Main;
In Ada 2005, an abstract operation does not participate in overloading
resolution, and is removed from the list of interpretations during the
first pass of resolution. However, if the operands are universal, the
universal interpretation must be preserved until the second pass. If
the node is still ambiguous and the context is not universal, it may be
due to the now incorrect presence of a numeric interpretation, which has
to be removed to resolve the ambiguity.
The following must compile quietly:
gcc -c -gnat05 amb.adb
--
procedure Amb is
type whole is new integer;
function "/" (Left, Right: Whole) return Whole is abstract; -- 1
function "+" ( Right: Whole) return Whole is abstract; -- 2
--
type Rational is record
Numerator : Whole;
Denominator: Whole;
end record;
--
function "+" ( Right: Whole ) return Rational is
begin
return (Right, 1);
end;
function "/" (Left, Right: Whole ) return Rational is
begin
return (Left, Right);
end;
function "+" ( Right: Rational) return Rational is
begin
return Right;
end;
--
R: Rational := +1/2; -- ambiguous in Ada 95, OK in Ada 2005
begin
R := (1/3) + (3/4);
end Amb;
2005-12-05 Ed Schonberg <schonberg@adacore.com>
* sem_ch4.adb (Remove_Abstract_Operations): Do not apply preference
rule prematurely when operands are universal, remaining ambiguities
will be removed during resolution.
Code cleanup.
* sem_type.adb (Disambiguate): In Ada95 mode, discard interpretations
that are Ada 2005 functions.
(Has_Abstract_Interpretation): Subsidiary to
Remove_Conversions, to remove ambiguities caused by abstract operations
on numeric types when operands are universal.
Attachment:
difs.22
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |