diff options
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Interp.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index b755a07..6f277a7 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -641,11 +641,30 @@ static bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr, if (!PtrType.isVolatileQualified()) return true; - const SourceInfo &Loc = S.Current->getSource(OpPC); - if (S.getLangOpts().CPlusPlus) - S.FFDiag(Loc, diag::note_constexpr_access_volatile_type) << AK << PtrType; - else - S.FFDiag(Loc); + if (!S.getLangOpts().CPlusPlus) + return Invalid(S, OpPC); + + const NamedDecl *ND = nullptr; + int DiagKind; + SourceLocation Loc; + if (const auto *F = Ptr.getField()) { + DiagKind = 2; + Loc = F->getLocation(); + ND = F; + } else if (auto *VD = Ptr.getFieldDesc()->asValueDecl()) { + DiagKind = 1; + Loc = VD->getLocation(); + ND = VD; + } else { + DiagKind = 0; + if (const auto *E = Ptr.getFieldDesc()->asExpr()) + Loc = E->getExprLoc(); + } + + S.FFDiag(S.Current->getLocation(OpPC), + diag::note_constexpr_access_volatile_obj, 1) + << AK << DiagKind << ND; + S.Note(Loc, diag::note_constexpr_volatile_here) << DiagKind; return false; } |