https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90126

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  I think this is odd behavior of the warning (not sure what it is
about).  Note you get no warning when you pass -fpreprocessed.  The key
to the diagnostic is that the anonymous namespace appears in a file
(through a #line directive) that is not the same as the file compiled.
Thus, the following testcase warns:

# 1 "t.C"
namespace {
    struct Receiver { int object; };
}
struct Node
{
    Receiver receiverQueue;
    Node() { }
};
int main(int argc, char* argv[]) { return 0; }

> g++ t2.C

note to put the testcase into a file named t2.C, it doesn't warn when
the filename is t.C.  This is because the warning intends to warn about
anonymous namespaces in headers which, when included from multiple sources
may cause issues.

So I think this behaves as intended and you need to compile preprocessed
source with -fpreprocessed (or use t2.ii filenames) or retain the original
filename.  Or disable this particular warning.

Reply via email to