Bug 69453 - unrecognized command line option suggestions should take negation into account
Summary: unrecognized command line option suggestions should take negation into account
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: David Malcolm
URL:
Keywords:
: 69642 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-01-24 10:53 UTC by Markus Trippelsdorf
Modified: 2016-02-12 17:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-01-25 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2016-01-24 10:53:35 UTC
Unrecognized command line option suggestions should take negation into account:

markus@x4 tmp % g++ --Wno-narrowing
g++: error: unrecognized command line option ‘--Wno-narrowing’; did you mean ‘-Wnarrowing’?
g++: fatal error: no input files
compilation terminated.

"did you mean ‘-Wno-narrowing’" would be nicer.
Comment 1 Andrew Pinski 2016-01-25 01:43:02 UTC
Confirmed.
Even the following:
-fmo-unroll-loops

Should recommend -fno-unroll-loops instead of -funroll-loops .

The n and m switch up happens when you are typing the command manually and very quickly without looking at the keyboard.
Comment 2 Markus Trippelsdorf 2016-01-25 08:51:19 UTC
(In reply to Andrew Pinski from comment #1)
 > The n and m switch up happens when you are typing the command manually and
> very quickly without looking at the keyboard.

(Not when you type Colemak, like myself...)
Comment 3 David Malcolm 2016-01-25 14:37:06 UTC
Although it's not a duplicate, I believe that the patch I posted for PR 69265 covers this:
  https://gcc.gnu.org/ml/gcc-patches/2016-01/msg00871.html

I can add the testcases suggested in this bug.
Comment 4 Andrew Pinski 2016-02-02 23:37:17 UTC
*** Bug 69642 has been marked as a duplicate of this bug. ***
Comment 5 David Malcolm 2016-02-12 17:39:58 UTC
Author: dmalcolm
Date: Fri Feb 12 17:39:27 2016
New Revision: 233382

URL: https://gcc.gnu.org/viewcvs?rev=233382&root=gcc&view=rev
Log:
PR driver/69265 and 69453: improved suggestions for various misspelled options

gcc/ChangeLog:
	PR driver/69265
	PR driver/69453
	* gcc.c (driver::driver): Initialize m_option_suggestions.
	(driver::~driver): Clean up m_option_suggestions.
	(suggest_option): Convert to...
	(driver::suggest_option): ...this, and split out into
	driver::build_option_suggestions and find_closest_string.
	(driver::build_option_suggestions): New function, from
	first half of suggest_option.  Special-case
	OPT_fsanitize_ and OPT_fsanitize_recover_, making use of
	the sanitizer_opts array.  For options of enum types, add the
	various enum values to the candidate strings.
	(driver::handle_unrecognized_options): Remove "const".
	* gcc.h (driver::handle_unrecognized_options): Likewise.
	(driver::build_option_suggestions): New decl.
	(driver::suggest_option): New decl.
	(driver::m_option_suggestions): New field.
	* opts-common.c (add_misspelling_candidates): New function.
	* opts.c (sanitizer_opts): Remove decl of struct sanitizer_opts_s
	and make non-static.
	* opts.h (sanitizer_opts): New array decl.
	(add_misspelling_candidates): New function decl.
	* spellcheck.c (find_closest_string): New function.
	* spellcheck.h (find_closest_string): New function decl.

gcc/testsuite/ChangeLog:
	PR driver/69265
	PR driver/69453
	* gcc.dg/spellcheck-options-3.c: New test case.
	* gcc.dg/spellcheck-options-4.c: New test case.
	* gcc.dg/spellcheck-options-5.c: New test case.
	* gcc.dg/spellcheck-options-6.c: New test case.
	* gcc.dg/spellcheck-options-7.c: New test case.
	* gcc.dg/spellcheck-options-8.c: New test case.
	* gcc.dg/spellcheck-options-9.c: New test case.
	* gcc.dg/spellcheck-options-10.c: New test case.


Added:
    trunk/gcc/testsuite/gcc.dg/spellcheck-options-10.c
    trunk/gcc/testsuite/gcc.dg/spellcheck-options-3.c
    trunk/gcc/testsuite/gcc.dg/spellcheck-options-4.c
    trunk/gcc/testsuite/gcc.dg/spellcheck-options-5.c
    trunk/gcc/testsuite/gcc.dg/spellcheck-options-6.c
    trunk/gcc/testsuite/gcc.dg/spellcheck-options-7.c
    trunk/gcc/testsuite/gcc.dg/spellcheck-options-8.c
    trunk/gcc/testsuite/gcc.dg/spellcheck-options-9.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/gcc.c
    trunk/gcc/gcc.h
    trunk/gcc/opts-common.c
    trunk/gcc/opts.c
    trunk/gcc/opts.h
    trunk/gcc/spellcheck.c
    trunk/gcc/spellcheck.h
    trunk/gcc/testsuite/ChangeLog
Comment 6 David Malcolm 2016-02-12 17:45:10 UTC
Should be fixed as of r233382; marking this one as resolved.