This is an archive of the discontinued LLVM Phabricator instance.

Preserve unknown STDC pragma through preprocessor
ClosedPublic

Authored by steven_wu on Jan 5 2018, 11:17 AM.

Details

Summary

#pragma STDC FP_CONTRACT handler is only registered in parser so we
should keep the unknown STDC pragma through preprocessor and we also
should not emit warning for unknown STDC pragma during preprocessor.

rdar://problem/35724351

Diff Detail

Repository
rL LLVM

Event Timeline

steven_wu created this revision.Jan 5 2018, 11:17 AM
steven_wu edited the summary of this revision. (Show Details)Jan 5 2018, 11:19 AM

If you move all the #pragma STDC handlers from the lexer to the parser, you might be able to avoid adding an explicit STDC handler in PrintPreprocessedOutput.cpp.

test/Preprocessor/pragma_unknown.c
32 ↗(On Diff #128775)

Maybe add CHECK lines to make sure these come out correctly?

If you move all the #pragma STDC handlers from the lexer to the parser, you might be able to avoid adding an explicit STDC handler in PrintPreprocessedOutput.cpp.

If it is safe to do that, I can change it. I am not sure if the other STDC pragmas would affect preprocessor output in any other way (which seems not).

Should be safe, I think; currently, FENV_ACCESS and CX_LIMITED_RANGE have no effect, and when we do start supporting them, we'll probably want to handle them in the parser, like we do for FP_CONTRACT.

steven_wu updated this revision to Diff 128794.Jan 5 2018, 2:02 PM

Move STDC pragma handler to parser.

efriedma accepted this revision.Jan 5 2018, 2:38 PM

LGTM

This revision is now accepted and ready to land.Jan 5 2018, 2:38 PM
This revision was automatically updated to reflect the committed changes.
steven_wu marked an inline comment as done.