On Thu, 29 Apr 2021, Jim Wilson wrote:

> Note that only in the -mfoo6= case are the duplicate options removed from
> the command line.  So pruning options requires that you have both
> RejectNegative and Negative pointing at yourself, which is not what the
> documentation says.

Thanks for the example.

There are definitely cases with RejectNegative that do not have the 
Negative semantics and so should not have any pruning done (for example, 
-Wa, is a JoinedOrMissing RejectNegative option).  I don't know if any 
such options have Negative specified, but I tend to think they shouldn't.

I think proper use of Negative should be to define equivalence classes of 
options, such that only the last such option (with its corresponding 
argument, if any) is in effect.  That is, it would naturally be completely 
orthogonal to Joined, JoinedOrMissing and RejectNegative.

As part of implmenting anything like the above, it's probably desirable to 
review existing uses of Negative to identify any which do not form a 
circular chain of options, or where the pruning isn't currently in effect 
because of any rules (documented or implemented) about interaction with 
Joined, JoinedOrMissing and RejectNegative.  In some cases, it's probably 
necessary to change the .opt files (to give options the correct semantics, 
or to keep them having the correct semantics).  If there are lots of cases 
where the semantics are correct at present but my proposal above means the 
.opt files need to change, we should look at some examples and consider 
revisiting my proposal.  When changes (to either option handling code or 
.opt files) fix user-visible problems with how options are handled at 
present, adding testcases to the testsuite would be a good idea, at least 
for some representative examples.

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to