Go to file
Gary Dismukes bbab2db3a6 [Ada] Implement static expression functions for Ada 202x (AI12-0075)
2020-06-17  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

	* aspects.ads (type Aspect_Id): Add Aspect_Static as a Boolean
	aspect, and update the Is_Representation_Aspect, Aspect_Names,
	and Aspect_Delay arrays.
	* exp_ch6.adb (Expand_Simple_Function_Return): In the case of a
	return for a static expression function, capture a copy of the
	expression of the return statement before it's expanded and
	reset its Analyzed flags. Then, just before leaving this
	procedure, if the expression was rewritten, set the
	Original_Node of the rewritten expression to the new copy and
	also set the Expression of the associated static expression
	function to designate that copy. This ensures that later copies
	of the expression made via New_Copy_Tree will fully copy all
	nodes of the expression tree.
	* inline.ads (Inline_Static_Expression_Function_Call): New
	procedure to evaluate and produce the result of a static call to
	a static expression function.
	* inline.adb: Add with and use for Sem_Res.
	(Establish_Actual_Mapping_For_Inlined_Call): New procedure
	extracted from code in Expand_Inlined_Call that traverses the
	actuals and formals of an inlined call and in some cases creates
	temporaries for holding the actuals, plus establishes an
	association between formals and actuals (via the Renamed_Object
	fields of the formals).
	(Formal_Is_Used_Once): Function removed from Expand_Inlined_Call
	and now nested in the above procedure.
	(Expand_Inlined_Call): Code for doing the formal/actual
	traversal is moved to Create_Actual_Temporaries and replaced
	with a call to that new procedure.
	(Inline_Static_Expression_Function_Call): New procedure to
	evaluate a static call to a static expression function,
	substituting actuals for their corresponding formals and
	producing a fully folded and static result expression. The
	function has subsidiary functions Replace_Formal and Reset_Sloc
	that take care of doing the mapping of formals to actuals and
	resetting the Slocs of subnodes of the mapped expression to that
	of the call so errors will be flagged on the call rather than
	function.
	* sem_ch6.adb (Analyze_Expression_Function): In the case of a
	static expression function, perform an additional preanalysis of
	the function's expression to ensure that it's a potentially
	static expression (according to the requirements of
	6.8(3.2/5-3.4/5)), and issue an error if it's not. The global
	flag Checking_Potentially_Static_Expression is set and unset
	around this checking.
	* sem_ch13.adb (Analyze_Aspect_Static): New procedure to enforce
	selected requirements of the new aspect Static on expression
	functions, including checking that the language version is
	Ada_2020 and that the entity to which it applies is an
	expression function whose formal parameters are of a static
	subtype and have mode 'in', its result subtype is a static
	subtype, and it has no pre- or postcondition aspects. A ???
	comment is added to indicate the need for adding checking that
	type invariants don't apply to the result type if the function
	is a boundary entity.
	(Analyze_One_Aspect): Call Analyze_Aspect_Static for aspect
	Static.
	* sem_elab.adb (Build_Call_Marker): Return without creating a
	call marker when the subprogram is a static expression function,
	since no ABE checking is needed for such functions.
	* sem_eval.ads (Checking_Potentially_Static_Expression): New
	function to return whether the checking for potentially static
	expressions is enabled.
	(Set_Checking_Potentially_Static_Expression): New procedure to
	enable or disable checking of potentially static expressions.
	* sem_eval.adb (Checking_For_Potentially_Static_Expression): New
	global flag for determining whether preanalysis of potentially
	static expression is being done, which affects the behavior of
	certain static evaluation routines.
	(Checking_Potentially_Static_Expression): New function to return
	whether the checking for potentially static expressions is
	enabled.
	(Eval_Call): When evaluating a call within a static expression
	function with checking of potentially static expression
	functions enabled, substitutes a static value in place of the
	call to allow folding of the expression.
	(Eval_Entity_Name): When evaluating a formal parameter of a
	static expression function with checking of potentially static
	expression functions enabled, substitutes a static value in
	place of the reference to the formal to allow folding of the
	expression.
	(Set_Checking_Potentially_Static_Expression): New procedure to
	enable or disable checking of potentially static expressions.
	* sem_res.adb (Resolve_Call): Test for a recursive call
	occurring within a static expression function and issue an error
	for such a call. Prevent the establishment of a transient scope
	in the case this is a call to a (string-returning) static
	expression function. When calling a static expression function,
	if no error has been posted on the function, call
	Inline_Static_Expression_Function_Call to convert the call into
	its equivalent static value.
	* sem_util.ads (Is_Static_Expression_Function): New function
	returning whether the subprogram entity passed to it is a static
	expression function.
	(Is_Static_Expression_Function_Call): New function to determine
	whether the call node passed to it is a static call to a static
	expression function.
	* sem_util.adb (Compile_Time_Constraint_Error): Suppress
	compile-time Constraint_Error reporting when checking for a
	potentially static expression.
	(Is_Static_Expression_Function): New function returning whether
	the subprogram entity passed to it is a static expression
	function by testing for the presence of aspect Static.
	(Has_All_Static_Actuals): New function in
	Is_Static_Expression_Function_Call that traverses the actual
	parameters of a function call and returns True only when all of
	the actuals are given by static expressions. In the case of a
	string-returning function, we call Resolve on each actual to
	ensure that their Is_Static_Expression flag properly reflects
	whether they're static, to allow suppressing creation of a
	transient scope within Resolve_Call. A prominent ??? comment is
	added to explain this rather unconventional call to Resolve.
	(Is_Static_Expression_Function_Call): New function that
	determines whether a node passed to it is a call to a static
	expression function all of whose actual parameters are given by
	static expressions.
2020-06-17 04:14:06 -04:00
config
contrib Daily bump. 2020-06-12 00:16:29 +00:00
fixincludes
gcc [Ada] Implement static expression functions for Ada 202x (AI12-0075) 2020-06-17 04:14:06 -04:00
gnattools
gotools
include
INSTALL
intl
libada
libatomic
libbacktrace
libcc1
libcpp
libdecnumber
libffi
libgcc gcov: fix gcov-tool merge for TOPN counters 2020-06-17 08:32:27 +02:00
libgfortran Daily bump. 2020-06-14 00:16:18 +00:00
libgo libgo: update x/sys/cpu to add all GOARCHes supported by gccgo 2020-06-15 14:20:07 -07:00
libgomp Daily bump. 2020-06-17 00:16:36 +00:00
libhsail-rt
libiberty
libitm
libobjc
liboffloadmic
libphobos
libquadmath
libsanitizer Daily bump. 2020-06-10 00:16:47 +00:00
libssp
libstdc++-v3 Daily bump. 2020-06-17 00:16:36 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore Add .clang-tidy to git ignored. 2020-06-12 16:03:02 +02:00
ABOUT-NLS
ar-lib
ChangeLog Daily bump. 2020-06-13 00:16:25 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure bootstrap: Fix --disable-bootstrap with older g++. 2020-06-08 16:42:35 -04:00
configure.ac bootstrap: Fix --disable-bootstrap with older g++. 2020-06-08 16:42:35 -04:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS: Add myself as xtensa port maintainer 2020-06-06 01:26:56 -07:00
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.