This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix #pragma mark on Darwin
- From: gkeating at apple dot com (Geoffrey Keating)
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 8 Oct 2007 11:02:04 -0700 (PDT)
- Subject: fix #pragma mark on Darwin
This patch fixes some regressions involving #pragma mark.
Unlike all other pragmas that GCC implements, it's allowed to put
#pragma mark after an 'else'. Fortunately the pragma is supposed to
be ignored, so we can just strip it out at cpp time rather than
converting it to C tokens. This also permits users to use it with
any pp-tokens, which was also historically allowed.
The weird UTF-8 characters in the testcase are bullets.
Bootstrapped & tested on powerpc-darwin8.
--
- Geoffrey Keating <geoffk@apple.com>
===File ~/patches/gcc-5497482.patch=========================
Index: gcc/ChangeLog
2007-10-07 Geoffrey Keating <geoffk@apple.com>
* config/darwin.h (DARWIN_REGISTER_TARGET_PRAGMAS): Register
'#pragma mark' to be executed at preprocessing time.
Index: gcc/testsuite/ChangeLog
2007-10-07 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/pragma-darwin-2.c: New.
Index: gcc/testsuite/gcc.dg/pragma-darwin-2.c
===================================================================
--- gcc/testsuite/gcc.dg/pragma-darwin-2.c (revision 0)
+++ gcc/testsuite/gcc.dg/pragma-darwin-2.c (revision 0)
@@ -0,0 +1,24 @@
+/* Darwin (Mac OS X) pragma exercises. */
+
+/* { dg-do compile { target *-*-darwin* } } */
+
+/* The mark pragma is valid at any point in the program. Fortunately
+ the compiler only needs to ignore it. It's also followed only
+ by pp-tokens, not necessarily real C tokens. */
+
+void foo(void)
+{
+ if (1) {
+ ;
+ }
+ else if (1) {
+ ;
+ }
+#pragma mark "last case" "hi"
+ else if (1) {
+ ;
+ }
+}
+
+#pragma mark 802.11x 1_2_3
+#pragma mark ââââ marker ââââ
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h (revision 128879)
+++ gcc/config/darwin.h (working copy)
@@ -892,7 +892,8 @@
#define DARWIN_REGISTER_TARGET_PRAGMAS() \
do { \
- c_register_pragma (0, "mark", darwin_pragma_ignore); \
+ cpp_register_pragma (parse_in, NULL, "mark", \
+ darwin_pragma_ignore, false); \
c_register_pragma (0, "options", darwin_pragma_options); \
c_register_pragma (0, "segment", darwin_pragma_ignore); \
c_register_pragma (0, "unused", darwin_pragma_unused); \
============================================================