[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 Eric Gallager changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=105963 --- Comment #18 from Eric Gallager --- Another bug about the underliner printing excess output: bug 105963
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #17 from David Malcolm --- One aspect of the original case in comment #0 that hasn't been mentioned in this discussion is that the two #warning messages are related to each other. It looks to me like the author of those lines intended for them to emit a block of related text, but the source-printing gets in the way of this and makes the connection between the two messages less clear. I'm not sure what the best approach here is though.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #16 from Andreas Schwab --- There is no difference between these cases. GCC will always show the source lines that are available. Of course, it will never pull anything out of thin air, but that is obvious.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #15 from eggert at cs dot ucla.edu --- (In reply to Andreas Schwab from comment #14) > I don't follow. It works exactly the same way. Let me try to explain further. In my comment #11, the first directive: #warning "You are too close to the curb" generates this diagnostic: In file included from foo.c:1: bar.h:1:2: warning: #warning "You are too close to the curb" [-Wcpp] 1 | #warning "You are too close to the curb" | ^~~ which contains "You are too close to the curb" twice. In contrast, the second directive #warning "Tomorrow is the deadline for paying taxes" generates only this diagnostic: In file included from foo.c:1: baz.h:100:2: warning: #warning "Tomorrow is the deadline for paying taxes" [-Wcpp] and this contains "Tomorrow is the deadline for paying taxes" only once, which is the win I'm suggesting. GCC treats the two #warning directives differently, and does so because of the intervening #line directive.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #14 from Andreas Schwab --- I don't follow. It works exactly the same way.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #13 from eggert at cs dot ucla.edu --- (In reply to Andreas Schwab from comment #12) > > GCC already treats that case differently > > In which way? A "#line" directive suppresses most of the duplication in later #warning diagnostics, as illustrated in my previous comment.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #12 from Andreas Schwab --- > GCC already treats that case differently In which way?
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #11 from eggert at cs dot ucla.edu --- (In reply to Andreas Schwab from comment #10) > See the #line directive. GCC already treats that case differently, and it can continue to do so. Come to think of it, GCC works better with #line than it does without. GCC should treat the ordinary case more like it already treats the #line case, except that GCC shouldn't say "warning" twice of course (it sounds like an old episode of "Lost in Space" :-). :: foo.c :: #include "bar.h" :: bar.h :: #warning "You are too close to the curb" #line 100 "baz.h" #warning "Tomorrow is the deadline for paying taxes" $ gcc -S foo.c In file included from foo.c:1: bar.h:1:2: warning: #warning "You are too close to the curb" [-Wcpp] 1 | #warning "You are too close to the curb" | ^~~ In file included from foo.c:1: baz.h:100:2: warning: #warning "Tomorrow is the deadline for paying taxes" [-Wcpp]
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #10 from Andreas Schwab --- See the #line directive.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #9 from eggert at cs dot ucla.edu --- (In reply to Andreas Schwab from comment #8) > That still doesn't handle the case when the source comes from a different > place. I don't know what you mean by "source comes from a different place". However, whatever that situation is, surely GCC could detect it and behave as it does now, even while it handles the typical case more nicely as I've been suggesting.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #8 from Andreas Schwab --- That still doesn't handle the case when the source comes from a different place.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #7 from eggert at cs dot ucla.edu --- (In reply to Andreas Schwab from comment #5 and #6) > There can be comments > Also, the source may come from a different place than the directive. For the unusual case where the #warning line invokes preprocessor macros defined elsewhere, it would be OK to output the warning both before and after preprocessing (to help with debugging the warning machinery, presumably). (Comments might cause something similar, I suppose, though that's less important.) However, for the case that I mentioned where the #warning line just contains a string, the duplicate messages are confusing and redundant, and the duplication should be avoided in this more-typical case.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #6 from Andreas Schwab --- Also, the source may come from a different place than the directive.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #5 from Andreas Schwab --- > For '#warning "xxx"' they're the same That is not true. There can be comments.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 Richard Biener changed: What|Removed |Added Ever confirmed|0 |1 Last reconfirmed||2020-11-27 CC||dmalcolm at gcc dot gnu.org Status|UNCONFIRMED |NEW --- Comment #4 from Richard Biener --- Confirmed.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 Eric Gallager changed: What|Removed |Added CC||egallager at gcc dot gnu.org Keywords||diagnostic --- Comment #3 from Eric Gallager --- I think there is another bug open about this, but I can't seem to find it right now...
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #2 from eggert at cs dot ucla.edu --- (In reply to Andrew Pinski from comment #1) > so you are asking not to show the source file for #warning ? That's the possibility I suggested, yes. Another possibility would be to not show the diagnostic, and just show the source file. The point is to avoid the duplication. > I don't see why this warning should be treated as any different from any > other warning. In other warnings, it's useful to show both the diagnostic and the source code line because they're different. For '#warning "xxx"' they're the same so there's no point to showing both and there is a downside that the output is redundant and confusing.
[Bug preprocessor/98021] #warning issues redundant diagnostic lines
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98021 --- Comment #1 from Andrew Pinski --- so you are asking not to show the source file for #warning ? I don't see why this warning should be treated as any different from any other warning.
