r183722 - Implement DR85: Redeclaration of member is forbidden
Kim Gräsman
kim.grasman at gmail.com
Wed Jul 3 12:59:52 PDT 2013
David, all,
I have a test for a clang-based tool that ran clean before this
commit, and I now get an unexpected diagnostic due to an intentional
double declaration in the test;
class Foo {
class NoUsage; // Unnecessary -- defined inline later in the class.
class NoUsageDefinedOutOfLine; // Necessary -- part of the public API.
class NoUsageDefinedOutOfLine; // Unnecessary -- second fwd declare.
...
};
Our tool removes duplicate declarations, so we're interested in being
able to process code like this. Now I'm greeted with:
tests\fwd_decl_nested_class.cc:19:9: warning: class member cannot be
redeclared [-Wgnu]
class NoUsageDefinedOutOfLine; // Unnecessary -- second fwd declare.
And this seems to be in the spirit of the fix. But:
1) Is -Wgnu really the right warning group for this? I'm not up to
speed on what -Wgnu means, is it to warn that this is a GNU extension?
2) Should this warning be active for -std=c++98 or only -std=c++11? I
get the diagnostic in both modes.
3) Other compilers (GCC, MSVC) seem to accept it, so I think I want to
keep our current behavior until this is considered illegal by
everyone. Is my best bet just to disable the warning to let Clang Sema
accept this?
Thanks!
- Kim
On Tue, Jun 11, 2013 at 5:51 AM, David Majnemer
<david.majnemer at gmail.com> wrote:
> Author: majnemer
> Date: Mon Jun 10 22:51:23 2013
> New Revision: 183722
>
> URL: http://llvm.org/viewvc/llvm-project?rev=183722&view=rev
> Log:
> Implement DR85: Redeclaration of member is forbidden
>
> Disallow the existence of a declaration of a member class that isn't a
> forward declaration before it's definition.
More information about the cfe-commits
mailing list