* c.opt (Wmissing-include-dirs): New.
* c-opts.c (c_common_handle_option): Pass true for user_supplied_p
to add_path () for -I, but false for OPT_idirafter, OPT_iquote and
OPT_isystem. Handle case OPT_Wmissing_include_dirs.
* c-incpath.h (add_path): Add fourth (bool) argument.
* c-incpath.c (add_env_var_paths): Pass false to add_path ().
(add_standard_paths): Likewise.
(remove_duplicates) [REASON_NOENT]: Warn if -Wmissing-include-dirs
is used and the directory was user-supplied via -I.
(add_path): Set p->user_supplied_p. Remove duplicated code by
using add_cpp_dir_path ().
* cpplib.h (struct cpp_options): Add warn_missing_include_dirs.
(struct cpp_dir): Add user_supplied_p.
* doc/invoke.texi (Warning Options): Document new option.
[testsuite]
* gcc.dg/cpp/Wmissingdirs.c: New.
From-SVN: r82121
+2004-05-22 Ben Elliston <bje@au.ibm.com>
+
+ * c.opt (Wmissing-include-dirs): New.
+ * c-opts.c (c_common_handle_option): Pass true for user_supplied_p
+ to add_path () for -I, but false for OPT_idirafter, OPT_iquote and
+ OPT_isystem. Handle case OPT_Wmissing_include_dirs.
+ * c-incpath.h (add_path): Add fourth (bool) argument.
+ * c-incpath.c (add_env_var_paths): Pass false to add_path ().
+ (add_standard_paths): Likewise.
+ (remove_duplicates) [REASON_NOENT]: Warn if -Wmissing-include-dirs
+ is used and the directory was user-supplied via -I.
+ (add_path): Set p->user_supplied_p. Remove duplicated code by
+ using add_cpp_dir_path ().
+ * cpplib.h (struct cpp_options): Add warn_missing_include_dirs.
+ (struct cpp_dir): Add user_supplied_p.
+ * doc/invoke.texi (Warning Options): Document new option.
+
2004-05-21 Ulrich Weigand <uweigand@de.ibm.com>
* fold-const.c (fold_read_from_constant_string): Convert result to
path[q - p] = '\0';
}
- add_path (path, chain, chain == SYSTEM);
+ add_path (path, chain, chain == SYSTEM, false);
}
}
if (!strncmp (p->fname, cpp_GCC_INCLUDE_DIR, len))
{
char *str = concat (iprefix, p->fname + len, NULL);
- add_path (str, SYSTEM, p->cxx_aware);
+ add_path (str, SYSTEM, p->cxx_aware, false);
}
}
}
else
str = update_path (p->fname, p->component);
- add_path (str, SYSTEM, p->cxx_aware);
+ add_path (str, SYSTEM, p->cxx_aware, false);
}
}
}
if (errno != ENOENT)
cpp_errno (pfile, CPP_DL_ERROR, cur->name);
else
- reason = REASON_NOENT;
+ {
+ /* If -Wmissing-include-dirs is given, warn. */
+ cpp_options *opts = cpp_get_options (pfile);
+ if (opts->warn_missing_include_dirs && cur->user_supplied_p)
+ cpp_errno (pfile, CPP_DL_WARNING, cur->name);
+ reason = REASON_NOENT;
+ }
}
else if (!S_ISDIR (st.st_mode))
cpp_error_with_line (pfile, CPP_DL_ERROR, 0, 0,
/* Add PATH to the include chain CHAIN. PATH must be malloc-ed and
NUL-terminated. */
void
-add_path (char *path, int chain, int cxx_aware)
+add_path (char *path, int chain, int cxx_aware, bool user_supplied_p)
{
cpp_dir *p;
else
p->sysp = 0;
p->construct = 0;
+ p->user_supplied_p = user_supplied_p;
- if (tails[chain])
- tails[chain]->next = p;
- else
- heads[chain] = p;
- tails[chain] = p;
+ add_cpp_dir_path (p, chain);
}
/* Exported function to handle include chain merging, duplicate
Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern void split_quote_chain (void);
-extern void add_path (char *, int, int);
+extern void add_path (char *, int, int, bool);
extern void register_include_chains (cpp_reader *, const char *,
const char *, int, int, int);
extern void add_cpp_dir_path (struct cpp_dir *, int);
case OPT_I:
if (strcmp (arg, "-"))
- add_path (xstrdup (arg), BRACKET, 0);
+ add_path (xstrdup (arg), BRACKET, 0, true);
else
{
if (quote_chain_split)
warn_missing_format_attribute = value;
break;
+ case OPT_Wmissing_include_dirs:
+ cpp_opts->warn_missing_include_dirs = value;
+ break;
+
case OPT_Wmissing_prototypes:
warn_missing_prototypes = value;
break;
break;
case OPT_idirafter:
- add_path (xstrdup (arg), AFTER, 0);
+ add_path (xstrdup (arg), AFTER, 0, true);
break;
case OPT_imacros:
break;
case OPT_iquote:
- add_path (xstrdup (arg), QUOTE, 0);
+ add_path (xstrdup (arg), QUOTE, 0, true);
break;
case OPT_isysroot:
break;
case OPT_isystem:
- add_path (xstrdup (arg), SYSTEM, 0);
+ add_path (xstrdup (arg), SYSTEM, 0, true);
break;
case OPT_iwithprefix:
memcpy (path + prefix_len, suffix, suffix_len);
path[prefix_len + suffix_len] = '\0';
- add_path (path, chain, 0);
+ add_path (path, chain, 0, false);
}
/* Handle -D, -U, -A, -imacros, and the first -include. */
C ObjC C++ ObjC++
Warn about functions which might be candidates for format attributes
+Wmissing-include-dirs
+C ObjC C++ ObjC++
+Warn about user-specified include directories that do not exist
+
Wmissing-prototypes
C ObjC
Warn about global functions without prototypes
/* Nonzero means warn if slash-star appears in a comment. */
unsigned char warn_comments;
+ /* Nonzero means warn if a user-supplied include directory does not
+ exist. */
+ unsigned char warn_missing_include_dirs;
+
/* Nonzero means warn if there are any trigraphs. */
unsigned char warn_trigraphs;
directories in the search path. */
ino_t ino;
dev_t dev;
+
+ /* Is this a user-supplied directory? */
+ bool user_supplied_p;
};
/* Name under which this program was invoked. */
-Wno-invalid-offsetof -Winvalid-pch @gol
-Wlarger-than-@var{len} -Wlong-long @gol
-Wmain -Wmissing-braces @gol
--Wmissing-format-attribute -Wmissing-noreturn @gol
+-Wmissing-format-attribute -Wmissing-include-dirs @gol
+-Wmissing-noreturn @gol
-Wno-multichar -Wnonnull -Wpacked -Wpadded @gol
-Wparentheses -Wpointer-arith -Wredundant-decls @gol
-Wreturn-type -Wsequence-point -Wshadow @gol
int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
@end smallexample
+@item -Wmissing-include-dirs @r{(C, C++, and Objective-C only)}
+@opindex Wmissing-include-dirs
+Warn if a user-supplied include directory does not exist.
+
@item -Wparentheses
@opindex Wparentheses
Warn if parentheses are omitted in certain contexts, such
+2004-05-22 Ben Elliston <bje@au.ibm.com>
+
+ * gcc.dg/cpp/Wmissingdirs.c: New.
+
2004-05-20 H.J. Lu <hongjiu.lu@intel.com>
PR target/15301
PR c++/9559
* g++.dg/init/static1.C: New test.
-2003-06-30 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
-
- * Changelog: Remove ">>>>>>>" from previous change.
-
2003-06-30 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
* g++.old-deja/g++.niklas/README: Fix spelling for "testcase".
--- /dev/null
+/* { dg-do preprocess } */
+/* { dg-options "-std=gnu99 -I /jolly/well/better/not/exist -Wmissing-include-dirs -fno-show-column" } */
+
+/* Test that -Wmissing-include-dirs issues a warning when a specified
+ directory does not exist. Source Ben Elliston, 2004-05-13. */
+
+/* { dg-warning "No such file or directory" "-Wmissing-include-dirs" { target *-*-* } 0 } */