Make the odr-use logic work correctly for constant-expressions. PR12006.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151699 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 30a02b2..5a2b2dc 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -10023,6 +10023,18 @@
MaybeODRUseExprs.erase(E->IgnoreParens());
}
+ExprResult Sema::ActOnConstantExpression(ExprResult Res) {
+ if (!Res.isUsable())
+ return Res;
+
+ // If a constant-expression is a reference to a variable where we delay
+ // deciding whether it is an odr-use, just assume we will apply the
+ // lvalue-to-rvalue conversion. In the one case where this doesn't happen
+ // (a non-type template argument), we have special handling anyway.
+ UpdateMarkingForLValueToRValue(Res.get());
+ return Res;
+}
+
void Sema::CleanupVarDeclMarking() {
for (llvm::SmallPtrSetIterator<Expr*> i = MaybeODRUseExprs.begin(),
e = MaybeODRUseExprs.end();