[Bug c++/39551] New: C++ frontend not warn about unused dereference operator with -Wunused-value

2009-03-24 Thread lcwu at gcc dot gnu dot org
Given the following code, where the value of the dereference operation is
unused, 

$ cat unused_deref.c
void Foo(int* x) {
  *x++;
}

if it is compiled with gcc (C frontend) with -Wunused-value option, we get a
warning.

$ gcc -Wunused-value -c unused_deref.c
unused_deref.c: In function 'Foo':
unused_deref.c:2: warning: value computed is not used

However, if the code is compiled with g++, we don't get the warning.

$ g++ -Wunused-value -c unused_deref.c


After doing some triage, it appears that C++ frontend silently gets rid of
INDIRECT_REF operator (without emitting any warnings) when it processes the
expression '*x++' in convert_to_void() in cp/cvt.c.

Here is the version string of the compiler that I tried:
gcc version 4.4.0 20090324 (experimental) (GCC)


-- 
   Summary: C++ frontend not warn about unused dereference operator
with -Wunused-value
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lcwu at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



[Bug c++/39551] C++ frontend not warn about unused dereference operator with -Wunused-value

2009-04-15 Thread lcwu at gcc dot gnu dot org


--- Comment #1 from lcwu at gcc dot gnu dot org  2009-04-15 17:56 ---
Subject: Bug 39551

Author: lcwu
Date: Wed Apr 15 17:55:50 2009
New Revision: 146132

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146132
Log:
PR c++/39551
* gcc/cp/call.c (build_over_call): Set TREE_NO_WARNING on the
compiler-generated INDIRECT_REF expression.
* gcc/cp/cvt.c (convert_to_void): Emit warning when stripping off
INDIRECT_REF.
* gcc/testsuite/g++.dg/warn/Wunused-13.C: New testcase.

Added:
trunk/gcc/testsuite/g++.dg/warn/Wunused-13.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/call.c
trunk/gcc/cp/cvt.c
trunk/gcc/testsuite/ChangeLog


-- 


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



[Bug c++/39551] C++ frontend not warn about unused dereference operator with -Wunused-value

2009-04-15 Thread lcwu at gcc dot gnu dot org


--- Comment #2 from lcwu at gcc dot gnu dot org  2009-04-15 18:03 ---
The fix for this bug was committed at revision 146132.


-- 

lcwu at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||FIXED


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



[Bug c++/39803] New: Bogus 'unused value' warning on declarations of non-POD arrays

2009-04-17 Thread lcwu at gcc dot gnu dot org
When compiling the following program using the mainline GCC (4.5) with -Wunused
flag, we get a bogus "unused value" warning on the array declaration:

$ cat Wunused-14.C
#include 

using std::pair;

int foo() {
  pair components[3];
  components[0].first = 0;
  return 0;
}

$ g++ -Wunused -c Wunused-14.C 
Wunused-14.C: In function 'int foo()':
Wunused-14.C:6: warning: value computed is not used

Here is the version string of the compiler used:
Target: x86_64-unknown-linux-gnu
gcc version 4.5.0 20090414 (experimental) (GCC)


-- 
   Summary: Bogus 'unused value' warning on declarations of non-POD
arrays
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: lcwu at gcc dot gnu dot org


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



[Bug c++/39803] Bogus 'unused value' warning on declarations of non-POD arrays

2009-04-17 Thread lcwu at gcc dot gnu dot org


--- Comment #1 from lcwu at gcc dot gnu dot org  2009-04-17 23:07 ---
This bogus warning started to show up after the fix for PR c++/39551 was
submitted (at revision 146132). And the root cause for the issue is that C++
front-end generates the following code to initialize the local 'pair' array:
(see build_vec_init() in cp/init.c)

*(struct pair[3] *) ({
  (D.2247 = (struct pair *) &components);
  (D.2248 = D.2247);
  (D.2249 = 2);
  for_stmt
{
  D.2249 != -1;
  --D.2249;
  __comp_ctor  (NON_LVALUE_EXPR );
  ++D.2248;
}
  D.2247; })

The INDIRECT_REF operation (*) in the above code was later determined useless
and therefore deleted. However, since we didn't know that the INDIRECT_REF
expression was actually created by the compiler (instead of coming from the
user code) and therefore mistakenly emit an 'unused value' warning.


-- 


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



[Bug c++/39803] Bogus 'unused value' warning on declarations of non-POD arrays

2009-04-20 Thread lcwu at gcc dot gnu dot org


--- Comment #2 from lcwu at gcc dot gnu dot org  2009-04-20 21:13 ---
Subject: Bug 39803

Author: lcwu
Date: Mon Apr 20 21:13:08 2009
New Revision: 146454

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146454
Log:
PR c++/39803
* gcc/cp/init.c (build_vec_init): Set TREE_NO_WARNING on the
compiler-generated INDIRECT_REF expression.
* gcc/testsuite/g++.dg/warn/Wunused-14.C: New test.

Added:
trunk/gcc/testsuite/g++.dg/warn/Wunused-14.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/init.c
trunk/gcc/testsuite/ChangeLog


-- 


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



[Bug c++/39803] Bogus 'unused value' warning on declarations of non-POD arrays

2009-04-20 Thread lcwu at gcc dot gnu dot org


--- Comment #3 from lcwu at gcc dot gnu dot org  2009-04-20 21:45 ---
The fix for this bug was committed to mainline at revision 146454.


-- 

lcwu at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||FIXED


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



[Bug bootstrap/39968] [4.5 Regression] ./plugin-version.h:11: error: 'gcc_version' defined but not used

2009-04-29 Thread lcwu at gcc dot gnu dot org


--- Comment #2 from lcwu at gcc dot gnu dot org  2009-04-30 00:34 ---
The sole use of gcc_version in plugin.c is in function try_init_one_plugin,
which is guarded by the macro ENABLE_PLUGIN. Since ENABLE_PLUGIN is set to 0 on
the Darwin systems, the function was compiled out. I think we need to guard the
inclusion of plugin-version.h with ENABLE_PLUGIN as well.


-- 

lcwu at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||dnovillo at google dot com,
   ||lcwu at gcc dot gnu dot org,
   ||espindola at google dot com
 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2009-04-30 00:34:30
   date||


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



[Bug c++/44128] New: C++ frontend not warn on type shadowing with -Wshadow

2010-05-13 Thread lcwu at gcc dot gnu dot org
This bug is a follow-up to bug c++/44122.

Given the following program:

$ cat t.c

typedef long Py_ssize_t;

void bar() {

 typedef int Py_ssize_t;
 Py_ssize_t pos;
}

When compiled with the C compiler with -Wshadow flag, a shadow warning is
emitted.

$ gcc -c t.c -Wshadow
t.c: In function ‘bar’:
t.c:5:14: warning: declaration of ‘Py_ssize_t’ shadows a global declaration
[-Wshadow]
t.c:1:14: warning: shadowed declaration is here [-Wshadow]

However, when using the C++ compiler with the same flag, no warning is emitted.

$ g++ -c t.c -Wshadow

I think C++ frontend should warn on this case as the C frontend.


-- 
   Summary: C++ frontend not warn on type shadowing with -Wshadow
   Product: gcc
   Version: 4.6.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: lcwu at gcc dot gnu dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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