kphp icon indicating copy to clipboard operation
kphp copied to clipboard

unused variable warning in empty switch()

Open comm644 opened this issue 2 years ago • 0 comments

Alex: Свич по строке из 0 кейсов (но с дефолтом) выдаёт предупреждение на этапе сборки плюсов.

Пример:

/.../UserTitle_reflection@@set_as_bool.cpp:9:8: warning: variable ‘v$matched_with_one_case$u4fdd7fa40628ca72_0’ set but not used [-Wunused-but-set-variable]
    9 |   bool v$matched_with_one_case$u4fdd7fa40628ca72_0 = false;

код (автоматически с моего генератора рефлексии)

//crc64:ec6457b181d08f2a
//crc64_with_comments:cdf1993cc21dd52c
#include "runtime-headers.h"
#include "o_49/LoaderTask@UserTitle_reflection@@set_as_bool.h"
//source = [src/Reflection/LoaderTask/UserTitle_reflection.php]
//1743: public function set_as_bool(string  $name, bool $value):void
void f$LoaderTask$UserTitle_reflection$$set_as_bool(class_instance<C$LoaderTask$UserTitle_reflection> const &v$this, string const &v$name, bool v$value) noexcept  {
  mixed v$condition_on_switch$u4fdd7fa40628ca72_0;
  bool v$matched_with_one_case$u4fdd7fa40628ca72_0 = false;
//1744: {
//1745: switch ($name) {
  {
    v$condition_on_switch$u4fdd7fa40628ca72_0 = f$strval (v$name);
    v$matched_with_one_case$u4fdd7fa40628ca72_0 = false;
    switch (v$condition_on_switch$u4fdd7fa40628ca72_0.as_string().hash()) {
      default:
      v$matched_with_one_case$u4fdd7fa40628ca72_0 = true;
//1746: default: //throw new \Exception("invalid argument: $name");
//1747: //throw new ReflectionException("Property '$name' not found in \LoaderTask\UserTitle");
//1748: }
      {
      }
    }
  };
  return ;
}


comm644 avatar Apr 24 '22 22:04 comm644