diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-09 07:26:29 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-09 07:26:29 +0000 |
commit | e6565625f456123ad6eb33c84c8100d8f9411192 (patch) | |
tree | 19e5b6249c83e2f1f50c3181178c0dc4b9558ab0 /clang/test | |
parent | 78360a8184b5e8ffd60b6bc1a51aea2af9c95fc8 (diff) | |
download | bcm5719-llvm-e6565625f456123ad6eb33c84c8100d8f9411192.tar.gz bcm5719-llvm-e6565625f456123ad6eb33c84c8100d8f9411192.zip |
Migrate the mish-mash of declaration checks in
Sema::ActOnUninitializedDecl over to InitializationSequence (with
default initialization), eliminating redundancy. More importantly, we
now check that a const definition in C++ has an initilizer, which was
an #if 0'd code for many, many months. A few other tweaks were needed
to get everything working again:
- Fix all of the places in the testsuite where we defined const
objects without initializers (now that we diagnose this issue)
- Teach instantiation of static data members to find the previous
declaration, so that we build proper redeclaration
chains. Previously, we had the redeclaration chain but built it
too late to be useful, because...
- Teach instantiation of static data member definitions not to try
to check an initializer if a previous declaration already had an
initializer. This makes sure that we don't complain about static
const data members with in-class initializers and out-of-line
definitions.
- Move all of the incomplete-type checking logic out of
Sema::FinalizeDeclaratorGroup; it makes more sense in
ActOnUnitializedDecl.
There may still be a few places where we can improve these
diagnostics. I'll address that as a separate commit.
llvm-svn: 95657
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CXX/dcl.decl/dcl.init/p6.cpp | 2 | ||||
-rw-r--r-- | clang/test/CXX/expr/p8.cpp | 2 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp | 2 | ||||
-rw-r--r-- | clang/test/Sema/incomplete-decl.c | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/cast-conversion.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/dcl_ambig_res.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaTemplate/instantiate-declref-ice.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaTemplate/instantiate-expr-4.cpp | 4 |
8 files changed, 9 insertions, 11 deletions
diff --git a/clang/test/CXX/dcl.decl/dcl.init/p6.cpp b/clang/test/CXX/dcl.decl/dcl.init/p6.cpp index 370bafcfbd5..f627a199eca 100644 --- a/clang/test/CXX/dcl.decl/dcl.init/p6.cpp +++ b/clang/test/CXX/dcl.decl/dcl.init/p6.cpp @@ -11,5 +11,5 @@ struct HasUserDefault { HasUserDefault(); }; void test_const_default_init() { const NoUserDefault x1; // expected-error{{default initialization of an object of const type 'struct NoUserDefault const' requires a user-provided default constructor}} const HasUserDefault x2; - const int x3; // FIXME: xpected-error{{default initialization of an object of const type 'struct NoUserDefault const' requires a user-provided default constructor}} + const int x3; // expected-error{{default initialization of an object of const type 'int const'}} } diff --git a/clang/test/CXX/expr/p8.cpp b/clang/test/CXX/expr/p8.cpp index cc834d9dc8d..2f6c094301e 100644 --- a/clang/test/CXX/expr/p8.cpp +++ b/clang/test/CXX/expr/p8.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s int a0; -const volatile int a1; +const volatile int a1 = 2; int a2[16]; int a3(); diff --git a/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp index 098ffa4dec7..b0078d4bdb6 100644 --- a/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp @@ -55,7 +55,7 @@ template double Foo::As2(); // Partial ordering with conversion function templates. struct X0 { template<typename T> operator T*() { - T x; + T x = 1; x = 17; // expected-error{{read-only variable is not assignable}} } diff --git a/clang/test/Sema/incomplete-decl.c b/clang/test/Sema/incomplete-decl.c index 753d9c0a3c1..e5b6d5f0da6 100644 --- a/clang/test/Sema/incomplete-decl.c +++ b/clang/test/Sema/incomplete-decl.c @@ -16,7 +16,7 @@ int ary[]; // expected-warning {{tentative array definition assumed to have one struct foo bary[]; // expected-error {{array has incomplete element type 'struct foo'}} void func() { - int ary[]; // expected-error{{variable has incomplete type 'int []'}} + int ary[]; // expected-error{{definition of variable with array type needs an explicit size or an initializer}} void b; // expected-error {{variable has incomplete type 'void'}} struct foo f; // expected-error {{variable has incomplete type 'struct foo'}} } diff --git a/clang/test/SemaCXX/cast-conversion.cpp b/clang/test/SemaCXX/cast-conversion.cpp index 77f4a528906..074e1330403 100644 --- a/clang/test/SemaCXX/cast-conversion.cpp +++ b/clang/test/SemaCXX/cast-conversion.cpp @@ -30,7 +30,7 @@ X0<T> make_X0(const T &Val) { } void test_X0() { - const char array[2]; + const char array[2] = { 'a', 'b' }; make_X0(array); } diff --git a/clang/test/SemaCXX/dcl_ambig_res.cpp b/clang/test/SemaCXX/dcl_ambig_res.cpp index 859d2045da0..f0ba2978e8d 100644 --- a/clang/test/SemaCXX/dcl_ambig_res.cpp +++ b/clang/test/SemaCXX/dcl_ambig_res.cpp @@ -12,8 +12,8 @@ void foo(double a) { S w(int(a)); // expected-warning{{disambiguated}} w(17); - S x(int()); // expected-warning{{disambiguated}} - x(&returns_an_int); + S x1(int()); // expected-warning{{disambiguated}} + x1(&returns_an_int); S y((int)a); y.bar(); S z = int(a); diff --git a/clang/test/SemaTemplate/instantiate-declref-ice.cpp b/clang/test/SemaTemplate/instantiate-declref-ice.cpp index e4e071dd20d..e88b49447cb 100644 --- a/clang/test/SemaTemplate/instantiate-declref-ice.cpp +++ b/clang/test/SemaTemplate/instantiate-declref-ice.cpp @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s - template<int i> struct x { static const int j = i; x<j>* y; @@ -10,7 +9,6 @@ const int x<i>::j; int array0[x<2>::j]; - template<typename T> struct X0 { static const unsigned value = sizeof(T); diff --git a/clang/test/SemaTemplate/instantiate-expr-4.cpp b/clang/test/SemaTemplate/instantiate-expr-4.cpp index b5ffa4b39b2..c5eb3cc53e7 100644 --- a/clang/test/SemaTemplate/instantiate-expr-4.cpp +++ b/clang/test/SemaTemplate/instantiate-expr-4.cpp @@ -173,8 +173,8 @@ struct is_pod { static const bool value = __is_pod(T); }; -static const int is_pod0[is_pod<X>::value? -1 : 1]; -static const int is_pod1[is_pod<Y>::value? 1 : -1]; +static int is_pod0[is_pod<X>::value? -1 : 1]; +static int is_pod1[is_pod<Y>::value? 1 : -1]; // --------------------------------------------------------------------- // initializer lists |