+2019-07-09 Ed Schonberg <schonberg@adacore.com>
+
+ * sem_ch4.adb (Diagnose_Call): Improve error recovery when a
+ local subprogram name hides a possible candidate name declared
+ in a child package in the context of the current unit.
+ * sem_ch6.adb (Process_Formals): Protect against malformed
+ formal types when the parameter type does not denote an entity.
+
2019-07-09 Hristian Kirtchev <kirtchev@adacore.com>
* bindo-augmentors.adb (Visit_Elaboration_Root): Do not start a
if Nkind (N) = N_Function_Call then
Get_First_Interp (Nam, X, It);
- while Present (It.Nam) loop
- if Ekind_In (It.Nam, E_Function, E_Operator) then
- return;
- else
- Get_Next_Interp (X, It);
- end if;
- end loop;
- -- If all interpretations are procedures, this deserves a
- -- more precise message. Ditto if this appears as the prefix
- -- of a selected component, which may be a lexical error.
+ if No (It.Typ)
+ and then Ekind (Entity (Name (N))) = E_Function
+ and then Present (Homonym (Entity (Name (N))))
+ then
- Error_Msg_N
- ("\context requires function call, found procedure name", Nam);
+ -- A name may appear overloaded if it has a homonym, even if
+ -- that homonym is non-overloadable, in which case the overload
+ -- list is in fact empty. This specialized case deserves a
+ -- special message if the homonym is a child package.
- if Nkind (Parent (N)) = N_Selected_Component
- and then N = Prefix (Parent (N))
- then
- Error_Msg_N -- CODEFIX
- ("\period should probably be semicolon", Parent (N));
+ declare
+ Nam : constant Node_Id := Name (N);
+ H : constant Entity_Id := Homonym (Entity (Nam));
+
+ begin
+ if Ekind (H) = E_Package
+ and then Is_Child_Unit (H)
+ then
+ Error_Msg_Qual_Level := 2;
+ Error_Msg_NE ("if an entity in package& is meant, ", Nam, H);
+ Error_Msg_NE ("\use a fully qualified name", Nam, H);
+ Error_Msg_Qual_Level := 0;
+ end if;
+ end;
+
+ else
+ while Present (It.Nam) loop
+ if Ekind_In (It.Nam, E_Function, E_Operator) then
+ return;
+ else
+ Get_Next_Interp (X, It);
+ end if;
+ end loop;
+
+ -- If all interpretations are procedures, this deserves a
+ -- more precise message. Ditto if this appears as the prefix
+ -- of a selected component, which may be a lexical error.
+
+ Error_Msg_N
+ ("\context requires function call, found procedure name", Nam);
+
+ if Nkind (Parent (N)) = N_Selected_Component
+ and then N = Prefix (Parent (N))
+ then
+ Error_Msg_N -- CODEFIX
+ ("\period should probably be semicolon", Parent (N));
+ end if;
end if;
elsif Nkind (N) = N_Procedure_Call_Statement