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] |
A common programming error is to assume that a predefined operator is visible when its operand type is in scope. The compiler in that case indicates that a use clause would make the operation legal. However, the type maybe only in scope indirectly, through other visible units, in which case the error message is incomplete, because a use_clause will not be sufficient to make the operator visible. THis patch recognizes this case, and specializes the error message accordingly. Compiling user.adb below must yield: user.adb:5:11: operator for type "E" defined at typ.ads:2 is not directly visible user.adb:5:11: add with_clause and use_clause for "Typ" --- with Cst; use Cst; procedure User is begin if Get = C then null; end if; end; --- package Typ is type E is range 0 .. 10; end; --- with Typ; use Typ; package Cst is C : constant E := 0; function Get return E; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Ed Schonberg <schonberg@adacore.com> * sem_ch4.adb (Operator_Check): improve error message when both a with_clause and a use_clause are needed to make operator usage legal. * sem_util.ads, sem_util.adb (Unit_Is_Visible): new predicate to determine whether a compilation unit is visible within an other, either through a with_clause in the current unit, or a with_clause in its library unit or one one of its parents.
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] |