diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-09 03:29:58 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-09 03:29:58 +0000 |
commit | b4e5e286a5cd156247720b1eb204abaa8e09568d (patch) | |
tree | c7d19ed16dffe977973cb5c69ef9815c580d4672 /lib/AST/ExprConstant.cpp | |
parent | 0ca7e8bf904d1c2cf70d271f3a06c1d71ff7e4fb (diff) |
CWG issue 1405: mutable members are allowed in literal types, but can't undergo
lvalue-to-rvalue conversions in constant expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150145 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 48e0c6f7da..e43884e376 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -1453,6 +1453,13 @@ static bool ExtractSubobject(EvalInfo &Info, const Expr *E, O = &O->getArrayFiller(); ObjType = CAT->getElementType(); } else if (const FieldDecl *Field = getAsField(Sub.Entries[I])) { + if (Field->isMutable()) { + Info.Diag(E->getExprLoc(), diag::note_constexpr_ltor_mutable, 1) + << Field; + Info.Note(Field->getLocation(), diag::note_declared_at); + return false; + } + // Next subobject is a class, struct or union field. RecordDecl *RD = ObjType->castAs<RecordType>()->getDecl(); if (RD->isUnion()) { |