[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#715271: Preprocessor now handles _Pragma less badly



I've recently upgraded to stretch (from wheezy), and I thought I'd look
to see whether my compiler bugs have been fixed.  This one is half
fixed.  Specifically, the integrated preprocessor now seems to work the
same way as the separate one, so the second example program, which I
named `pragbug2.c', now seems to be handled correctly.

Alas, the first program is still handled wrongly: the `diagnostic
ignored' pragma somehow escapes the push/pop sandwich it's supposed to
be in.

[stratocaster /tmp/mdw]cat pragbug1.c
#include <stdio.h>

#define PRAGMA(x) _Pragma(#x)

#define WARNING(warn) PRAGMA(GCC diagnostic ignored warn)

#define SANDWICH(warns, filling)					\
  _Pragma("GCC diagnostic push")                                        \
  warns									\
  filling								\
  _Pragma("GCC diagnostic pop")

#define CHECK(cond) __extension__ ({					\
  SANDWICH(WARNING("-Waddress"), !!(cond); )				\
})

#define WRAP(x) x

int main(void)
{
  int y = 0;
  if (CHECK(&y)) puts("Hello, world!");
  return (0);
}
[stratocaster /tmp/mdw]gcc -E -o- pragbug1.c
...
# 19 "pragbug1.c"
int main(void)
{
  int y = 0;
  if (__extension__ ({
# 22 "pragbug1.c"
#pragma GCC diagnostic ignored "-Waddress"
# 22 "pragbug1.c"
 
# 22 "pragbug1.c"
#pragma GCC diagnostic push
# 22 "pragbug1.c"
  !!(&y);
# 22 "pragbug1.c"
#pragma GCC diagnostic pop
# 22 "pragbug1.c"
  })) puts("Hello, world!");
  return (0);
}
[stratocaster /tmp/mdw]

-- [mdw]


Reply to: