+2016-05-18 David Malcolm <dmalcolm@redhat.com>
+
+ PR driver/69265
+ * Makefile.in (GCC_OBJS): Move spellcheck.o to...
+ (OBJS-libcommon-target): ...here.
+ * opts-common.c: Include spellcheck.h.
+ (cmdline_handle_error): Build a vec of valid options and use it
+ to suggest provide hints for misspelled arguments.
+
2016-05-18 Jakub Jelinek <jakub@redhat.com>
PR c++/71100
FORTRAN_TARGET_OBJS=@fortran_target_objs@
# Object files for gcc many-languages driver.
-GCC_OBJS = gcc.o gcc-main.o ggc-none.o spellcheck.o
+GCC_OBJS = gcc.o gcc-main.o ggc-none.o
c-family-warn = $(STRICT_WARN)
# compiler and containing target-dependent code.
OBJS-libcommon-target = $(common_out_object_file) prefix.o params.o \
opts.o opts-common.o options.o vec.o hooks.o common/common-targhooks.o \
- hash-table.o file-find.o
+ hash-table.o file-find.o spellcheck.o
# This lists all host objects for the front ends.
ALL_HOST_FRONTEND_OBJS = $(foreach v,$(CONFIG_LANGUAGES),$($(v)_OBJS))
#include "opts.h"
#include "options.h"
#include "diagnostic.h"
+#include "spellcheck.h"
static void prune_options (struct cl_decoded_option **, unsigned int *);
for (i = 0; e->values[i].arg != NULL; i++)
len += strlen (e->values[i].arg) + 1;
+ auto_vec <const char *> candidates;
s = XALLOCAVEC (char, len);
p = s;
for (i = 0; e->values[i].arg != NULL; i++)
memcpy (p, e->values[i].arg, arglen);
p[arglen] = ' ';
p += arglen + 1;
+ candidates.safe_push (e->values[i].arg);
}
p[-1] = 0;
- inform (loc, "valid arguments to %qs are: %s", option->opt_text, s);
+ const char *hint = find_closest_string (arg, &candidates);
+ if (hint)
+ inform (loc, "valid arguments to %qs are: %s; did you mean %qs?",
+ option->opt_text, s, hint);
+ else
+ inform (loc, "valid arguments to %qs are: %s", option->opt_text, s);
+
return true;
}
+2016-05-18 David Malcolm <dmalcolm@redhat.com>
+
+ PR driver/69265
+ * gcc.dg/spellcheck-options-11.c: New test case.
+
2016-05-18 Jakub Jelinek <jakub@redhat.com>
PR c++/71100
--- /dev/null
+/* Verify that we provide a hint if the user misspells an option argument
+ (PR driver/69265). */
+
+/* { dg-do compile } */
+/* { dg-options "-ftls-model=global-dinamic" } */
+/* { dg-error "unknown TLS model 'global-dinamic'" "" { target *-*-* } 0 } */
+/* { dg-message "valid arguments to '-ftls-model=' are: global-dynamic initial-exec local-dynamic local-exec; did you mean 'global-dynamic'?" "" { target *-*-* } 0 } */