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 mainline. An implicit inequality operator is created whenever there is user-defined equality operation, either inherited or explicit. The inequality is built only for semantic analysis, and eventually rewritten as the negation of the corresponding equality operation. Because of this transient nature, it is handled in an abbreviated matter, and its declaration is not visible to the back-end. Previous code simply set the Parent field of the operator declaration. This is incorrect when the operation is declared in a private part and overrides an inherited operation declared in the visible part of a package. Because the declaration was not properly part of a list of declarations, the predicate Is_Private_Operation could malfunction, either aborting when built with assertions, or returning an incorrect result. The new code ensures that Is_Private_Operation works properly. The following procedure must compile and execute quietly: with P; use P; with text_io; use text_io; procedure try is this, that: t; yes : boolean := this /= that; begin if not yes then put_line ("FAILED"); end if; end; package q is type t is null record; function "=" (this, that: t) return boolean; end; package body q is function "=" (this, that: t) return boolean is begin return False; end; end; with q; package p is type t is new q.t; private function "=" (this, that: t) return boolean; end; package body p is function "=" (this, that: t) return boolean is begin return True; end; this, that : t; end; 2005-03-08 Ed Schonberg <schonberg@adacore.com> * sem_ch6.adb (Is_Private_Declaration): Verify that the declaration is attached to a list before checking whether it appears in the private declarations of the current package. (Make_Inequality_Operator): Insert declaration in proper declarative list rather than just setting the Parent field, so that Is_Private_Declaration can handle it properly.
Attachment:
difs.27
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |