view gcc/testsuite/g++.dg/warn/Wunused-var-35.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents
children
line wrap: on
line source

// 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\\\]" }
    return 0;
  else
    return 1;
}