Bug 543383 - Macro expansion result is not re-evaluated on resource save
Summary: Macro expansion result is not re-evaluated on resource save
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 9.5.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-12 02:12 EST by Vladimir Grishchenko CLA
Modified: 2020-09-04 15:27 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Grishchenko CLA 2019-01-12 02:12:34 EST
Consider these files:

test.h:
#ifndef TEST_H_
#define TEST_H_
#if (FOO == 1)
#	define BAR 1
#else
#	if (FOO == 2)
#		define BAZ 2
#	else
#		define BAZ 3
#	endif
#	define BAR BAZ
#endif
#endif /* TEST_H_ */

test.c:
#define FOO 1
#include "test.h"
int main() {
	return BAR;
}


Macro expansion evaluation (hover or explore) will not update when the value of FOO is changed (2 or 3) in test.c and the file is saved. Rebuilding the index or saving test.h fixes it. Arguably not the best programming style but fairly common nevertheless.
Comment 1 Vladimir Grishchenko CLA 2019-01-12 02:26:01 EST
By macro expansion I meant BAR in main.
Comment 2 Vladimir Grishchenko CLA 2019-01-12 02:57:29 EST
Additional detail, this works as expected if I select "Index all header variants" under Indexer settings.