re PR c++/84125 (ICE in generic lambda when static_assert argument is implicitly...
authorMarek Polacek <polacek@redhat.com>
Thu, 1 Feb 2018 20:32:33 +0000 (20:32 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 1 Feb 2018 20:32:33 +0000 (20:32 +0000)
PR c++/84125
* typeck.c (build_address): Relax the assert when
processing_template_decl.

* g++.dg/cpp1y/lambda-generic-84125.C:New test.

From-SVN: r257311

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/lambda-generic-84125.C [new file with mode: 0644]

index 897774e43f7a21b3cf2d205143c76548137f4cea..5b6c75a83f55023a58eac951e15359cc0bc1dd46 100644 (file)
@@ -1,3 +1,9 @@
+2018-02-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/84125
+       * typeck.c (build_address): Relax the assert when
+       processing_template_decl.
+
 2018-02-01  Jason Merrill  <jason@redhat.com>
 
        PR c++/84126 - ICE with variadic generic lambda
index 1102f677f159170308dd48bee1ca58f06cdf5652..83e767829986d614317f6777184c0344d11a5b50 100644 (file)
@@ -5735,7 +5735,8 @@ build_address (tree t)
 {
   if (error_operand_p (t) || !cxx_mark_addressable (t))
     return error_mark_node;
-  gcc_checking_assert (TREE_CODE (t) != CONSTRUCTOR);
+  gcc_checking_assert (TREE_CODE (t) != CONSTRUCTOR
+                      || processing_template_decl);
   t = build_fold_addr_expr_loc (EXPR_LOCATION (t), t);
   if (TREE_CODE (t) != ADDR_EXPR)
     t = rvalue (t);
index 8ce7c29050cc72d411345c2ee2ae6cb5452288b5..64af747598546a955b4757cf3e092de7d699d87b 100644 (file)
@@ -1,3 +1,8 @@
+2018-02-01  Marek Polacek  <polacek@redhat.com>
+
+       PR c++/84125
+       * g++.dg/cpp1y/lambda-generic-84125.C:New test.
+
 2018-01-30  Jeff Law  <law@redhat.com>
 
        PR target/84128
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-84125.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-84125.C
new file mode 100644 (file)
index 0000000..8bf6a09
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/84125
+// { dg-do compile { target c++14 } }
+
+struct X { constexpr operator bool() const { return true; } };
+
+int main(){
+    [](auto) {
+        static_assert(X{}, "");
+    };
+}