danmar / simplecpp

C++ preprocessor
BSD Zero Clause License
209 stars 83 forks source link

combineOperators() misidentifies references in C code #354

Open chrchr-github opened 5 months ago

chrchr-github commented 5 months ago

&= is tokenized as & =:

int g(int i, int j) {
    return h(i &= ~j, i &= j);
}
// don't combine &= if it is a anonymous reference parameter with default value:
// void f(x&=2)

Also happens in C++ code. This compiles: void f(const int& = 2); This does not: void f(const int &= 2);