ArduinoCore-API
ArduinoCore-API copied to clipboard
Fix -Wshadow warning for Interrupt callbacks
Adding -Wshadow to builds identified a template for the Interrupt callback which used a local variable the same as the function parameter. Rename the local variable to not shadow the parameter and make GCC happier.
The GCC warning for -Wshadow is as follows:
In file included from /home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/../../../ArduinoCore-API/api/ArduinoAPI.h:29,
from /home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/ArduinoAPI.h:2,
from /home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/Arduino.h:28,
from /tmp/arduino_build_576215/sketch/DataLoggerUSB.ino.cpp:1:
/home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/../../../ArduinoCore-API/api/Interrupts.h: In lambda function:
/home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/../../../ArduinoCore-API/api/Interrupts.h:50:7: warning: declaration of 'T param' shadows a parameter [-Wshadow]
50 | T param = *(T*)((struct __container__<T>*)a)->param;
| ^~~~~
/home/earle/Arduino/hardware/pico/rp2040/cores/rp2040/api/../../../ArduinoCore-API/api/Interrupts.h:40:125: note: shadowed declaration is here
40 | template<typename T> void attachInterrupt(pin_size_t interruptNum, voidTemplateFuncPtrParam<T> userFunc, PinStatus mode, T& param) {
| ~~~^~~~~
Unit tests looks like it's failing in some other part of the CI infra not related to the 2-line patch here
/home/runner/work/ArduinoCore-API/ArduinoCore-API/test/src/String/test_move.cpp: In function ‘void C_A_T_C_H_T_E_S_T_4()’:
/home/runner/work/ArduinoCore-API/ArduinoCore-API/test/src/String/test_move.cpp:45:7: error: moving ‘a’ of type ‘arduino::String’ to itself [-Werror=self-move]
45 | a = std::move(a);
| ~~^~~~~~~~~~~~~~
/home/runner/work/ArduinoCore-API/ArduinoCore-API/test/src/String/test_move.cpp:45:7: note: remove ‘std::move’ call