public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26269]  New: [3.4/4.0/4.1/4.2 regression] Declaring a variable too late yields bogus error message
@ 2006-02-13 22:56 reichelt at gcc dot gnu dot org
  2006-02-14  0:00 ` [Bug c++/26269] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: reichelt at gcc dot gnu dot org @ 2006-02-13 22:56 UTC (permalink / raw)
  To: gcc-bugs

Compiling the invalid code snippet

==================
void foo()
{
    i;
    int i;
}
==================

yields the following error message (since GCC 3.4.5):

bug.cc: In function 'void foo()':
bug.cc:3: error: 'i' was not declared in this scope
bug.cc:4: error: redeclaration of 'int i'
bug.cc:3: error: '<typeprefixerror>i' previously declared here

The error about the redeclaraion is bogus here.
It is issued because we created a dummy declaration of 'i' to
suppress further error messages about 'i' being not declared.

Since the dummy declaration contains an error_mark_node as TREE_TYPE
(which btw. causes the <typeprefixerror> part) we should be able to
detect this case and skip issuing the redeclaration error message.
In fact we do attempt something like this in duplicate_decls:

  /* If either the type of the new decl or the type of the old decl is an
     error_mark_node, then that implies that we have already issued an
     error (earlier) for some bogus type specification, and in that case,
     it is rather pointless to harass the user with yet more error message
     about the same declaration, so just pretend the types match here.  */
  if (TREE_TYPE (newdecl) == error_mark_node
      || TREE_TYPE (olddecl) == error_mark_node)
    types_match = 1;

We indeed have TREE_TYPE (olddecl) == error_mark_node in the testcase
above, but apparently just setting types_match = 1 is not enough.

Is it possible to get rid of olddecl altogether and replace it with
newdecl?


-- 
           Summary: [3.4/4.0/4.1/4.2 regression] Declaring a variable too
                    late yields bogus error message
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: diagnostic, monitored
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: reichelt at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-07-04 15:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-13 22:56 [Bug c++/26269] New: [3.4/4.0/4.1/4.2 regression] Declaring a variable too late yields bogus error message reichelt at gcc dot gnu dot org
2006-02-14  0:00 ` [Bug c++/26269] " pinskia at gcc dot gnu dot org
2006-02-14  9:08 ` mmitchel at gcc dot gnu dot org
2006-02-14  9:09 ` mmitchel at gcc dot gnu dot org
2006-02-14 10:04 ` rguenth at gcc dot gnu dot org
2006-02-24  0:30 ` mmitchel at gcc dot gnu dot org
2006-05-25  2:43 ` [Bug c++/26269] [4.0/4.1/4.2 " mmitchel at gcc dot gnu dot org
2006-08-19 19:10 ` lmillward at gcc dot gnu dot org
2006-08-20  7:33 ` patchapp at dberlin dot org
2006-08-21 17:28 ` lmillward at gcc dot gnu dot org
2006-08-21 17:28 ` [Bug c++/26269] [4.0/4.1 " lmillward at gcc dot gnu dot org
2007-02-14  9:09 ` mmitchel at gcc dot gnu dot org
2008-07-04 15:17 ` [Bug c++/26269] [4.1 " jsm28 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).