view gcc/testsuite/g++.dg/warn/Wunused-var-35.C @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 1830386684a0
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;
}