On Thu, Jan 02, 2020 at 10:52:38AM -0500, Nathan Sidwell wrote: > On 12/31/19 6:05 AM, Jakub Jelinek wrote: > > 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 <ja...@redhat.com> > > > > PR c/90677 > > * cp-objcp-common.c (identifier_global_tag): Return NULL_TREE if name > > has not been found, rather than error_mark_node. > > > > ok. I vaguely recall consciously making this change in behaviour, on the > basis that if we were looking for a global binding, it would be an error for > the lookup to fail (either by finding nothing, or because the user made it > ambiguous in some way). But I didn't know about the kind of speculative > lookup you have here.
The speculative lookup is for the format tdiag etc. attributes, we need cgraph_node and gimple structures for the diagnostics, but it is fine if those aren't declared yet (or at all), as long as no format specifier needs those. So, the format attribute handling code just keeps trying to lookup those whenever new format attribute for the GCC specific formats is seen; if we find something that is clearly wrong, we diagnose it and similarly diagnose if the specific format specifier is seen and the needed trees are still not defined. Jakub