re PR c++/77338 (ICE on invalid C++11 code on x86_64-linux-gnu: Segmentation fault)
authorJakub Jelinek <jakub@redhat.com>
Fri, 16 Sep 2016 20:22:35 +0000 (22:22 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 16 Sep 2016 20:22:35 +0000 (22:22 +0200)
PR c++/77338
* constexpr.c (cxx_eval_constant_expression) <case PARM_DECL>: Only
call is_really_empty_class on complete types.

* g++.dg/cpp0x/decltype-77338.C: New test.

From-SVN: r240196

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/decltype-77338.C [new file with mode: 0644]

index ee0818e2edfedac4ad33d389ba1f9ef5d1dbc553..0c7d35140bfb4745d50d8e7d820ae67b031f0a54 100644 (file)
@@ -1,5 +1,9 @@
 2016-09-16  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77338
+       * constexpr.c (cxx_eval_constant_expression) <case PARM_DECL>: Only
+       call is_really_empty_class on complete types.
+
        PR c++/77375
        * class.c (check_bases): Set CLASSTYPE_HAS_MUTABLE if any
        TYPE_HAS_MUTABLE_P for any bases.
index 34806d6749a960d816344aa894ae2d1d138a5a3c..9308c5486217e635b564f1089f6ae3f636649c49 100644 (file)
@@ -3744,7 +3744,8 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
        /* Defer in case this is only used for its type.  */;
       else if (TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)
        /* Defer, there's no lvalue->rvalue conversion.  */;
-      else if (is_really_empty_class (TREE_TYPE (t)))
+      else if (COMPLETE_TYPE_P (TREE_TYPE (t))
+              && is_really_empty_class (TREE_TYPE (t)))
        {
          /* If the class is empty, we aren't actually loading anything.  */
          r = build_constructor (TREE_TYPE (t), NULL);
index bd3f70f0d5f80894ca837e6ee89a8c2cd4bef4a0..30d7615ef6894ce43549303a95ad00b313e0725d 100644 (file)
@@ -1,5 +1,8 @@
 2016-09-16  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77338
+       * g++.dg/cpp0x/decltype-77338.C: New test.
+
        PR c++/77375
        * g++.dg/cpp0x/mutable1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype-77338.C b/gcc/testsuite/g++.dg/cpp0x/decltype-77338.C
new file mode 100644 (file)
index 0000000..4ba7c96
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/77338
+// { dg-do compile { target c++11 } }
+
+struct S;
+
+template <typename>
+auto f (S s) -> decltype (s (s));      // { dg-error "no match for call to" }