[Ada] Spurious run-time error with 64-bit modular types

Pierre-Marie de Rodat derodat@adacore.com
Wed Jul 10 09:04:00 GMT 2019


As a lexical element an integer literal has type Universal_Integer, i.e
is compatible with any integer type. This is semantically consistent and
simplifies type checking and subsequent constant folding when
applicable.  An exception is caused by 64-bit modular types, whose upper
bound is not representable in a non-static context that will use 64-bit
integers at run-time. For such cases we need to preserve the information
that the analyzed literal has that modular type. For simplicity we
preseve the information for all integer literals that result from a
modular operation.  This happens after prior analysis (or construction)
of the literal, and after type checking and resolution.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-07-10  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch2.adb (Analyze_Integer_Literal): Preserve the type of
	the literal if prior analysis determined that its type is a
	modular integer type.

gcc/testsuite/

	* gnat.dg/modular5.adb: New testcase.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 2571 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190710/7c27d6a7/attachment.bin>


More information about the Gcc-patches mailing list