re PR c++/51400 ([c++0x] ICE with constexpr and attribute noreturn)
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 30 Jun 2014 15:41:16 +0000 (15:41 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 30 Jun 2014 15:41:16 +0000 (15:41 +0000)
/c-family
2014-06-30  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51400
* c-common.c (handle_noreturn_attribute, handle_const_attribute):
Do not discard TYPE_QUALS of type.

/testsuite
2014-06-30  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51400
* g++.dg/cpp0x/constexpr-attribute3.C: New.

From-SVN: r212155

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-attribute3.C [new file with mode: 0644]

index 0112bc5..341df69 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-30  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51400
+       * c-common.c (handle_noreturn_attribute, handle_const_attribute):
+       Do not discard TYPE_QUALS of type.
+
 2014-06-26  Jason Merrill  <jason@redhat.com>
 
        * c-common.h (enum cxx_dialect): Add cxx1z.
index 087f036..ee89fca 100644 (file)
@@ -6575,9 +6575,11 @@ handle_noreturn_attribute (tree *node, tree name, tree ARG_UNUSED (args),
   else if (TREE_CODE (type) == POINTER_TYPE
           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
     TREE_TYPE (*node)
-      = build_pointer_type
-       (build_type_variant (TREE_TYPE (type),
-                            TYPE_READONLY (TREE_TYPE (type)), 1));
+      = (build_qualified_type
+        (build_pointer_type
+         (build_type_variant (TREE_TYPE (type),
+                              TYPE_READONLY (TREE_TYPE (type)), 1)),
+         TYPE_QUALS (type)));
   else
     {
       warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -6988,9 +6990,11 @@ handle_const_attribute (tree *node, tree name, tree ARG_UNUSED (args),
   else if (TREE_CODE (type) == POINTER_TYPE
           && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
     TREE_TYPE (*node)
-      = build_pointer_type
-       (build_type_variant (TREE_TYPE (type), 1,
-                            TREE_THIS_VOLATILE (TREE_TYPE (type))));
+      = (build_qualified_type
+        (build_pointer_type
+         (build_type_variant (TREE_TYPE (type), 1,
+                              TREE_THIS_VOLATILE (TREE_TYPE (type)))),
+         TYPE_QUALS (type)));
   else
     {
       warning (OPT_Wattributes, "%qE attribute ignored", name);
index 4c4b683..930d60b 100644 (file)
@@ -1,3 +1,8 @@
+2014-06-30  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51400
+       * g++.dg/cpp0x/constexpr-attribute3.C: New.
+
 2014-06-30  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/61607
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute3.C
new file mode 100644 (file)
index 0000000..491c2e7
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/51400
+// { dg-do compile { target c++11 } }
+
+constexpr int (*f)() __attribute__((noreturn)) = 0;
+constexpr int (*g)() __attribute__((const)) = 0;