re PR c++/77482 (Segfault when compiling ill-formed constexpr code)
authorJakub Jelinek <jakub@redhat.com>
Fri, 16 Sep 2016 20:25:17 +0000 (22:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 16 Sep 2016 20:25:17 +0000 (22:25 +0200)
PR c++/77482
* error.c (dump_simple_decl): Only check DECL_DECLARED_CONCEPT_P
if DECL_LANG_SPECIFIC is non-NULL.  Fix up formatting.

* g++.dg/cpp0x/constexpr-77482.C: New test.

From-SVN: r240198

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

index 0c7d35140bfb4745d50d8e7d820ae67b031f0a54..9d74bdbb8ba7fd41ee684fa8fd808c83a948f000 100644 (file)
@@ -1,5 +1,9 @@
 2016-09-16  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77482
+       * error.c (dump_simple_decl): Only check DECL_DECLARED_CONCEPT_P
+       if DECL_LANG_SPECIFIC is non-NULL.  Fix up formatting.
+
        PR c++/77338
        * constexpr.c (cxx_eval_constant_expression) <case PARM_DECL>: Only
        call is_really_empty_class on complete types.
index 88049ee8f1a4bf2fe5dc2ea2e7879dc0f5f5f07c..ca7360fa602fb5dada589b62e4f81475fd1d5bab 100644 (file)
@@ -959,14 +959,13 @@ dump_simple_decl (cxx_pretty_printer *pp, tree t, tree type, int flags)
 {
   if (flags & TFF_DECL_SPECIFIERS)
     {
-      if (VAR_P (t)
-         && DECL_DECLARED_CONSTEXPR_P (t))
-            {
-              if (DECL_DECLARED_CONCEPT_P (t))
-                pp_cxx_ws_string (pp, "concept");
-              else
-               pp_cxx_ws_string (pp, "constexpr");
-            }
+      if (VAR_P (t) && DECL_DECLARED_CONSTEXPR_P (t))
+        {
+         if (DECL_LANG_SPECIFIC (t) && DECL_DECLARED_CONCEPT_P (t))
+           pp_cxx_ws_string (pp, "concept");
+         else
+           pp_cxx_ws_string (pp, "constexpr");
+       }
       dump_type_prefix (pp, type, flags & ~TFF_UNQUALIFIED_NAME);
       pp_maybe_space (pp);
     }
index 88d32962d9f1fe49401d429394c78d2547ccc004..dfcccf7726e1fa9b35269af8fde9a296fe0127e4 100644 (file)
@@ -1,5 +1,8 @@
 2016-09-16  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/77482
+       * g++.dg/cpp0x/constexpr-77482.C: New test.
+
        PR c++/77379
        * g++.dg/abi/abi-tag23.C: Adjust scan-assembler regex for differing
        thunk offsets.
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-77482.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-77482.C
new file mode 100644 (file)
index 0000000..6f5c916
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/77482
+// { dg-do compile { target c++11 } }
+
+constexpr auto x;      // { dg-error "declaration\[^\n\r]*has no initializer" }
+extern struct S s;
+constexpr auto y = s;  // { dg-error "has incomplete type" }