-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minor fixes #840
Minor fixes #840
Conversation
Move all initialization into constructor so some compilers can error on regression.
This LGTM! I'll run tests, but will merge if it looks ok to me (I don't feel like I need to wait until next week for this one, it's not a major change). So the new code still allows function to be declared twice as long as only one has statements? So this operates like a "forward declaration"? Is there any use for this, or should we just disallow the duplicate declaration in the same scope? |
Yes forward declarations are still allowed. I'd vote to keep them:
Fails:
Works:
Fixing the recursion issue looks to be non-trivial, but also seems it's a nice feature that it fails unless really explicit about it. |
I'm certainly fine with forward declarations, no reason to disallow them. In fact, we rely on them via stdosl.h to declare most of the built-ins that way. I do like the new property that it's a recognized error for the function to be declared more than once with statements. Recursion is explicitly disallowed by the OSL spec, and all user functions are inlined. This is (a) for speed, and (b) to eliminate stack overflows or infinite recursion (we try very hard to prevent user errors in shaders from being able to crash a renderer). |
Originally I had thought recursion was disallowed but searching both the spec and google turned up no info. Adding to the pdf in functions or control-flow might be worthwhile. |
Oops, you're right. My oversight. I will fix the spec, I'm not sure how that got lost. |
So 2e2e2fe wound up causing conflicts as it is attempting to fix what d5ad478 did, but from what I can tell 2e2e2fe is inferior: No filename/sourceline information about redefinition making the problem much more tedious to correct. It is warning on things that should be legal:
Is currently incorrectly (because fwd decl should be allowed and duped warning) spewing:
Demotion to warning instead of errs can make the compiler spew untruths later:
Leads to this output which is totally incorrect given the source:
Part of the original fix delineated built-ins from user defined functions leading to more descriptive messages such where the larger error is probably a user trying to override a builtin which can be reported as such:
The first two commits in this are fairly simple and I'm fine with loping off the last and opening a new PR devoted to redefinitions, or just merging/resolving the current conflicts here, but would like to avoid resolving conflicts only to repeat of the current situation of duplicated work. |
Oy, sorry, I guess I botched this, not realizing that there were two PRs simultaneously that were both addressing the double declaration problem. Yours was probably better. I'm sorry to make more work for you, but perhaps the best way to proceed is to merge just the first two commits of this PR, and then submit a second PR with the third commit, plus fixes to whatever I broke. |
d5ad478
to
be57edf
Compare
Ok, chopped of the conflict. First two should be easy enough to review. |
LGTM, merging. |
…AcademySoftwareFoundation#840) * Turn off Turn off whitespace insertion when using boost::wave. * Fix un-initialized members of ASTfunction_call. Move all initialization into constructor so some compilers can error on regression.
Description
Minor fixes that #836, #838, & #839 depend on that are less intrusive/controversial:
ASTfunction_call::m_poly
can possibly be left uninitialized.Tests
Yes
Checklist: