@@ -2934,8 +2934,9 @@ bool Compiler<Emitter>::VisitMaterializeTemporaryExpr(
2934
2934
// For everyhing else, use local variables.
2935
2935
if (SubExprT) {
2936
2936
bool IsConst = SubExpr->getType ().isConstQualified ();
2937
- unsigned LocalIndex =
2938
- allocateLocalPrimitive (E, *SubExprT, IsConst, E->getExtendingDecl ());
2937
+ bool IsVolatile = SubExpr->getType ().isVolatileQualified ();
2938
+ unsigned LocalIndex = allocateLocalPrimitive (
2939
+ E, *SubExprT, IsConst, IsVolatile, E->getExtendingDecl ());
2939
2940
if (!this ->visit (SubExpr))
2940
2941
return false ;
2941
2942
if (!this ->emitSetLocal (*SubExprT, LocalIndex, E))
@@ -4452,6 +4453,9 @@ bool Compiler<Emitter>::visitAssignment(const Expr *LHS, const Expr *RHS,
4452
4453
if (!this ->visit (LHS))
4453
4454
return false ;
4454
4455
4456
+ if (LHS->getType ().isVolatileQualified ())
4457
+ return this ->emitInvalidStore (LHS->getType ().getTypePtr (), E);
4458
+
4455
4459
// We don't support assignments in C.
4456
4460
if (!Ctx.getLangOpts ().CPlusPlus && !this ->emitInvalid (E))
4457
4461
return false ;
@@ -4560,13 +4564,14 @@ bool Compiler<Emitter>::emitConst(const APSInt &Value, const Expr *E) {
4560
4564
4561
4565
template <class Emitter >
4562
4566
unsigned Compiler<Emitter>::allocateLocalPrimitive(
4563
- DeclTy &&Src, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl ,
4564
- ScopeKind SC, bool IsConstexprUnknown) {
4567
+ DeclTy &&Src, PrimType Ty, bool IsConst, bool IsVolatile ,
4568
+ const ValueDecl *ExtendingDecl, ScopeKind SC, bool IsConstexprUnknown) {
4565
4569
// FIXME: There are cases where Src.is<Expr*>() is wrong, e.g.
4566
4570
// (int){12} in C. Consider using Expr::isTemporaryObject() instead
4567
4571
// or isa<MaterializeTemporaryExpr>().
4568
4572
Descriptor *D = P.createDescriptor (Src, Ty, nullptr , Descriptor::InlineDescMD,
4569
- IsConst, isa<const Expr *>(Src));
4573
+ IsConst, isa<const Expr *>(Src),
4574
+ /* IsMutable=*/ false , IsVolatile);
4570
4575
D->IsConstexprUnknown = IsConstexprUnknown;
4571
4576
Scope::Local Local = this ->createLocal (D);
4572
4577
if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast <const Decl *>()))
@@ -4874,7 +4879,8 @@ Compiler<Emitter>::visitVarDecl(const VarDecl *VD, const Expr *Init,
4874
4879
4875
4880
if (VarT) {
4876
4881
unsigned Offset = this ->allocateLocalPrimitive (
4877
- VD, *VarT, VD->getType ().isConstQualified (), nullptr , ScopeKind::Block,
4882
+ VD, *VarT, VD->getType ().isConstQualified (),
4883
+ VD->getType ().isVolatileQualified (), nullptr , ScopeKind::Block,
4878
4884
IsConstexprUnknown);
4879
4885
if (Init) {
4880
4886
// If this is a toplevel declaration, create a scope for the
0 commit comments