aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2022-10-13 15:54:17 +0200
committerMartin Liska <mliska@suse.cz>2022-10-13 15:54:17 +0200
commitbd21c04269deded2c7476ceca1100a26f28ea526 (patch)
tree197bf75eedac69362078a4ccc0afe5615c45c327 /gcc/c-family
parentd9e7934d25da4a78ffef1f738206aa1d897911df (diff)
parent786e4c024f941671a233f5779d73a5d22f4e9588 (diff)
downloadgcc-bd21c04269deded2c7476ceca1100a26f28ea526.zip
gcc-bd21c04269deded2c7476ceca1100a26f28ea526.tar.gz
gcc-bd21c04269deded2c7476ceca1100a26f28ea526.tar.bz2
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/ChangeLog26
-rw-r--r--gcc/c-family/c-cppbuiltin.cc10
-rw-r--r--gcc/c-family/c-opts.cc2
-rw-r--r--gcc/c-family/c-ppoutput.cc17
-rw-r--r--gcc/c-family/c-pretty-print.cc96
-rw-r--r--gcc/c-family/c-pretty-print.h1
6 files changed, 93 insertions, 59 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 7bae1d5..1fade0a 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,29 @@
+2022-10-12 Lewis Hyatt <lhyatt@gmail.com>
+
+ PR preprocessor/60014
+ PR preprocessor/60723
+ * c-ppoutput.cc (class token_streamer): Remove member
+ line_marker_emitted to...
+ (token_streamer::stream): ...a local variable here. Set
+ print.prev_was_system_token on all code paths.
+
+2022-10-10 Nathan Sidwell <nathan@acm.org>
+
+ * c-opts.cc (c_common_post_options): Bump abi to 18.
+
+2022-10-10 Marek Polacek <polacek@redhat.com>
+
+ PR c++/106937
+ * c-pretty-print.cc (pp_c_specifier_qualifier_list): Print only GNU
+ attributes here.
+ (c_pretty_printer::direct_abstract_declarator): Print the standard [[]]
+ attributes here.
+ (pp_c_attributes): Remove.
+ (pp_c_attributes_display): Print the [[]] form if appropriate. Use
+ get_attribute_name. Don't print a trailing space when printing the
+ [[]] form.
+ * c-pretty-print.h (pp_c_attributes): Remove.
+
2022-10-07 Qing Zhao <qing.zhao@oracle.com>
* c-attribs.cc (handle_strict_flex_array_attribute): New function.
diff --git a/gcc/c-family/c-cppbuiltin.cc b/gcc/c-family/c-cppbuiltin.cc
index 4b8486c..2e39acb 100644
--- a/gcc/c-family/c-cppbuiltin.cc
+++ b/gcc/c-family/c-cppbuiltin.cc
@@ -319,14 +319,10 @@ builtin_define_float_constants (const char *name_prefix,
}
/* For C2x *_IS_IEC_60559. 0 means the type does not match an IEC
- 60559 format, 1 that it matches a format but not operations and 2
- that it matches a format and operations (but may not conform to
- Annex F; we take this as meaning exceptions and rounding modes
- need not be supported). */
+ 60559 format, 1 that it matches a format but not necessarily
+ operations. */
sprintf (name, "__%s_IS_IEC_60559__", name_prefix);
- builtin_define_with_int_value (name,
- (fmt->ieee_bits == 0
- ? 0 : (fmt->round_towards_zero ? 1 : 2)));
+ builtin_define_with_int_value (name, fmt->ieee_bits != 0);
}
/* Define __DECx__ constants for TYPE using NAME_PREFIX and SUFFIX. */
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index babaa2f..55cebf6 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -975,7 +975,7 @@ c_common_post_options (const char **pfilename)
/* Change flag_abi_version to be the actual current ABI level, for the
benefit of c_cpp_builtins, and to make comparison simpler. */
- const int latest_abi_version = 17;
+ const int latest_abi_version = 18;
/* Generate compatibility aliases for ABI v13 (8.2) by default. */
const int abi_compat_default = 13;
diff --git a/gcc/c-family/c-ppoutput.cc b/gcc/c-family/c-ppoutput.cc
index 98081cc..a99d9e9 100644
--- a/gcc/c-family/c-ppoutput.cc
+++ b/gcc/c-family/c-ppoutput.cc
@@ -184,15 +184,13 @@ class token_streamer
bool avoid_paste;
bool do_line_adjustments;
bool in_pragma;
- bool line_marker_emitted;
public:
token_streamer (cpp_reader *pfile)
:avoid_paste (false),
do_line_adjustments (cpp_get_options (pfile)->lang != CLK_ASM
&& !flag_no_line_commands),
- in_pragma (false),
- line_marker_emitted (false)
+ in_pragma (false)
{
gcc_assert (!print.streamer);
print.streamer = this;
@@ -227,7 +225,14 @@ token_streamer::stream (cpp_reader *pfile, const cpp_token *token,
if (token->type == CPP_EOF)
return;
+ /* Keep track when we move into and out of system locations. */
+ const bool is_system_token = in_system_header_at (loc);
+ const bool system_state_changed
+ = (is_system_token != print.prev_was_system_token);
+ print.prev_was_system_token = is_system_token;
+
/* Subtle logic to output a space if and only if necessary. */
+ bool line_marker_emitted = false;
if (avoid_paste)
{
unsigned src_line = LOCATION_LINE (loc);
@@ -301,19 +306,17 @@ token_streamer::stream (cpp_reader *pfile, const cpp_token *token,
if (do_line_adjustments
&& !in_pragma
&& !line_marker_emitted
- && print.prev_was_system_token != !!in_system_header_at (loc)
+ && system_state_changed
&& !is_location_from_builtin_token (loc))
/* The system-ness of this token is different from the one of
the previous token. Let's emit a line change to mark the
new system-ness before we emit the token. */
{
- do_line_change (pfile, token, loc, false);
- print.prev_was_system_token = !!in_system_header_at (loc);
+ line_marker_emitted = do_line_change (pfile, token, loc, false);
}
if (!in_pragma || should_output_pragmas ())
{
cpp_output_token (token, print.outf);
- line_marker_emitted = false;
print.printed = true;
}
}
diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc
index efa1768..c99b2ce 100644
--- a/gcc/c-family/c-pretty-print.cc
+++ b/gcc/c-family/c-pretty-print.cc
@@ -466,7 +466,12 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
{
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);
@@ -595,6 +600,13 @@ c_pretty_printer::direct_abstract_declarator (tree t)
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:
@@ -850,32 +862,7 @@ c_pretty_printer::declaration (tree t)
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)
@@ -885,10 +872,12 @@ 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 ()
@@ -896,26 +885,47 @@ pp_c_attributes_display (c_pretty_printer *pp, tree a)
/* 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);
+ }
}
}
diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h
index be86bed..92674ab 100644
--- a/gcc/c-family/c-pretty-print.h
+++ b/gcc/c-family/c-pretty-print.h
@@ -119,7 +119,6 @@ void pp_c_space_for_pointer_operator (c_pretty_printer *, tree);
/* Declarations. */
void pp_c_tree_decl_identifier (c_pretty_printer *, tree);
void pp_c_function_definition (c_pretty_printer *, tree);
-void pp_c_attributes (c_pretty_printer *, tree);
void pp_c_attributes_display (c_pretty_printer *, tree);
void pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type);
void pp_c_type_qualifier_list (c_pretty_printer *, tree);