PR c++/44648 - missing -Wunused warning on a const variable in if statement

gcc/testsuite/ChangeLog:
	* g++.dg/warn/Wunused-var-35.C: New test.

From-SVN: r268503
This commit is contained in:
Martin Sebor 2019-02-03 21:48:27 +00:00 committed by Martin Sebor
parent 6090f91591
commit 0b841214a8
2 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2019-02-03 Martin Sebor <msebor@redhat.com>
PR c++/44648
* g++.dg/warn/Wunused-var-35.C: New test.
2019-02-03 Richard Biener <rguenther@suse.de>
PR debug/87295

View File

@ -0,0 +1,19 @@
// PR c++/44648 - missing -Wunused warning on a const variable in if statement
// { dg-do compile }
// { dg-options "-Wunused" }
int main()
{
bool b0 = 1; // { dg-warning "\\\[-Wunused-variable\\\]" }
const bool b00 = 1; // { dg-warning "\\\[-Wunused-variable\\\]" }
if (bool b1 = 1) // { dg-warning "\\\[-Wunused-variable\\\]" }
return 0;
else
return 1;
if (const bool b2 = 1) // { dg-warning "\\\[-Wunused-variable\\\]" "bug" { xfail c++98_only } }
return 0;
else
return 1;
}