public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation
@ 2021-05-06 13:22 burnus at gcc dot gnu.org
2021-05-06 15:07 ` [Bug c/100450] " burnus at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-05-06 13:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
Bug ID: 100450
Summary: Missing ' ' space for '-E' preprocessing output, works
with direct compilation
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
The following code compiles with
-c -fopenmp -Wall test.c
But the output with -E + compilation shows:
warning: ignoring ‘#pragma omp forreduction’ [-Wunknown-pragmas]
as the -E preprocessor outputs:
#pragma omp forreduction(+:red)
instead of the expected
#pragma omp for reduction(+:red)
-----------------^
Testcase:
-----------------------------------
#define TEST(T) { \
{T} \
}
#define CLAUSES reduction(+:red)
#define PARALLEL_FOR(X) TEST({ \
_Pragma("omp for CLAUSES") \
X \
})
void foo()
{
int red = 0;
int A[3] = {};
#pragma omp parallel shared(red)
PARALLEL_FOR( for(int i=0; i < 3; i++) red += A[i]; )
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
@ 2021-05-06 15:07 ` burnus at gcc dot gnu.org
2021-05-06 18:03 ` jakub at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-05-06 15:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Likewise with g++ - nonsurprising as it is common code
in c-ppoutput.c's token_streamer::stream. First called with
token->type == CPP_PRAGMA
fprintf (print.outf, "%s %s", space, name);
is the proper '#pragma omp for'. Then comes a CPP_PADDING followed by CPP_NAME.
There is some 'Subtle logic to output a space if and only if necessary.' at the
top of that file - and that seems to break here.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
2021-05-06 15:07 ` [Bug c/100450] " burnus at gcc dot gnu.org
@ 2021-05-06 18:03 ` jakub at gcc dot gnu.org
2021-05-06 18:31 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-06 18:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think it started with my
https://gcc.gnu.org/legacy-ml/gcc-patches/2008-02/msg01329.html
Before that we weren't expanding those CLAUSES at all during preprocessing,
neither for _Pragma nor for #pragma. But #pragma omp for CLAUSES works fine.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
2021-05-06 15:07 ` [Bug c/100450] " burnus at gcc dot gnu.org
2021-05-06 18:03 ` jakub at gcc dot gnu.org
@ 2021-05-06 18:31 ` jakub at gcc dot gnu.org
2021-05-06 18:36 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-06 18:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Last reconfirmed| |2021-05-06
Ever confirmed|0 |1
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I guess would should in libcpp/lex.c (cpp_avoid_paste) handle
case CPP_PRAGMA: like case CPP_NAME:
cpp_avoid_paste is called only from token_streamer::stream and from Fortran
scan_translation_unit, so I think we should be ok.
What we print for CPP_PRAGMA is always #pragma name or #pragma space name
where name is some identifier.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2021-05-06 18:31 ` jakub at gcc dot gnu.org
@ 2021-05-06 18:36 ` jakub at gcc dot gnu.org
2021-05-07 15:49 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-06 18:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50769
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50769&action=edit
gcc12-pr100450.patch
Untested fix.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
` (3 preceding siblings ...)
2021-05-06 18:36 ` jakub at gcc dot gnu.org
@ 2021-05-07 15:49 ` cvs-commit at gcc dot gnu.org
2021-05-07 16:48 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-07 15:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:170c850e4bd46745e2a5130b5eb09f9fceb98416
commit r12-616-g170c850e4bd46745e2a5130b5eb09f9fceb98416
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri May 7 17:48:37 2021 +0200
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.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
` (4 preceding siblings ...)
2021-05-07 15:49 ` cvs-commit at gcc dot gnu.org
@ 2021-05-07 16:48 ` cvs-commit at gcc dot gnu.org
2021-05-07 17:05 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-07 16:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:8482ed658ca77bfd7fc119cd62afd5b70a024500
commit r11-8371-g8482ed658ca77bfd7fc119cd62afd5b70a024500
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri May 7 17:48:37 2021 +0200
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.
(cherry picked from commit 170c850e4bd46745e2a5130b5eb09f9fceb98416)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
` (5 preceding siblings ...)
2021-05-07 16:48 ` cvs-commit at gcc dot gnu.org
@ 2021-05-07 17:05 ` cvs-commit at gcc dot gnu.org
2021-05-07 17:10 ` cvs-commit at gcc dot gnu.org
2021-05-07 17:11 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-07 17:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:d7c8e6261532e7b2d16221becd5db11ded03e059
commit r10-9810-gd7c8e6261532e7b2d16221becd5db11ded03e059
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri May 7 17:48:37 2021 +0200
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.
(cherry picked from commit 170c850e4bd46745e2a5130b5eb09f9fceb98416)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
` (6 preceding siblings ...)
2021-05-07 17:05 ` cvs-commit at gcc dot gnu.org
@ 2021-05-07 17:10 ` cvs-commit at gcc dot gnu.org
2021-05-07 17:11 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-07 17:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:ec910efa1f70e3903091b23e80c5c554b4db6c9b
commit r9-9521-gec910efa1f70e3903091b23e80c5c554b4db6c9b
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri May 7 17:48:37 2021 +0200
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.
(cherry picked from commit 170c850e4bd46745e2a5130b5eb09f9fceb98416)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/100450] Missing ' ' space for '-E' preprocessing output, works with direct compilation
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
` (7 preceding siblings ...)
2021-05-07 17:10 ` cvs-commit at gcc dot gnu.org
@ 2021-05-07 17:11 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-05-07 17:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100450
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:e2979f8687f590461bef9f87bd997390af67312e
commit r8-10958-ge2979f8687f590461bef9f87bd997390af67312e
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri May 7 17:48:37 2021 +0200
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.
(cherry picked from commit 170c850e4bd46745e2a5130b5eb09f9fceb98416)
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-05-07 17:11 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 13:22 [Bug c/100450] New: Missing ' ' space for '-E' preprocessing output, works with direct compilation burnus at gcc dot gnu.org
2021-05-06 15:07 ` [Bug c/100450] " burnus at gcc dot gnu.org
2021-05-06 18:03 ` jakub at gcc dot gnu.org
2021-05-06 18:31 ` jakub at gcc dot gnu.org
2021-05-06 18:36 ` jakub at gcc dot gnu.org
2021-05-07 15:49 ` cvs-commit at gcc dot gnu.org
2021-05-07 16:48 ` cvs-commit at gcc dot gnu.org
2021-05-07 17:05 ` cvs-commit at gcc dot gnu.org
2021-05-07 17:10 ` cvs-commit at gcc dot gnu.org
2021-05-07 17:11 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).