public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16029] New: incorrect "unused variable" message from -Wall
@ 2004-06-16 23:23 tromey at gcc dot gnu dot org
2004-06-17 0:20 ` [Bug c++/16029] " bangerth at dealii dot org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: tromey at gcc dot gnu dot org @ 2004-06-16 23:23 UTC (permalink / raw)
To: gcc-bugs
Try this simple invalid program:
int main ()
{
return whatever ();
}
I compile it with -Wall:
fleche. g++ -Wall -c main.cc
main.cc: In function `int main()':
main.cc:3: error: `whatever' was not declared in this scope
main.cc:3: warning: unused variable 'whatever'
The "unused variable" warning is odd, I think it should not
be emitted.
I'm using a recent cvs trunk:
Reading specs from
/home/tromey/gnu/Trunk/install/lib/gcc/i686-pc-linux-gnu/3.5.0/specs
Configured with: ../gcc/configure --prefix=/home/tromey/gnu/Trunk/install
--enable-languages=c++,java --enable-threads=posix --enable-checking=tree
--enable-java-awt=gtk,xlib --disable-static
Thread model: posix
gcc version 3.5.0 20040616 (experimental)
--
Summary: incorrect "unused variable" message from -Wall
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tromey at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16029
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16029] incorrect "unused variable" message from -Wall
2004-06-16 23:23 [Bug c++/16029] New: incorrect "unused variable" message from -Wall tromey at gcc dot gnu dot org
@ 2004-06-17 0:20 ` bangerth at dealii dot org
2004-06-17 0:22 ` bangerth at dealii dot org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-06-17 0:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-06-17 00:20 -------
Well, that's error recovery: the compiler has to assume something when
encountering an error, before going on. In this case, it assumes that
'whatever' is a variable, and seems to tentatively inject a declaration
of it. Since the 'return' statement was in error, it is apparently not
considered a 'use' of this variable.
I am tempted to close this PR since it really is a case where one shouldn't
place too much emphasis on follow-up errors, given that the first error
is already pretty clear. However, it may also be easy enough to change the
compiler to mark all tentative variable and function declarations in error
recovery with __attribute__((used)) to avoid this kind of follow-up.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2004-06-17 00:20:08
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16029
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16029] incorrect "unused variable" message from -Wall
2004-06-16 23:23 [Bug c++/16029] New: incorrect "unused variable" message from -Wall tromey at gcc dot gnu dot org
2004-06-17 0:20 ` [Bug c++/16029] " bangerth at dealii dot org
@ 2004-06-17 0:22 ` bangerth at dealii dot org
2004-09-16 7:21 ` [Bug c++/16029] [4.0 Regression] " pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: bangerth at dealii dot org @ 2004-06-17 0:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2004-06-17 00:22 -------
It may or may not be worth stating that this warning was actually
only introduced after the branch of 3.4, i.e. it is only present on
mainline. Whether that qualifies this thing as a regression I consider
doubtful nevertheless.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16029
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16029] [4.0 Regression] incorrect "unused variable" message from -Wall
2004-06-16 23:23 [Bug c++/16029] New: incorrect "unused variable" message from -Wall tromey at gcc dot gnu dot org
2004-06-17 0:20 ` [Bug c++/16029] " bangerth at dealii dot org
2004-06-17 0:22 ` bangerth at dealii dot org
@ 2004-09-16 7:21 ` pinskia at gcc dot gnu dot org
2004-09-17 2:02 ` mmitchel at gcc dot gnu dot org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-16 7:21 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-16 07:21 -------
Related to bug 17393, this is a regression.
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|enhancement |minor
Keywords| |diagnostic
Known to fail| |4.0.0
Known to work| |3.4.0
Summary|incorrect "unused variable" |[4.0 Regression] incorrect
|message from -Wall |"unused variable" message
| |from -Wall
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16029
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16029] [4.0 Regression] incorrect "unused variable" message from -Wall
2004-06-16 23:23 [Bug c++/16029] New: incorrect "unused variable" message from -Wall tromey at gcc dot gnu dot org
` (2 preceding siblings ...)
2004-09-16 7:21 ` [Bug c++/16029] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2004-09-17 2:02 ` mmitchel at gcc dot gnu dot org
2004-09-17 7:01 ` cvs-commit at gcc dot gnu dot org
2004-09-17 7:12 ` mmitchel at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-09-17 2:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-09-17 02:02 -------
Working on a fix.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |mark at codesourcery dot com
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16029
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16029] [4.0 Regression] incorrect "unused variable" message from -Wall
2004-06-16 23:23 [Bug c++/16029] New: incorrect "unused variable" message from -Wall tromey at gcc dot gnu dot org
` (3 preceding siblings ...)
2004-09-17 2:02 ` mmitchel at gcc dot gnu dot org
@ 2004-09-17 7:01 ` cvs-commit at gcc dot gnu dot org
2004-09-17 7:12 ` mmitchel at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-09-17 7:01 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2004-09-17 07:01 -------
Subject: Bug 16029
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: mmitchel@gcc.gnu.org 2004-09-17 07:01:11
Modified files:
gcc/testsuite : ChangeLog
gcc/cp : ChangeLog lex.c parser.c
Added files:
gcc/testsuite/g++.dg/parse: error18.C
gcc/testsuite/g++.dg/warn: Wunused-8.C
Log message:
PR c++/16002
* parser.c (cp_parser_simple_declaration): Commit to tentative
parses after seeing a decl-specifier.
(cp_parser_simple_declaration): Eliminate spurious message.
(cp_parser_init_declarator): Adjust error message.
PR c++/16029
* lex.c (unqualified_name_lookup_error): Mark the dummy
declaration as used.
PR c++/16002
* g++.dg/template/error18.C: New test.
PR c++/16029
* g++.dg/warn/Wunused-8.C: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4303&r2=1.4304
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4360&r2=1.4361
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/lex.c.diff?cvsroot=gcc&r1=1.344&r2=1.345
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.248&r2=1.249
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error18.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wunused-8.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16029
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/16029] [4.0 Regression] incorrect "unused variable" message from -Wall
2004-06-16 23:23 [Bug c++/16029] New: incorrect "unused variable" message from -Wall tromey at gcc dot gnu dot org
` (4 preceding siblings ...)
2004-09-17 7:01 ` cvs-commit at gcc dot gnu dot org
@ 2004-09-17 7:12 ` mmitchel at gcc dot gnu dot org
5 siblings, 0 replies; 7+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-09-17 7:12 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2004-09-17 07:12 -------
Fixed in GCC 4.0.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16029
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-09-17 7:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-16 23:23 [Bug c++/16029] New: incorrect "unused variable" message from -Wall tromey at gcc dot gnu dot org
2004-06-17 0:20 ` [Bug c++/16029] " bangerth at dealii dot org
2004-06-17 0:22 ` bangerth at dealii dot org
2004-09-16 7:21 ` [Bug c++/16029] [4.0 Regression] " pinskia at gcc dot gnu dot org
2004-09-17 2:02 ` mmitchel at gcc dot gnu dot org
2004-09-17 7:01 ` cvs-commit at gcc dot gnu dot org
2004-09-17 7:12 ` mmitchel 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).