aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-09 23:58:28 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-09 23:58:28 +0000
commitf8d8d1a99b802b8e9f2e7da441b64096b89f133d (patch)
tree4821d4f5b46557143c4762922936633ed46915a7
parent9cd9f3f55d22f34f1d69db8bfc2735c4e1e082c3 (diff)
Don't bother to perform any initialization for a variable declaration
of class type whose default constructor is trivial. Should un-break testing on x86_64-pc-linux-gnu. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81405 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDecl.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 9bd89ef270..65516f2c29 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -3283,6 +3283,8 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
// thereof), the object shall be default-initialized; if the
// object is of const-qualified type, the underlying class type
// shall have a user-declared default constructor.
+ //
+ // FIXME: Diagnose the "user-declared default constructor" bit.
if (getLangOptions().CPlusPlus) {
QualType InitType = Type;
if (const ArrayType *Array = Context.getAsArrayType(Type))
@@ -3303,12 +3305,18 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl,
IK_Default,
ConstructorArgs);
- if (!Constructor ||
- InitializeVarWithConstructor(Var, Constructor, InitType,
- move_arg(ConstructorArgs)))
+ // FIXME: Location info for the variable initialization?
+ if (!Constructor)
Var->setInvalidDecl();
- else
+ else {
+ // FIXME: Cope with initialization of arrays
+ if (!Constructor->isTrivial() &&
+ InitializeVarWithConstructor(Var, Constructor, InitType,
+ move_arg(ConstructorArgs)))
+ Var->setInvalidDecl();
+
FinalizeVarWithDestructor(Var, InitType);
+ }
}
}
}