[ccache] cache hides compiler warnings about comments
Joel Rosdahl
joel at rosdahl.net
Sun Oct 27 14:25:04 MDT 2013
Hi Akim,
> Compilers such as gcc/clang support -C/-CC to leave comments
> in the preprocessed output. Wouldn't it make sense to use it
> in ccache?
Perhaps yes, but one problem with that is that ccache (currently) can't
assume that the compiler accepts -C/-CC.
Also, there is this caveat in GCC documentation: "You should be prepared
for side effects when using -C; it causes the preprocessor to treat
comments as tokens in their own right. For example, comments appearing at
the start of what would be a directive line have the effect of turning that
line into an ordinary source line, since the first token on the line is no
longer a #."
By the way, a workaround is to set CCACHE_CPP2 when compiling.
-- Joel
On 22 October 2013 15:59, Akim Demaille <akim at lrde.epita.fr> wrote:
> Hi!
>
> Since the comments are removed by the preprocessor, they
> don't make it to the compiler, which in turn cannot make
> warnings about comments.
>
> This source file has issues in genuine code, and in comments:
>
> $ cat foo.cc
> /// \param foo
> static int i;
> int main() {}
>
> The compiler complains about both (-Wdocumentation is really
> all about comments):
>
> $ clang++-mp-3.4 -Wdocumentation -Wunused -c foo.cc
> foo.cc:1:6: warning: '\param' command used in a comment that is not
> attached to a function declaration [-Wdocumentation]
> /// \param foo
> ^~~~~
> foo.cc:1:14: warning: empty paragraph passed to '\param' command
> [-Wdocumentation]
> /// \param foo
> ~~~~~~~~~^
> foo.cc:2:12: warning: unused variable 'i' [-Wunused-variable]
> static int i;
> ^
> 3 warnings generated.
>
> But ccache shows just one kind of issue:
>
> $ ccache clang++-mp-3.4 -Wdocumentation -Wunused -c foo.cc
> foo.cc:2:12: warning: unused variable 'i' [-Wunused-variable]
> static int i;
> ^
> 1 warning generated.
>
> Compilers such as gcc/clang support -C/-CC to leave comments
> in the preprocessed output. Wouldn't it make sense to use it
> in ccache? That would keep such warnings alive:
>
> $ ccache clang++-mp-3.4 -Wdocumentation -Wunused -c -C foo.cc
> clang: warning: argument unused during compilation: '-C'
> foo.cc:1:6: warning: '\param' command used in a comment that is not
> attached to a function declaration [-Wdocumentation]
> /// \param foo
> ^~~~~
> foo.cc:1:14: warning: empty paragraph passed to '\param' command
> [-Wdocumentation]
> /// \param foo
> ~~~~~~~~~^
> foo.cc:2:12: warning: unused variable 'i' [-Wunused-variable]
> static int i;
> ^
> 3 warnings generated.
>
> Thanks!
> _______________________________________________
> ccache mailing list
> ccache at lists.samba.org
> https://lists.samba.org/mailman/listinfo/ccache
>
More information about the ccache
mailing list