From 6e7ceb171d0905bdd7ffb7f97d98c2f0b11226a3 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Mon, 30 Jun 2014 15:41:16 +0000 Subject: [PATCH] re PR c++/51400 ([c++0x] ICE with constexpr and attribute noreturn) /c-family 2014-06-30 Paolo Carlini 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 PR c++/51400 * g++.dg/cpp0x/constexpr-attribute3.C: New. From-SVN: r212155 --- gcc/c-family/ChangeLog | 6 ++++++ gcc/c-family/c-common.c | 16 ++++++++++------ gcc/testsuite/ChangeLog | 5 +++++ .../g++.dg/cpp0x/constexpr-attribute3.C | 5 +++++ 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-attribute3.C diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0112bc5c49c..341df696859 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2014-06-30 Paolo Carlini + + PR c++/51400 + * c-common.c (handle_noreturn_attribute, handle_const_attribute): + Do not discard TYPE_QUALS of type. + 2014-06-26 Jason Merrill * c-common.h (enum cxx_dialect): Add cxx1z. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 087f036c34a..ee89fca78d5 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c4b683aec9..930d60b7338 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-06-30 Paolo Carlini + + PR c++/51400 + * g++.dg/cpp0x/constexpr-attribute3.C: New. + 2014-06-30 Jeff Law 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 index 00000000000..491c2e7a8fe --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-attribute3.C @@ -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; -- 2.30.2