===================================================================
@@ -6575,9 +6575,11 @@ handle_noreturn_attribute (tree *node, tree name,
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, tre
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);
===================================================================
@@ -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;