diff options
author | Jakub Jelinek <jakub@redhat.com> | 2016-02-23 20:47:24 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2016-02-23 20:47:24 +0100 |
commit | 067fbd8b4b3a4af6d0948204e42b2f928c5e5282 (patch) | |
tree | 581ba76b0e43ed3d6b85de942669146902e8d4d5 /gcc/c | |
parent | 64a454d9f74cecd95241e96fef281b64715049c4 (diff) | |
download | gcc-067fbd8b4b3a4af6d0948204e42b2f928c5e5282.zip gcc-067fbd8b4b3a4af6d0948204e42b2f928c5e5282.tar.gz gcc-067fbd8b4b3a4af6d0948204e42b2f928c5e5282.tar.bz2 |
re PR objc/69844 (Possibly bogus error: unknown type name in ObjC code)
PR objc/69844
* c-parser.c (c_parser_for_statement): Properly handle ObjC classes
in id_kind reclassification.
* objc.dg/pr69844.m: New test.
From-SVN: r233643
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 31 |
2 files changed, 30 insertions, 7 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index ae00338..d0fbaba 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2016-02-23 Jakub Jelinek <jakub@redhat.com> + + PR objc/69844 + * c-parser.c (c_parser_for_statement): Properly handle ObjC classes + in id_kind reclassification. + 2016-02-16 Jakub Jelinek <jakub@redhat.com> PR c/69835 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 23853be..82c1d61 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -5886,13 +5886,30 @@ c_parser_for_statement (c_parser *parser, bool ivdep) if (c_parser_next_token_is (parser, CPP_NAME)) { c_token *token = c_parser_peek_token (parser); - tree decl = lookup_name (token->value); - if (decl == NULL_TREE || VAR_P (decl)) - /* If DECL is null, we don't know what this token might be. Treat - it as an ID for better diagnostics; we'll error later on. */ - token->id_kind = C_ID_ID; - else if (TREE_CODE (decl) == TYPE_DECL) - token->id_kind = C_ID_TYPENAME; + + if (token->id_kind != C_ID_CLASSNAME) + { + tree decl = lookup_name (token->value); + + token->id_kind = C_ID_ID; + if (decl) + { + if (TREE_CODE (decl) == TYPE_DECL) + token->id_kind = C_ID_TYPENAME; + } + else if (c_dialect_objc ()) + { + tree objc_interface_decl = objc_is_class_name (token->value); + /* Objective-C class names are in the same namespace as + variables and typedefs, and hence are shadowed by local + declarations. */ + if (objc_interface_decl) + { + token->value = objc_interface_decl; + token->id_kind = C_ID_CLASSNAME; + } + } + } } token_indent_info next_tinfo |