[PATCH] [Parse] Allow 'constexpr' in condition declarations

Meador Inge meadori at gmail.com
Tue May 5 10:13:27 PDT 2015


================
Comment at: include/clang/Parse/Parser.h:1689
@@ -1689,1 +1688,3 @@
+    DSC_template_type_arg, // template type argument context
+    DSC_constexpr // constexpr declaration context
   };
----------------
rsmith wrote:
> I think this should be called `DSC_condition`?
Agreed.  Will fix.

================
Comment at: lib/Sema/SemaExprCXX.cpp:2586-2589
@@ -2585,3 +2585,6 @@
 
-  return Condition;
+  return ActOnFinishFullExpr(Condition.get(),
+                             Condition.get()->getExprLoc(),
+                             false, /* DiscardedValue */
+                             Condition.get()->isCXX11ConstantExpr(Context));
 }
----------------
rsmith wrote:
> For the switch condition case, additional conversion will be performed on the result of this function; you should delay the `ActOnFinishFullExpr` until after those conversions in that case.
Ah, thank you for pointing that out (again; sorry I missed the suggestion before :-) ).  I suppose this new call to `ActOnFinishFullExpr` can just happen for `ConvertToBoolean` since `ActOnStartOfSwitchStmt` already has a call to `ActOnFinishFullExpr` after the said conversions happen.

This is the easiest thing to do now.  After this patch is committed I think there is a potential refactoring to consolidate the check and conversion logic for if, for, switch, and while so that there is only one call to `ActOnFinishFullExpr`.

http://reviews.llvm.org/D8978

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






More information about the cfe-commits mailing list