]> granicus.if.org Git - clang/commit
Provide better diagnostic wording for initializers on static
authorHans Wennborg <hans@hanshq.net>
Thu, 21 Nov 2013 03:17:44 +0000 (03:17 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 21 Nov 2013 03:17:44 +0000 (03:17 +0000)
commite5814317b4022b90279ccb5e0164e9282353564e
treefc130a7d8f7dcefe1e73e2716e2a7f3caacd7e86
parent891be43ecfe67666aebd39922c1fa77149152121
Provide better diagnostic wording for initializers on static
data member definitions when the variable has an initializer
in its declaration.

For the following code:

  struct S {
    static const int x = 42;
  };
  const int S::x = 42;

This patch changes the diagnostic from:

  a.cc:4:14: error: redefinition of 'x'
  const int S::x = 42;
               ^
  a.cc:2:20: note: previous definition is here
    static const int x = 42;
                     ^
to:

  a.cc:4:18: error: static data member 'x' already has an initializer
  const int S::x = 42;
                   ^
  a.cc:2:24: note: previous initialization is here
    static const int x = 42;
                         ^

Differential Revision: http://llvm-reviews.chandlerc.com/D2235

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195306 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDecl.cpp
test/CXX/class/class.static/class.static.data/p4.cpp
test/CXX/drs/dr0xx.cpp
test/SemaCXX/cxx1y-variable-templates_in_class.cpp