/* Fall through for fields that aren't bitfields. */
gcc_fallthrough ();
- case FUNCTION_DECL:
case VAR_DECL:
+ if (is_capture_proxy (expr))
+ {
+ if (is_normal_capture_proxy (expr))
+ {
+ expr = DECL_CAPTURED_VARIABLE (expr);
+ type = TREE_TYPE (expr);
+ type = non_reference (type);
+ }
+ else
+ {
+ expr = DECL_VALUE_EXPR (expr);
+ gcc_assert (TREE_CODE (expr) == COMPONENT_REF);
+ expr = TREE_OPERAND (expr, 1);
+ type = TREE_TYPE (expr);
+ }
+ break;
+ }
+ /* Fall through for variables that aren't capture proxies. */
+ gcc_fallthrough ();
+
+ case FUNCTION_DECL:
case CONST_DECL:
case PARM_DECL:
case RESULT_DECL:
--- /dev/null
+// PR c++/96917
+// { dg-do compile { target c++14 } }
+
+int main() {
+ int x = 0;
+ int y = 0;
+ const int cx = 0;
+ const int cy = 0;
+
+ [x, &y, cx, &cy] {
+ decltype(auto) a = x;
+ using ty1 = int;
+ using ty1 = decltype(x);
+ using ty1 = decltype(a);
+
+ decltype(auto) b = y;
+ using ty2 = int;
+ using ty2 = decltype(y);
+ using ty2 = decltype(b);
+
+ decltype(auto) ca = cx;
+ using ty3 = const int;
+ using ty3 = decltype(cx);
+ using ty3 = decltype(ca);
+
+ decltype(auto) cb = cy;
+ using ty4 = const int;
+ using ty4 = decltype(cy);
+ using ty4 = decltype(cb);
+ };
+
+ [x=x, &y=y, cx=cx, &cy=cy] {
+ decltype(auto) a = x;
+ using ty1 = int;
+ using ty1 = decltype(x);
+ using ty1 = decltype(a);
+
+ decltype(auto) b = y;
+ using ty2 = int&;
+ using ty2 = decltype(y);
+ using ty2 = decltype(b);
+
+ decltype(auto) ca = cx;
+ using ty3 = int;
+ using ty3 = decltype(cx);
+ using ty3 = decltype(ca);
+
+ decltype(auto) cb = cy;
+ using ty4 = const int&;
+ using ty4 = decltype(cy);
+ using ty4 = decltype(cb);
+ };
+}
--- /dev/null
+// PR c++/79378
+// { dg-do compile { target c++14 } }
+
+int main() {
+ int x = 0;
+ [x=x, &r=x] {
+ using ty1 = int;
+ using ty1 = decltype(x);
+
+ using ty2 = int&;
+ using ty2 = decltype(r);
+ };
+
+ const int cx = 0;
+ [x=cx, &r=cx] {
+ using ty1 = int;
+ using ty1 = decltype(x);
+
+ using ty2 = const int&;
+ using ty2 = decltype(r);
+ };
+}