Hi!
My PR90677 fix actually made building older GCCs with newer ones worse.
The problem is that identifier_global_value used earlier returned either the
type decl on success or NULL_TREE on failure and the caller in that case
just defers handling it until later, and that is also what the C
identifier_global_tag implementation does, but C++ uses
lookup_qualified_name which returns error_mark_node if not found, rather
than NULL_TREE and the c-format.c caller is unprepared to handle that and
diagnoses error.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
additionally tested by building GCC 8 with unmodified trunk (failed with
In file included from ./config.h:8,
from ../../gcc/gimple-streamer-in.c:22:
../../gcc/../include/ansidecl.h:169:64: error: ‘cgraph_node’ is not defined as
a type
169 | # define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
| ^
...
) and finally building GCC 8 with patched trunk, which succeeded.
Ok for trunk/9.3?
2019-12-31 Jakub Jelinek <[email protected]>
PR c/90677
* cp-objcp-common.c (identifier_global_tag): Return NULL_TREE if name
has not been found, rather than error_mark_node.
* c-c++-common/pr90677-2.c: New test.
--- gcc/cp/cp-objcp-common.c.jj 2019-11-22 22:44:02.124600331 +0100
+++ gcc/cp/cp-objcp-common.c 2019-12-30 18:29:01.386576418 +0100
@@ -354,8 +354,11 @@ identifier_global_value (tree name)
tree
identifier_global_tag (tree name)
{
- return lookup_qualified_name (global_namespace, name, /*prefer_type*/2,
- /*complain*/false);
+ tree ret = lookup_qualified_name (global_namespace, name, /*prefer_type*/2,
+ /*complain*/false);
+ if (ret == error_mark_node)
+ return NULL_TREE;
+ return ret;
}
/* Returns true if NAME refers to a built-in function or function-like
--- gcc/testsuite/c-c++-common/pr90677-2.c.jj 2019-12-30 18:30:50.318911231
+0100
+++ gcc/testsuite/c-c++-common/pr90677-2.c 2019-12-30 18:30:36.303125485
+0100
@@ -0,0 +1,8 @@
+/* PR c/90677 */
+/* { dg-do compile } */
+/* { dg-options "-W -Wall" } */
+
+extern void foo (int, int, const char *, ...)
+ __attribute__ ((__format__ (__gcc_tdiag__, 3, 4)));
+struct cgraph_node;
+extern void bar (struct cgraph_node *);
Jakub