29 lines
1,016 B
C++
29 lines
1,016 B
C++
// genericLambda.cpp — Phase 2.7 cxxSmoke check 2.
|
|
//
|
|
// Exercises a C++14 generic lambda (auto parameter) that captures a local
|
|
// i32 accumulator by reference. The i32 path is the path most recently
|
|
// touched by codegen work (most likely place to regress).
|
|
//
|
|
// The lambda is invoked twice: once with an i16 argument, once with an
|
|
// i32 argument. After both calls the accumulator holds the sum, which we
|
|
// split into two u16 markers.
|
|
//
|
|
// $025000 = lo16 of acc (0x100 + 0x12345 = 0x12445; lo = 0x2445)
|
|
// $025002 = hi16 of acc (hi = 0x0001)
|
|
// $025004 = 0x0099 success marker
|
|
#include <stdint.h>
|
|
|
|
|
|
int main(void) {
|
|
volatile int32_t acc = 0;
|
|
auto add = [&](auto x) {
|
|
acc += (int32_t)x;
|
|
};
|
|
add((int16_t)0x100);
|
|
add((int32_t)0x12345);
|
|
uint32_t v = (uint32_t)acc;
|
|
*(volatile uint16_t *)0x025000UL = (uint16_t)(v & 0xFFFFu);
|
|
*(volatile uint16_t *)0x025002UL = (uint16_t)((v >> 16) & 0xFFFFu);
|
|
*(volatile uint16_t *)0x025004UL = 0x0099;
|
|
return 0;
|
|
}
|