Project

General

Profile

Actions

Bug #10478

closed

Respect intermixes of declarations and statements

Added by Evgeny Novikov over 3 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Urgent
Category:
C back-end
Start date:
08/28/2020
Due date:
% Done:

0%

Estimated time:
Detected in build:
git
Platform:
Published in build:

Description

Sometimes developers intermix declarations and statements and sometimes it is not valid to reorder them. For instance, Pavel Andrianov revealed such the case:

mutex_lock(&ldv_lock);
char *ptr = gp;

(it is not valid to change the order of these two lines since a data race can arise).

Actions #3

Updated by Evgeny Novikov over 2 years ago

  • Priority changed from High to Urgent

Yet another example shot in another project is declaration that is put somewhere within statements/expressions and that is initialed with a function call. Moving such declarations to the beginning of the function can completely break the logic especially the environment model logic where everything is strictly depend on the context and particular places of corresponding actions.

Actions #4

Updated by Evgeny Novikov over 2 years ago

  • Status changed from New to Closed

I fixed this issue in 8ec721468aec. Besides, that commit added a new test case for C Backend. Surprisingly it was not very hard to fix the issue since processing of various cases (variables, labels, type declarations and normal statements) were already supported. It was necessary just to move some handlers to the appropriate places and take into account different cases, e.g. when there is the only variable declaration in a block. Let's see on results of a more exhaustive testing.

Actions

Also available in: Atom PDF