[LLVMbugs] [Bug 10371] New: Spurious -Wunused-[x] warning within erroneous function
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jul 15 09:51:16 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10371
Summary: Spurious -Wunused-[x] warning within erroneous
function
Product: clang
Version: trunk
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: matthieu.monrocq at gmail.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
When a function does not parse correctly, there is a risk that some
arguments/identifiers be reported as unused; probably if they only appear in
expressions whose evaluation has been short-circuited.
Using the following short program:
struct A;
void sink(A,int);
void func(A const& a, int x, int y) {
sink(a + x, y);
}
Clang will correctly report an error, but it will accompany it by an incorrect
warning:
$ clang -fsyntax-only -Wunused-parameter unused_parameter.cpp
unused_parameter.cpp:15:11: error: invalid operands to binary expression
('const A' and 'int')
sink(a + x, y);
~ ^ ~
unused_parameter.cpp:14:34: warning: unused parameter 'y'
[-Wunused-parameter]
void func(A const& a, int x, int y) {
^
1 warning and 1 error generated.
For reference:
$ clang --version
clang version 3.0 (trunk 132889)
Target: i686-pc-mingw32
Thread model: posix
The warning is probably emitted because of the incomplete parse of the
function, meaning that the point of use is "hidden" by the error.
>From Ted:
We should probably not emit a -Wunused-[x] warning in cases where a function
doesn't fully parse correctly. Please file a bug.
Here it is :)
-- Matthieu
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list