Bug 50300 - Error message incomplete and points to the wrong place. "premature usage of incomplete type"
Summary: Error message incomplete and points to the wrong place. "premature usage of ...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 4.5.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-05 19:08 UTC by Gary Barnes
Modified: 2015-12-06 14:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gary Barnes 2011-09-05 19:08:39 UTC
Using the current GNAT GPL from AdaCore
GNAT GPL 2011 (20110419)
Copyright 1996-2011, Free Software Foundation, Inc.


lapwarmer-171: gcc -v

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/gnat/libexec/gcc/i686-pc-linux-gnu/4.5.3/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../src/configure --prefix=/usr/gnat --with-libelf=/ter.a/gnatmail/release-gpl/build-ter/libmpfr/install --with-mpc=/ter.a/gnatmail/release-gpl/build-ter/libmpfr/install --with-gmp=/ter.a/gnatmail/release-gpl/build-ter/libmpfr/install --with-mpfr=/ter.a/gnatmail/release-gpl/build-ter/libmpfr/install --build=i686-pc-linux-gnu --enable-languages=c,ada,c++ --disable-nls --without-libiconv-prefix --disable-libmudflap --disable-libstdcxx-pch --disable-libada --enable-checking=release --enable-__cxa_atexit --enable-threads=posix --with-bugurl=URL:mailto:report@adacore.com --with-build-time-tools=/ter.a/gnatmail/release-gpl/build-ter/obj
Thread model: posix
gcc version 4.5.3 20110419 for GNAT GPL 2011 (20110419) (GCC) 

lapwarmer-172: gcc -c -gnata -gnatE -fstack-check -gnatef -gnatf -gnatm50 \
                      -gnatn -gnato -gnatU -gnatwa -gnatwe -gnatwi -gnatwj \
                      -gnatwK -gnatwl -Wuninitialized -gnatVa \
                      -pass-exit-codes -O -g -gnatA -x ada proc.adb

proc.adb:15:09: error: premature usage of incomplete private type "P2" defined at line 8

The actual error is that the completion of P2 is trying to use the also-incomplete P1 as a field and it is the incompleteness of P1 that is a problem.  It would also be much better to point to line 10.

The test program is quite small.

with Text_Io;

procedure Proc is

    package X is
        type P1 is private;
        package Y is
            type P2 is private;
        private
            type P2 is
                record
                    Z : P1; -- Actual error is use of P1 before completed.
                end record;
        end Y;
        Q : Y.P2;
    private
        type P1 is new Integer;
    end X;

begin
    Text_Io.Put_Line ("Hello");
end Proc;
Comment 1 Eric Botcazou 2015-12-06 14:21:06 UTC
Problems in AdaCore's compilers must be reported to AdaCore.