summaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-07-15 10:40:39 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2016-07-15 10:40:39 +0000
commit0dd7db3b2527e4d4d596f6257cfa27210c4e922d (patch)
tree56e0c00028a6dfb864fa929c7d4929c7c0a6b999 /gcc/c
parentb41cc4d1b981166f94a05819eb4dc8092e09aaed (diff)
downloadgcc-0dd7db3b2527e4d4d596f6257cfa27210c4e922d.tar.gz
PR c/71858
* c-common.h (enum lookup_name_fuzzy_kind): Add FUZZY_LOOKUP_FUNCTION_NAME. * c-decl.c (implicit_decl_warning): Use FUZZY_LOOKUP_FUNCTION_NAME instead of FUZZY_LOOKUP_NAME. (lookup_name_fuzzy): For FUZZY_LOOKUP_FUNCTION_NAME consider FUNCTION_DECLs, {VAR,PARM}_DECLs function pointers and macros. * gcc.dg/spellcheck-identifiers-3.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238369 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog8
-rw-r--r--gcc/c/c-decl.c29
2 files changed, 33 insertions, 4 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 6d35693cb2f..968d942c7be 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,11 @@
+2016-07-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/71858
+ * c-decl.c (implicit_decl_warning): Use FUZZY_LOOKUP_FUNCTION_NAME
+ instead of FUZZY_LOOKUP_NAME.
+ (lookup_name_fuzzy): For FUZZY_LOOKUP_FUNCTION_NAME consider
+ FUNCTION_DECLs, {VAR,PARM}_DECLs function pointers and macros.
+
2016-07-14 Jakub Jelinek <jakub@redhat.com>
PR c/71858
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index e2e0f640b0a..955c0e8da73 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -3090,7 +3090,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl)
bool warned;
tree hint = NULL_TREE;
if (!olddecl)
- hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME);
+ hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME);
if (flag_isoc99)
if (hint)
@@ -4028,9 +4028,30 @@ lookup_name_fuzzy (tree name, enum lookup_name_fuzzy_kind kind)
if (TREE_CODE (binding->decl) == FUNCTION_DECL)
if (C_DECL_IMPLICIT (binding->decl))
continue;
- if (kind == FUZZY_LOOKUP_TYPENAME)
- if (TREE_CODE (binding->decl) != TYPE_DECL)
- continue;
+ switch (kind)
+ {
+ case FUZZY_LOOKUP_TYPENAME:
+ if (TREE_CODE (binding->decl) != TYPE_DECL)
+ continue;
+ break;
+
+ case FUZZY_LOOKUP_FUNCTION_NAME:
+ if (TREE_CODE (binding->decl) != FUNCTION_DECL)
+ {
+ /* Allow function pointers. */
+ if ((VAR_P (binding->decl)
+ || TREE_CODE (binding->decl) == PARM_DECL)
+ && TREE_CODE (TREE_TYPE (binding->decl)) == POINTER_TYPE
+ && (TREE_CODE (TREE_TYPE (TREE_TYPE (binding->decl)))
+ == FUNCTION_TYPE))
+ break;
+ continue;
+ }
+ break;
+
+ default:
+ break;
+ }
bm.consider (binding->id);
}