public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/38975] New: deferred constants of not null access types are not possible
@ 2009-01-26 12:28 Artem dot Andreev at oktetlabs dot ru
2009-10-03 10:11 ` [Bug ada/38975] " sam at gcc dot gnu dot org
2009-10-03 10:32 ` ebotcazou at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: Artem dot Andreev at oktetlabs dot ru @ 2009-01-26 12:28 UTC (permalink / raw)
To: gcc-bugs
The following does not compile:
package Test is
type X is new Positive;
type X_Access is not null access constant X;
Y : constant X_Access;
private
Y_Val : aliased constant X := 1;
Y : constant X_Access := Y_Val'Access;
end Test;
with the following diagnostics:
test.ads:6:09: warning: (Ada 2005) null-excluding objects must be initialized
test.ads:6:09: warning: "Constraint_Error" will be raised at run time
test.ads:11:09: "Y" conflicts with declaration at line 6
If "not null" modifier is removed, everything is fine.
As I can see from the following code, the semantic analyzer sees a deferred
constant and (erroneously) assumes that it's an uninitialized object. It then
inserts an implicit null initialization. And when it comes to a full definition
of the constant, the compiler thinks it has been already defined:
(gcc/ada/checks.adb, procedure Null_Exclusion_Static_Checks, line 2728):
if K = N_Object_Declaration
and then No (Expression (N))
and then not No_Initialization (N)
then
-- Add an expression that assigns null. This node is needed by
-- Apply_Compile_Time_Constraint_Error, which will replace this with
-- a Constraint_Error node.
Set_Expression (N, Make_Null (Sloc (N)));
Set_Etype (Expression (N), Etype (Defining_Identifier (N)));
Apply_Compile_Time_Constraint_Error
(N => Expression (N),
Msg => "(Ada 2005) null-excluding objects must be initialized?",
Reason => CE_Null_Not_Allowed);
end if;
The code can be traced back to at least gcc 4.1.2
--
Summary: deferred constants of not null access types are not
possible
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: Artem dot Andreev at oktetlabs dot ru
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38975
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug ada/38975] deferred constants of not null access types are not possible
2009-01-26 12:28 [Bug ada/38975] New: deferred constants of not null access types are not possible Artem dot Andreev at oktetlabs dot ru
@ 2009-10-03 10:11 ` sam at gcc dot gnu dot org
2009-10-03 10:32 ` ebotcazou at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: sam at gcc dot gnu dot org @ 2009-10-03 10:11 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from sam at gcc dot gnu dot org 2009-10-03 10:11 -------
It has been fixed on trunk by commit 134020. The fix will be in GCC 4.5.0.
2008-04-08 Javier Miranda <miranda@adacore.com>
Robert Dewar <dewar@adacore.com>
Ed Schonberg <schonberg@adacore.com>
[...]
(Null_Exclusion_Static_Checks): If the non-null access type appears in
a
deferred constant declaration. do not add a null expression, to prevent
spurious errors when full declaration is analyzed.
--
sam at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sam at gcc dot gnu dot org
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38975
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug ada/38975] deferred constants of not null access types are not possible
2009-01-26 12:28 [Bug ada/38975] New: deferred constants of not null access types are not possible Artem dot Andreev at oktetlabs dot ru
2009-10-03 10:11 ` [Bug ada/38975] " sam at gcc dot gnu dot org
@ 2009-10-03 10:32 ` ebotcazou at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2009-10-03 10:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from ebotcazou at gcc dot gnu dot org 2009-10-03 10:31 -------
> It has been fixed on trunk by commit 134020. The fix will be in GCC 4.5.0.
>
> 2008-04-08 Javier Miranda <miranda@adacore.com>
> Robert Dewar <dewar@adacore.com>
> Ed Schonberg <schonberg@adacore.com>
The fix is already in GCC 4.4 then.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.5.0 |4.4.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38975
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-10-03 10:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-26 12:28 [Bug ada/38975] New: deferred constants of not null access types are not possible Artem dot Andreev at oktetlabs dot ru
2009-10-03 10:11 ` [Bug ada/38975] " sam at gcc dot gnu dot org
2009-10-03 10:32 ` ebotcazou at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).