aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-05-07 17:48:37 +0200
committerJakub Jelinek <jakub@redhat.com>2021-05-07 17:48:37 +0200
commit170c850e4bd46745e2a5130b5eb09f9fceb98416 (patch)
treecc92339a9d553a6a8959bb4753d0af19841ce53e /libcpp
parent5795ec0edc30e077a9900cf3ca0a04ad8ac5ac97 (diff)
downloadgcc-170c850e4bd46745e2a5130b5eb09f9fceb98416.zip
gcc-170c850e4bd46745e2a5130b5eb09f9fceb98416.tar.gz
gcc-170c850e4bd46745e2a5130b5eb09f9fceb98416.tar.bz2
libcpp: Fix up pragma preprocessing [PR100450]
Since the r0-85991-ga25a8f3be322fe0f838947b679f73d6efc2a412c https://gcc.gnu.org/legacy-ml/gcc-patches/2008-02/msg01329.html changes, so that we handle macros inside of pragmas that should expand macros, during preprocessing we print those pragmas token by token, with CPP_PRAGMA printed as fputs ("#pragma ", print.outf); if (space) fprintf (print.outf, "%s %s", space, name); else fprintf (print.outf, "%s", name); where name is some identifier (so e.g. print #pragma omp parallel or #pragma omp for etc.). Because it ends in an identifier, we need to handle it like an identifier (i.e. CPP_NAME) for the decision whether a space needs to be emitted in between that #pragma whatever or #pragma whatever whatever and following token, otherwise the attached testcase is preprocessed as #pragma omp forreduction(+:red) rather than #pragma omp for reduction(+:red) The cpp_avoid_paste function is only called for this purpose. 2021-05-07 Jakub Jelinek <jakub@redhat.com> PR c/100450 * lex.c (cpp_avoid_paste): Handle token1 CPP_PRAGMA like CPP_NAME. * c-c++-common/gomp/pr100450.c: New test.
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/lex.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 9662f1b..b7ce85a 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -3719,6 +3719,7 @@ cpp_avoid_paste (cpp_reader *pfile, const cpp_token *token1,
case CPP_DEREF: return c == '*';
case CPP_DOT: return c == '.' || c == '%' || b == CPP_NUMBER;
case CPP_HASH: return c == '#' || c == '%'; /* Digraph form. */
+ case CPP_PRAGMA:
case CPP_NAME: return ((b == CPP_NUMBER
&& name_p (pfile, &token2->val.str))
|| b == CPP_NAME