After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 624199 - parser picks up contents of large macros
parser picks up contents of large macros
Status: RESOLVED FIXED
Product: gtk-doc
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: 1.16
Assigned To: gtk-doc maintainers
gtk-doc maintainers
Depends on:
Blocks:
 
 
Reported: 2010-07-12 21:30 UTC by Allison Karlitskaya (desrt)
Modified: 2010-07-13 13:13 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Allison Karlitskaya (desrt) 2010-07-12 21:30:10 UTC
gmem.h in glib has this macro:

#  define _G_NEW(struct_type, n_structs, func) \
        (struct_type *) (__extension__ ({                       \
          gsize __n = (gsize) (n_structs);                      \
          gsize __s = sizeof (struct_type);                     \
          gpointer __p;                                         \
          if (__s == 1)                                         \
            __p = g_##func (__n);                               \
          else if (__builtin_constant_p (__n) &&                \
                   (__s == 0 || __n <= G_MAXSIZE / __s))        \
            __p = g_##func (__n * __s);                         \
          else                                                  \
            __p = g_##func##_n (__n, __s);                      \
          __p;                                                  \
        }))


the parser is grabbing:

          else if (__builtin_constant_p (__n) &&
                   (__s == 0 || __n <= G_MAXSIZE / __s))

as if it were a function called "if" that returns "else".
Comment 1 Allison Karlitskaya (desrt) 2010-07-12 21:44:45 UTC
more in gobject too:

#  define _G_TYPE_CIT(ip, gt)             (G_GNUC_EXTENSION ({ \
  GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \
  if (!__inst) \
    __r = FALSE; \
  else if (__inst->g_class && __inst->g_class->g_type == __t) \
    __r = TRUE; \
  else \
    __r = g_type_check_instance_is_a (__inst, __t); \
  __r; \
}))
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2010-07-13 13:13:24 UTC
commit 364ba12a0b147f8b0186c970efeb786e36c2879a
Author: Stefan Kost <ensonic@users.sf.net>
Date:   Tue Jul 13 16:06:28 2010 +0300

    scan: correctly skip internal macros. Fixes #624199
    
    If we come across an internal macro (starting with a '_') we still need to read
    over it to not confuse the macro body with new declarations. Add a test.