diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-01-31 09:12:51 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-01-31 09:12:51 +0000 |
commit | 9db7dbb918ca49f4ee6c181e4917e7b6ec547353 (patch) | |
tree | ca2970a7b2115f226131005dc0c162108fc18720 /test/SemaCXX/constructor-initializer.cpp | |
parent | a05315436746963c4034555ca725956507e14553 (diff) |
Rework base and member initialization in constructors, with several
(necessarily simultaneous) changes:
- CXXBaseOrMemberInitializer now contains only a single initializer
rather than a set of initialiation arguments + a constructor. The
single initializer covers all aspects of initialization, including
constructor calls as necessary but also cleanup of temporaries
created by the initializer (which we never handled
before!).
- Rework + simplify code generation for CXXBaseOrMemberInitializers,
since we can now just emit the initializer as an initializer.
- Switched base and member initialization over to the new
initialization code (InitializationSequence), so that it
- Improved diagnostics for the new initialization code when
initializing bases and members, to match the diagnostics produced
by the previous (special-purpose) code.
- Simplify the representation of type-checked constructor initializers in
templates; instead of keeping the fully-type-checked AST, which is
rather hard to undo at template instantiation time, throw away the
type-checked AST and store the raw expressions in the AST. This
simplifies instantiation, but loses a little but of information in
the AST.
- When type-checking implicit base or member initializers within a
dependent context, don't add the generated initializers into the
AST, because they'll look like they were explicit.
- Record in CXXConstructExpr when the constructor call is to
initialize a base class, so that CodeGen does not have to infer it
from context. This ensures that we call the right kind of
constructor.
There are also a few "opportunity" fixes here that were needed to not
regress, for example:
- Diagnose default-initialization of a const-qualified class that
does not have a user-declared default constructor. We had this
diagnostic specifically for bases and members, but missed it for
variables. That's fixed now.
- When defining the implicit constructors, destructor, and
copy-assignment operator, set the CurContext to that constructor
when we're defining the body.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94952 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/constructor-initializer.cpp')
-rw-r--r-- | test/SemaCXX/constructor-initializer.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp index 53f057ed0f..2efb7b9c21 100644 --- a/test/SemaCXX/constructor-initializer.cpp +++ b/test/SemaCXX/constructor-initializer.cpp @@ -104,8 +104,8 @@ struct M { // expected-note 2 {{candidate constructor (the implicit }; struct N : M { - N() : M(1), // expected-error {{no matching constructor for initialization of 'M'}} - m1(100) { } // expected-error {{no matching constructor for initialization of 'm1'}} + N() : M(1), // expected-error {{no matching constructor for initialization of 'struct M'}} + m1(100) { } // expected-error {{no matching constructor for initialization of 'struct M'}} M m1; }; @@ -116,8 +116,8 @@ struct P : M { }; struct Q { - Q() : f1(1,2), // expected-error {{Too many arguments for member initializer 'f1'}} - pf(0.0) { } // expected-error {{incompatible type passing 'double', expected 'float *'}} + Q() : f1(1,2), // expected-error {{excess elements in scalar initializer}} + pf(0.0) { } // expected-error {{cannot initialize a member subobject of type 'float *' with an rvalue of type 'double'}} float f1; float *pf; |