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. In Ada 2005, the construct Obj.Proc (X, Y, Z) can denote a call to a primitive operation whose first parameter has the type of Obj. If the signature (s) of the possible interpretation(s)of Proc do not match the actuals, this must be diagnosed as an incorrect subprogram call, not as an attempt to retrieve a non-existent component of a record. If the user enables the Full_Error report, we must list all the possible candidates, and wherever possible provide an indication of where the signature failed to match. -- gcc -c -gnat05 q.adb gcc -c -gnat05 -gnatf q.adb -- output: -- q.adb:5:23: expected type "Standard.Boolean" q.adb:5:23: found type universal integer q.adb:5:17: expected type "Standard.Float" q.adb:5:17: found type "Standard.Boolean" q.adb:5:17: ==> in call to "Proc" at p.ads:3 q.adb:5:23: expected type "Standard.Boolean" q.adb:5:23: found type universal integer q.adb:5:23: ==> in call to "Proc" at p.ads:4 -- package P is type T is tagged null record; procedure Proc (It : T; X : Float; Y : Integer); procedure Proc (It : T; X : Boolean; Z : Boolean); end P; -- with P; use P; procedure Q is Object : T; begin Object.Proc (True, 15); end; Continuing work on AI-318. Move the check for "initialization not allowed for limited types" after analyzing the expression. This is necessary, because OK_For_Limited_Init looks at the structure of the expression. Before analysis, we don't necessarily know what sort of expression it is. For example, we don't know whether F(X) is a function call or an indexed component; the former is legal in Ada 2005; the latter is not. Several constructs are not allowed as expressions of type conversions: aggregates, allocators, null, and string literals. If the error occurs in a generic there is no need to perform the test anew in an instance. Furthermore, if the expression is a concatenation whose components are constant, it may be foldable in the generic, and be flagged incorrectly in the instance. This patch removes the check within an instance. See gnat.dg/type_conv.adb This patch also fixes two problems involving prefix notation for subprogram calls in Ada 2005. Even though the processing rewrites a selected component as a call, the name of the subprogram comes from source, and it must be marked as such so that it appears in cross-reference information. When checking whether a selected component can be interpreted as a primitive operation, we must take into account access parameters. The prefix may be a discriminated subtype of the type of the formal, in which case we must test whether the base type of the actual is the designated type of the formal. Finally, a selected component can denote a call to a class-wide operation if its first parameter has the class-wide type, or an access to it. The code did not check for the access case. See gnat.dg/class_wide.adb 2006-10-31 Ed Schonberg <schonberg@adacore.com> Javier Miranda <miranda@adacore.com> Robert Dewar <dewar@adacore.com> * sem_ch4.adb (Try_Primitive_Operation): Code cleanup to ensure that we generate the same errors compiling under -gnatc. (Try_Object_Operation): If no candidate interpretation succeeds, but there is at least one primitive operation with the right name, report error in call rather than on a malformed selected component. (Analyze_Selected_Component): If the prefix is an incomplete type from a limited view, and the full view is available, use the full view to determine whether this is a prefixed call to a primitive operation. (Operator_Check): Verify that a candidate interpretation is a binary operation before checking the type of its second formal. (Analyze_Call): Add additional warnings for function call contexts not yet supported. (Analyze_Allocator): Move the check for "initialization not allowed for limited types" after analyzing the expression. This is necessary, because OK_For_Limited_Init looks at the structure of the expression. Before analysis, we don't necessarily know what sort of expression it is. For example, we don't know whether F(X) is a function call or an indexed component; the former is legal in Ada 2005; the latter is not. (Analyze_Allocator): Correct code for AI-287 -- extension aggregates were missing. We also didn't handle qualified expressions. Now also allow function calls. Use new common routine OK_For_Limited_Init. (Analyze_Type_Conversion): Do not perform some legality checks in an instance, because the error message will be redundant or spurious. (Analyze_Overloaded_Selected_Component): Do not do style check when setting an entity, since we do not know it is the right entity yet. (Analyze_Selected_Component): Move Generate_Reference call to Sem_Res (Analyze_Overloaded_Selected_Component): Same change (Analyze_Selected_Component): Remove unnecessary prefix type retrieval since regular incomplete subtypes are transformed into corresponding subtypes of their full views. (Complete_Object_Operation): Treat name of transformed subprogram call as coming from source, for browsing purposes. (Try_Primitive_Operation): If formal is an access parameter, compare with base type of object to determine whether it is a primitive operation. (Operator_Check): If no interpretation of the operator matches, check whether a use clause on any candidate might make the operation legal. (Try_Class_Wide_Operation): Check whether the first parameter is an access type whose designated type is class-wide.
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] |