diff options
| author | Martin Liska <mliska@suse.cz> | 2022-10-08 10:19:23 +0200 |
|---|---|---|
| committer | Martin Liska <mliska@suse.cz> | 2022-10-08 10:19:23 +0200 |
| commit | d9e7934d25da4a78ffef1f738206aa1d897911df (patch) | |
| tree | 1bd1697c14259e095f4b4790946eae7df0c5a2e3 /gcc/c-family | |
| parent | da0970e441345f8349522ff1abac5c223044ebb1 (diff) | |
| parent | 6ffbf87ca66f4ed9cd79cff675fabe2109e46e85 (diff) | |
| download | gcc-d9e7934d25da4a78ffef1f738206aa1d897911df.zip gcc-d9e7934d25da4a78ffef1f738206aa1d897911df.tar.gz gcc-d9e7934d25da4a78ffef1f738206aa1d897911df.tar.bz2 | |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'gcc/c-family')
| -rw-r--r-- | gcc/c-family/ChangeLog | 37 | ||||
| -rw-r--r-- | gcc/c-family/c-attribs.cc | 62 | ||||
| -rw-r--r-- | gcc/c-family/c-common.cc | 10 | ||||
| -rw-r--r-- | gcc/c-family/c-common.h | 24 | ||||
| -rw-r--r-- | gcc/c-family/c-lex.cc | 2 | ||||
| -rw-r--r-- | gcc/c-family/c.opt | 7 | ||||
| -rw-r--r-- | gcc/c-family/name-hint.h | 2 |
7 files changed, 128 insertions, 16 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ea4b254..7bae1d5 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,40 @@ +2022-10-07 Qing Zhao <qing.zhao@oracle.com> + + * c-attribs.cc (handle_strict_flex_array_attribute): New function. + (c_common_attribute_table): New item for strict_flex_array. + * c.opt: (fstrict-flex-arrays): New option. + (fstrict-flex-arrays=): New option. + +2022-10-07 Martin Liska <mliska@suse.cz> + + * name-hint.h: Use std::move. + +2022-10-07 Jakub Jelinek <jakub@redhat.com> + + * c-common.cc (attribute_fallthrough_p): Lookup fallthrough attribute + only in gnu namespace or as standard attribute, treat fallthrough + attributes in other namespaces like any other unknown attribute. + +2022-10-06 Joseph Myers <joseph@codesourcery.com> + + * c-common.cc (c_common_reswords): Mark typeof as D_EXT11. Add + typeof_unqual. + * c-common.h (enum rid): Add RID_TYPEOF_UNQUAL. + (D_EXT11): New macro. Values of subsequent macros updated. + +2022-10-06 Jakub Jelinek <jakub@redhat.com> + + PR c++/106654 + * c-attribs.cc (handle_assume_attribute): New function. + (c_common_attribute_table): Add entry for assume attribute. + * c-lex.cc (c_common_has_attribute): Handle + __have_cpp_attribute (assume). + +2022-10-04 Jakub Jelinek <jakub@redhat.com> + + * c-omp.cc (c_omp_directives): Uncomment begin declare target + entry. + 2022-10-03 Patrick Palka <ppalka@redhat.com> * c-common.cc (c_common_reswords): Use RID_IS_SAME instead of diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc index 8bb80e2..92ac93b 100644 --- a/gcc/c-family/c-attribs.cc +++ b/gcc/c-family/c-attribs.cc @@ -101,6 +101,8 @@ static tree handle_special_var_sec_attribute (tree *, tree, tree, int, bool *); static tree handle_aligned_attribute (tree *, tree, tree, int, bool *); static tree handle_warn_if_not_aligned_attribute (tree *, tree, tree, int, bool *); +static tree handle_strict_flex_array_attribute (tree *, tree, tree, + int, bool *); static tree handle_weak_attribute (tree *, tree, tree, int, bool *) ; static tree handle_noplt_attribute (tree *, tree, tree, int, bool *) ; static tree handle_alias_ifunc_attribute (bool, tree *, tree, tree, bool *); @@ -144,6 +146,7 @@ static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *); static tree handle_alloc_size_attribute (tree *, tree, tree, int, bool *); static tree handle_alloc_align_attribute (tree *, tree, tree, int, bool *); static tree handle_assume_aligned_attribute (tree *, tree, tree, int, bool *); +static tree handle_assume_attribute (tree *, tree, tree, int, bool *); static tree handle_target_attribute (tree *, tree, tree, int, bool *); static tree handle_target_clones_attribute (tree *, tree, tree, int, bool *); static tree handle_optimize_attribute (tree *, tree, tree, int, bool *); @@ -368,6 +371,8 @@ const struct attribute_spec c_common_attribute_table[] = attr_aligned_exclusions }, { "warn_if_not_aligned", 0, 1, false, false, false, false, handle_warn_if_not_aligned_attribute, NULL }, + { "strict_flex_array", 1, 1, true, false, false, false, + handle_strict_flex_array_attribute, NULL }, { "weak", 0, 0, true, false, false, false, handle_weak_attribute, NULL }, { "noplt", 0, 0, true, false, false, false, @@ -530,6 +535,8 @@ const struct attribute_spec c_common_attribute_table[] = handle_designated_init_attribute, NULL }, { "fallthrough", 0, 0, false, false, false, false, handle_fallthrough_attribute, NULL }, + { "assume", 1, 1, false, false, false, false, + handle_assume_attribute, NULL }, { "patchable_function_entry", 1, 2, true, false, false, false, handle_patchable_function_entry_attribute, NULL }, @@ -2505,6 +2512,49 @@ handle_warn_if_not_aligned_attribute (tree *node, tree name, no_add_attrs, true); } +/* Handle a "strict_flex_array" attribute; arguments as in + struct attribute_spec.handler. */ + +static tree +handle_strict_flex_array_attribute (tree *node, tree name, + tree args, int ARG_UNUSED (flags), + bool *no_add_attrs) +{ + tree decl = *node; + tree argval = TREE_VALUE (args); + + /* This attribute only applies to field decls of a structure. */ + if (TREE_CODE (decl) != FIELD_DECL) + { + error_at (DECL_SOURCE_LOCATION (decl), + "%qE attribute may not be specified for %q+D", name, decl); + *no_add_attrs = true; + } + /* This attribute only applies to field with array type. */ + else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE) + { + error_at (DECL_SOURCE_LOCATION (decl), + "%qE attribute may not be specified for a non-array field", + name); + *no_add_attrs = true; + } + else if (TREE_CODE (argval) != INTEGER_CST) + { + error_at (DECL_SOURCE_LOCATION (decl), + "%qE attribute argument not an integer", name); + *no_add_attrs = true; + } + else if (!tree_fits_uhwi_p (argval) || tree_to_uhwi (argval) > 3) + { + error_at (DECL_SOURCE_LOCATION (decl), + "%qE attribute argument %qE is not an integer constant" + " between 0 and 3", name, argval); + *no_add_attrs = true; + } + + return NULL_TREE; +} + /* Handle a "weak" attribute; arguments as in struct attribute_spec.handler. */ @@ -5741,6 +5791,18 @@ handle_fallthrough_attribute (tree *, tree name, tree, int, return NULL_TREE; } +/* Handle a "assume" attribute; arguments as in struct + attribute_spec.handler. */ + +tree +handle_assume_attribute (tree *, tree name, tree, int, + bool *no_add_attrs) +{ + pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored", name); + *no_add_attrs = true; + return NULL_TREE; +} + /* Handle a "patchable_function_entry" attributes; arguments as in struct attribute_spec.handler. */ diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 4f9878d..9ec9100 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -494,7 +494,8 @@ const struct c_common_resword c_common_reswords[] = { "typedef", RID_TYPEDEF, 0 }, { "typename", RID_TYPENAME, D_CXXONLY | D_CXXWARN }, { "typeid", RID_TYPEID, D_CXXONLY | D_CXXWARN }, - { "typeof", RID_TYPEOF, D_ASM | D_EXT }, + { "typeof", RID_TYPEOF, D_EXT11 }, + { "typeof_unqual", RID_TYPEOF_UNQUAL, D_CONLY | D_C2X }, { "union", RID_UNION, 0 }, { "unsigned", RID_UNSIGNED, 0 }, { "using", RID_USING, D_CXXONLY | D_CXXWARN }, @@ -6007,12 +6008,12 @@ attribute_fallthrough_p (tree attr) { if (attr == error_mark_node) return false; - tree t = lookup_attribute ("fallthrough", attr); + tree t = lookup_attribute ("", "fallthrough", attr); if (t == NULL_TREE) return false; /* It is no longer true that "this attribute shall appear at most once in each attribute-list", but we still give a warning. */ - if (lookup_attribute ("fallthrough", TREE_CHAIN (t))) + if (lookup_attribute ("", "fallthrough", TREE_CHAIN (t))) warning (OPT_Wattributes, "attribute %<fallthrough%> specified multiple " "times"); /* No attribute-argument-clause shall be present. */ @@ -6023,7 +6024,8 @@ attribute_fallthrough_p (tree attr) for (t = attr; t != NULL_TREE; t = TREE_CHAIN (t)) { tree name = get_attribute_name (t); - if (!is_attribute_p ("fallthrough", name)) + if (!is_attribute_p ("fallthrough", name) + || !is_attribute_namespace_p ("", t)) { if (!c_dialect_cxx () && get_attribute_namespace (t) == NULL_TREE) /* The specifications of standard attributes in C mean diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 5f470d9..62ab4ba 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -104,7 +104,8 @@ enum rid RID_SIZEOF, /* C extensions */ - RID_ASM, RID_TYPEOF, RID_ALIGNOF, RID_ATTRIBUTE, RID_VA_ARG, + RID_ASM, RID_TYPEOF, RID_TYPEOF_UNQUAL, RID_ALIGNOF, RID_ATTRIBUTE, + RID_VA_ARG, RID_EXTENSION, RID_IMAGPART, RID_REALPART, RID_LABEL, RID_CHOOSE_EXPR, RID_TYPES_COMPATIBLE_P, RID_BUILTIN_COMPLEX, RID_BUILTIN_SHUFFLE, RID_BUILTIN_SHUFFLEVECTOR, RID_BUILTIN_CONVERTVECTOR, RID_BUILTIN_TGMATH, @@ -438,16 +439,17 @@ extern machine_mode c_default_pointer_mode; #define D_CXX11 0x0010 /* In C++, C++11 only. */ #define D_EXT 0x0020 /* GCC extension. */ #define D_EXT89 0x0040 /* GCC extension incorporated in C99. */ -#define D_ASM 0x0080 /* Disabled by -fno-asm. */ -#define D_OBJC 0x0100 /* In Objective C and neither C nor C++. */ -#define D_CXX_OBJC 0x0200 /* In Objective C, and C++, but not C. */ -#define D_CXXWARN 0x0400 /* In C warn with -Wcxx-compat. */ -#define D_CXX_CONCEPTS 0x0800 /* In C++, only with concepts. */ -#define D_TRANSMEM 0x1000 /* C++ transactional memory TS. */ -#define D_CXX_CHAR8_T 0x2000 /* In C++, only with -fchar8_t. */ -#define D_CXX20 0x4000 /* In C++, C++20 only. */ -#define D_CXX_COROUTINES 0x8000 /* In C++, only with coroutines. */ -#define D_CXX_MODULES 0x10000 /* In C++, only with modules. */ +#define D_EXT11 0x0080 /* GCC extension incorporated in C2X. */ +#define D_ASM 0x0100 /* Disabled by -fno-asm. */ +#define D_OBJC 0x0200 /* In Objective C and neither C nor C++. */ +#define D_CXX_OBJC 0x0400 /* In Objective C, and C++, but not C. */ +#define D_CXXWARN 0x0800 /* In C warn with -Wcxx-compat. */ +#define D_CXX_CONCEPTS 0x1000 /* In C++, only with concepts. */ +#define D_TRANSMEM 0x2000 /* C++ transactional memory TS. */ +#define D_CXX_CHAR8_T 0x4000 /* In C++, only with -fchar8_t. */ +#define D_CXX20 0x8000 /* In C++, C++20 only. */ +#define D_CXX_COROUTINES 0x10000 /* In C++, only with coroutines. */ +#define D_CXX_MODULES 0x20000 /* In C++, only with modules. */ #define D_CXX_CONCEPTS_FLAGS D_CXXONLY | D_CXX_CONCEPTS #define D_CXX_CHAR8_T_FLAGS D_CXXONLY | D_CXX_CHAR8_T diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc index d4e448a..050fa77 100644 --- a/gcc/c-family/c-lex.cc +++ b/gcc/c-family/c-lex.cc @@ -378,6 +378,8 @@ c_common_has_attribute (cpp_reader *pfile, bool std_syntax) result = 201803; else if (is_attribute_p ("nodiscard", attr_name)) result = 201907; + else if (is_attribute_p ("assume", attr_name)) + result = 202207; } else { diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 1c7f89e..01d4807 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -2076,6 +2076,13 @@ fsized-deallocation C++ ObjC++ Var(flag_sized_deallocation) Init(-1) Enable C++14 sized deallocation support. +fstrict-flex-arrays +C C++ Common Alias(fstrict-flex-arrays=,3,0) + +fstrict-flex-arrays= +C C++ Common Joined RejectNegative UInteger Var(flag_strict_flex_arrays) Init(0) IntegerRange(0,3) +-fstrict-flex-arrays=<level> Control when to treat the trailing array of a structure as a flexible array member for the purposes of accessing the elements of such an array. The default is treating all trailing arrays of structures as flexible array members. + fsquangle C++ ObjC++ WarnRemoved diff --git a/gcc/c-family/name-hint.h b/gcc/c-family/name-hint.h index df733e7..98392ce 100644 --- a/gcc/c-family/name-hint.h +++ b/gcc/c-family/name-hint.h @@ -106,7 +106,7 @@ public: /* Take ownership of this name_hint's deferred_diagnostic, for use in chaining up deferred diagnostics. */ - std::unique_ptr<deferred_diagnostic> take_deferred () { return move (m_deferred); } + std::unique_ptr<deferred_diagnostic> take_deferred () { return std::move (m_deferred); } /* Call this on a name_hint if the corresponding warning was not emitted, in which case we should also not emit the deferred_diagnostic. */ |
