This is an archive of the discontinued LLVM Phabricator instance.

Fix for bug 22941, [asm inline] integer template parameter ...
ClosedPublic

Authored by Sunil_Srivastava on Jun 15 2015, 11:30 AM.

Details

Reviewers
majnemer
Summary

It should not be an error if an expression in inline-asm statements is not evaluatable while parsing the template, as the failure may be due to the presence of template paramaters, which do not have values at this stage.

This change suppresses those errors.

If the template gets used, another check is made during instantiation, and a failure to evaluate at that time is reported as an error.

The test checks both: that the error during template parsing is not reported, and an error detectable during instantiation is reported.

Diff Detail

Event Timeline

Sunil_Srivastava retitled this revision from to Fix for bug 22941, [asm inline] integer template parameter ....
Sunil_Srivastava updated this object.
Sunil_Srivastava edited the test plan for this revision. (Show Details)
Sunil_Srivastava added a subscriber: Unknown Object (MLST).
majnemer added inline comments.
lib/Sema/SemaStmtAsm.cpp
257

I think we could just fix this by inserting:

if (InputExpr->isValueDependent())
  continue;

Changed along the lines suggested by David Majnemer

ping

lib/Sema/SemaStmtAsm.cpp
257

Just that does not work because the 'continue' skips needed code later inside the loop body, leading to assertion failures, on the windows build at least.

However, wrapping whole 10 line checking code in a (!InputExpr->isValueDependent()) works. I am updating the review to reflect that.

This differential revision doesn't include a testcase.

lib/Sema/SemaStmtAsm.cpp
257

Please move this variable declaration to the point at which EvaluateAsInt is called.

Moved declaration of Result to just before its use.
The test is same as original, but added it back.

majnemer accepted this revision.Jul 8 2015, 9:47 AM
majnemer added a reviewer: majnemer.

LGTM

This revision is now accepted and ready to land.Jul 8 2015, 9:47 AM

submitted in r242175