Opening up in **constexpr** s in conditions allows "maybe" odr used expression 
to be collected in cases like:

  class T {
  public:
     constexpr T(int v) : v(v) { }
     constexpr operator int() const { return v; }
  private:
     int v;
  };
  
  int main() {
     if (constexpr T x = 200) { }
  }

Without the cleanup the following assert fires:

  (MaybeODRUseExprs.empty() && "Leftover expressions for odr-use checking"), 
function ActOnFinishFunctionBody, file 
/Users/meadori/Code/source/llvm/tools/clang/lib/Sema/SemaDecl.cpp, line 10820.

**MaybeODRUseExprs** is populated in **DoMarkVarDeclReferenced** from 
**SemaExpr.cpp** (the end of the function does an explicit check for constant 
expressions).  I don't think this situation could ever happen for conditional 
declarations before, but know it can and we need the new cleanup.


================
Comment at: include/clang/Parse/Parser.h:1760
@@ -1760,1 +1759,3 @@
+                                   DeclSpecContext DSC = DSC_normal,
+                                   bool AllowConstexprs = false);
 
----------------
rsmith wrote:
> Please add a new DSC value for conditions rather than adding a flag here.
Will fix.

================
Comment at: lib/Sema/SemaExprCXX.cpp:2585
@@ -2584,1 +2584,3 @@
 
+  Condition = MaybeCreateExprWithCleanups(Condition.get());
+
----------------
rsmith wrote:
> Do your tests cover the need for this?
Not yet, but I will add a test for it.

================
Comment at: test/CXX/stmt.stmt/stmt.select/p6.cpp:4-5
@@ +3,4 @@
+
+// This test verifies the functionality specified by DR948:
+// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#948
+
----------------
rsmith wrote:
> The right place for such a test is tests/CXX/drs/dr9xx.cpp.
Will fix.

http://reviews.llvm.org/D8978

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/



_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to