[Bug ada/50300] New: Error message incomplete and points to the wrong place. "premature usage of incomplete type"

garynot at comcast dot net gcc-bugzilla@gcc.gnu.org
Mon Sep 5 19:08:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50300

             Bug #: 50300
           Summary: Error message incomplete and points to the wrong
                    place.  "premature usage of  incomplete type"
    Classification: Unclassified
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: garynot@comcast.net


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;



More information about the Gcc-bugs mailing list