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
llvm-svn: 195306
25 lines
817 B
C++
25 lines
817 B
C++
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
struct InClassInitializerOnly {
|
|
static const int i = 0;
|
|
};
|
|
int const InClassInitializerOnly::i;
|
|
|
|
struct OutOfClassInitializerOnly {
|
|
static const int i;
|
|
};
|
|
int const OutOfClassInitializerOnly::i = 0;
|
|
|
|
struct InClassInitializerAndOutOfClassCopyInitializer {
|
|
static const int i = 0; // expected-note{{previous initialization is here}}
|
|
};
|
|
int const InClassInitializerAndOutOfClassCopyInitializer::i = 0; // expected-error{{static data member 'i' already has an initializer}}
|
|
|
|
struct InClassInitializerAndOutOfClassDirectInitializer {
|
|
static const int i = 0; // expected-note{{previous initialization is here}}
|
|
};
|
|
int const InClassInitializerAndOutOfClassDirectInitializer::i(0); // expected-error{{static data member 'i' already has an initializer}}
|
|
|
|
|
|
int main() { }
|
|
|