{
pp_c_whitespace (pp);
pp_c_left_paren (pp);
- pp_c_attributes_display (pp, TYPE_ATTRIBUTES (pointee));
+ /* If we're dealing with the GNU form of attributes, print this:
+ void (__attribute__((noreturn)) *f) ();
+ If it is the standard [[]] attribute, we'll print the attribute
+ in c_pretty_printer::direct_abstract_declarator/FUNCTION_TYPE. */
+ if (!cxx11_attribute_p (TYPE_ATTRIBUTES (pointee)))
+ pp_c_attributes_display (pp, TYPE_ATTRIBUTES (pointee));
}
else if (!c_dialect_cxx ())
pp_c_whitespace (pp);
case FUNCTION_TYPE:
pp_c_parameter_type_list (this, t);
direct_abstract_declarator (TREE_TYPE (t));
+ /* If this is the standard [[]] attribute, print
+ void (*)() [[noreturn]]; */
+ if (cxx11_attribute_p (TYPE_ATTRIBUTES (t)))
+ {
+ pp_space (this);
+ pp_c_attributes_display (this, TYPE_ATTRIBUTES (t));
+ }
break;
case ARRAY_TYPE:
pp_c_init_declarator (this, t);
}
-/* Pretty-print ATTRIBUTES using GNU C extension syntax. */
-
-void
-pp_c_attributes (c_pretty_printer *pp, tree attributes)
-{
- if (attributes == NULL_TREE)
- return;
-
- pp_c_ws_string (pp, "__attribute__");
- pp_c_left_paren (pp);
- pp_c_left_paren (pp);
- for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes))
- {
- pp_tree_identifier (pp, TREE_PURPOSE (attributes));
- if (TREE_VALUE (attributes))
- pp_c_call_argument_list (pp, TREE_VALUE (attributes));
-
- if (TREE_CHAIN (attributes))
- pp_separate_with (pp, ',');
- }
- pp_c_right_paren (pp);
- pp_c_right_paren (pp);
-}
-
-/* Pretty-print ATTRIBUTES using GNU C extension syntax for attributes
- marked to be displayed on disgnostic. */
+/* Pretty-print ATTRIBUTES marked to be displayed on diagnostic. */
void
pp_c_attributes_display (c_pretty_printer *pp, tree a)
if (a == NULL_TREE)
return;
+ const bool std_p = cxx11_attribute_p (a);
+
for (; a != NULL_TREE; a = TREE_CHAIN (a))
{
- const struct attribute_spec *as;
- as = lookup_attribute_spec (TREE_PURPOSE (a));
+ const struct attribute_spec *as
+ = lookup_attribute_spec (get_attribute_name (a));
if (!as || as->affects_type_identity == false)
continue;
if (c_dialect_cxx ()
/* In C++ transaction_safe is printed at the end of the declarator. */
continue;
if (is_first)
- {
- pp_c_ws_string (pp, "__attribute__");
- pp_c_left_paren (pp);
- pp_c_left_paren (pp);
- is_first = false;
- }
+ {
+ if (std_p)
+ {
+ pp_c_left_bracket (pp);
+ pp_c_left_bracket (pp);
+ }
+ else
+ {
+ pp_c_ws_string (pp, "__attribute__");
+ pp_c_left_paren (pp);
+ pp_c_left_paren (pp);
+ }
+ is_first = false;
+ }
else
- {
- pp_separate_with (pp, ',');
- }
- pp_tree_identifier (pp, TREE_PURPOSE (a));
+ pp_separate_with (pp, ',');
+ tree ns;
+ if (std_p && (ns = get_attribute_namespace (a)))
+ {
+ pp_tree_identifier (pp, ns);
+ pp_colon (pp);
+ pp_colon (pp);
+ }
+ pp_tree_identifier (pp, get_attribute_name (a));
if (TREE_VALUE (a))
- pp_c_call_argument_list (pp, TREE_VALUE (a));
+ pp_c_call_argument_list (pp, TREE_VALUE (a));
}
if (!is_first)
{
- pp_c_right_paren (pp);
- pp_c_right_paren (pp);
- pp_c_whitespace (pp);
+ if (std_p)
+ {
+ pp_c_right_bracket (pp);
+ pp_c_right_bracket (pp);
+ }
+ else
+ {
+ pp_c_right_paren (pp);
+ pp_c_right_paren (pp);
+ pp_c_whitespace (pp);
+ }
}
}
#include "internal-fn.h"
#include "gcc-rich-location.h"
#include "cp-name-hint.h"
+#include "attribs.h"
#define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',')
#define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';')
{
pp_cxx_whitespace (pp);
pp_cxx_left_paren (pp);
- pp_c_attributes_display (pp, TYPE_ATTRIBUTES (sub));
+ /* If we're dealing with the GNU form of attributes, print this:
+ void (__attribute__((noreturn)) *f) ();
+ If it is the standard [[]] attribute, we'll print the attribute
+ in dump_type_suffix. */
+ if (!cxx11_attribute_p (TYPE_ATTRIBUTES (sub)))
+ pp_c_attributes_display (pp, TYPE_ATTRIBUTES (sub));
}
if (TYPE_PTR_P (t))
pp_star (pp);
if (tx_safe_fn_type_p (t))
pp_cxx_ws_string (pp, "transaction_safe");
dump_exception_spec (pp, TYPE_RAISES_EXCEPTIONS (t), flags);
+ /* If this is the standard [[]] attribute, print
+ void (*)() [[noreturn]]; */
+ if (cxx11_attribute_p (TYPE_ATTRIBUTES (t)))
+ {
+ pp_space (pp);
+ pp_c_attributes_display (pp, TYPE_ATTRIBUTES (t));
+ pp->padding = pp_before;
+ }
dump_type_suffix (pp, TREE_TYPE (t), flags);
break;
}