[Ada] Spurious errors on aspect specifications in generic units
authorEd Schonberg <schonberg@adacore.com>
Tue, 11 Dec 2018 11:09:19 +0000 (11:09 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 11 Dec 2018 11:09:19 +0000 (11:09 +0000)
commit5f531feff7ed6651354ed5b1cbd2a83cf204d170
tree516bc968672662fd2a9636ff4234661f1e7aaefd
parent15bdffc4963b842cf104a0075921965a3cee272b
[Ada] Spurious errors on aspect specifications in generic units

This patch fixes spurious errors on aspect specifications on record
types when the aspect expression references a component of the type that
is not a discriminant. The patch also cleans up the legality checks on
aspect specifications, and improves error message on illegal aspect
specifications whose expressions are not conformant between
specification and freeze point, because of changes in visibility.

2018-12-11  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* sem_ch13.adb (Push_Type, Pop_Type): New procedures, used for
analysis of aspect expressions for record types, whose
components (not only discriminants) may be referenced in aspect
expressions.
(Analyze_Aspect_Specifications, Analyze_Aspects_At_Freeze_Point,
Analyze_Aspect_At_End-Of_Declarations,
Resolve_Aspect_Expressions): Use the new subprograms.
(Check_Aspect_At_End_Of_Declarations): Improve error message.
(Build_Predicate_Functions): Do not build their bodies in a
generic unit.
(Is_Derived_Type_With_Constraint): New subprogram to uncover and
reject aspect specificationss on types that appear after the
type is frozen.
* sem_ch13.ads (Push_Scope_And_Install_Discriminants,
Uninstall_Discriminants_And_Pop_Scope): Remove.
* sem_ch6.adb, sem_ch6.ads (Fully_Conformant_Expressions):
Additional parameter to improve error message on illegal aspect
specifications whose resolution differ between aspect
specification and freeze point.
* freeze.adb: Remove references to
Install/Uninstall_Discriminants.

gcc/testsuite/

* gnat.dg/aspect1.adb, gnat.dg/aspect1_horizontal.adb,
gnat.dg/aspect1_horizontal.ads, gnat.dg/aspect1_vectors_2d.ads:
New testcase.
* gnat.dg/static_pred1.adb: Expect an error message.

From-SVN: r266980
12 files changed:
gcc/ada/ChangeLog
gcc/ada/freeze.adb
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch13.ads
gcc/ada/sem_ch6.adb
gcc/ada/sem_ch6.ads
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/aspect1.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/aspect1_horizontal.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/aspect1_horizontal.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/aspect1_vectors_2d.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/static_pred1.adb