forked from OSchip/llvm-project
8c7b64b5ae
For backwards compatiblity, we emit only a warning instead of an error if the attribute is one of the existing type attributes that we have historically allowed to "slide" to the `DeclSpec` just as if it had been specified in GNU syntax. (We will call these "legacy type attributes" below.) The high-level changes that achieve this are: - We introduce a new field `Declarator::DeclarationAttrs` (with appropriate accessors) to store C++11 attributes occurring in the attribute-specifier-seq at the beginning of a simple-declaration (and other similar declarations). Previously, these attributes were placed on the `DeclSpec`, which made it impossible to reconstruct later on whether the attributes had in fact been placed on the decl-specifier-seq or ahead of the declaration. - In the parser, we propgate declaration attributes and decl-specifier-seq attributes separately until we can place them in `Declarator::DeclarationAttrs` or `DeclSpec::Attrs`, respectively. - In `ProcessDeclAttributes()`, in addition to processing declarator attributes, we now also process the attributes from `Declarator::DeclarationAttrs` (except if they are legacy type attributes). - In `ConvertDeclSpecToType()`, in addition to processing `DeclSpec` attributes, we also process any legacy type attributes that occur in `Declarator::DeclarationAttrs` (and emit a warning). - We make `ProcessDeclAttribute` emit an error if it sees any non-declaration attributes in C++11 syntax, except in the following cases: - If it is being called for attributes on a `DeclSpec` or `DeclaratorChunk` - If the attribute is a legacy type attribute (in which case we only emit a warning) The standard justifies treating attributes at the beginning of a simple-declaration and attributes after a declarator-id the same. Here are some relevant parts of the standard: - The attribute-specifier-seq at the beginning of a simple-declaration "appertains to each of the entities declared by the declarators of the init-declarator-list" (https://eel.is/c++draft/dcl.dcl#dcl.pre-3) - "In the declaration for an entity, attributes appertaining to that entity can appear at the start of the declaration and after the declarator-id for that declaration." (https://eel.is/c++draft/dcl.dcl#dcl.pre-note-2) - "The optional attribute-specifier-seq following a declarator-id appertains to the entity that is declared." (https://eel.is/c++draft/dcl.dcl#dcl.meaning.general-1) The standard contains similar wording to that for a simple-declaration in other similar types of declarations, for example: - "The optional attribute-specifier-seq in a parameter-declaration appertains to the parameter." (https://eel.is/c++draft/dcl.fct#3) - "The optional attribute-specifier-seq in an exception-declaration appertains to the parameter of the catch clause" (https://eel.is/c++draft/except.pre#1) The new behavior is tested both on the newly added type attribute `annotate_type`, for which we emit errors, and for the legacy type attribute `address_space` (chosen somewhat randomly from the various legacy type attributes), for which we emit warnings. Depends On D111548 Reviewed By: aaron.ballman, rsmith Differential Revision: https://reviews.llvm.org/D126061 |
||
---|---|---|
.. | ||
Inputs | ||
Weverything.c | ||
Wno-everything.c | ||
aarch64-target-cpu.c | ||
aarch64-vscale-min.c | ||
absolute-paths-symlinks.c | ||
absolute-paths-windows.test | ||
absolute-paths.c | ||
aix-unsupported.c | ||
arm-branch-protection-default-arch.c | ||
arm-ignore-branch-protection-option.c | ||
arm-invalid-branch-protection.c | ||
ast-codegen.c | ||
ast-main.c | ||
ast-main.cpp | ||
backend-attribute-error-warning-optimize.c | ||
backend-attribute-error-warning.c | ||
backend-attribute-error-warning.cpp | ||
backend-diagnostic.c | ||
cc1-return-codes.c | ||
clang-abi-compat.cpp | ||
compiler-options-dump.cpp | ||
cpp-output.c | ||
crash-diagnostic-renderer.cpp | ||
darwin-eabi.c | ||
darwin-version.c | ||
dependency-gen-escaping.c | ||
dependency-gen-extradeps-phony.c | ||
dependency-gen-has-include.c | ||
dependency-gen-symlink.c | ||
dependency-gen-windows-duplicates.c | ||
dependency-gen.c | ||
dependency-generation-crash.c | ||
diagnostics-option-names.c | ||
diagnostics-order.c | ||
disable-output.c | ||
embed-bitcode-noopt.c | ||
embed-bitcode-noopt.ll | ||
embed-bitcode.ll | ||
embed-object.c | ||
embed-object.ll | ||
exceptions.c | ||
fixed_point_add.c | ||
fixed_point_add_const.c | ||
fixed_point_bit_widths.c | ||
fixed_point_comparisons.c | ||
fixed_point_compound.c | ||
fixed_point_conversions.c | ||
fixed_point_conversions_const.c | ||
fixed_point_conversions_half.c | ||
fixed_point_crash.c | ||
fixed_point_declarations.c | ||
fixed_point_div.c | ||
fixed_point_div_const.c | ||
fixed_point_errors.c | ||
fixed_point_errors.cpp | ||
fixed_point_mul.c | ||
fixed_point_mul_const.c | ||
fixed_point_not_enabled.c | ||
fixed_point_same_fbits.c | ||
fixed_point_shift.c | ||
fixed_point_shift_const.c | ||
fixed_point_sub.c | ||
fixed_point_sub_const.c | ||
fixed_point_to_bool.c | ||
fixed_point_unary.c | ||
fixed_point_unknown_conversions.c | ||
force-include-not-found.c | ||
ftime-report-template-decl.cpp | ||
fwarn-stack-size.c | ||
gnu-inline.c | ||
gnu-mcount.c | ||
hexagon-target-basic.c | ||
iframework.c | ||
include-duplicate-removal.c | ||
int128.cpp | ||
invalid-cxx-abi.cpp | ||
invalid-o-level.c | ||
ir-support-codegen.ll | ||
ir-support-errors.ll | ||
ir-support.c | ||
lit.local.cfg | ||
macro_defined_type.cpp | ||
macros.c | ||
mfpmath.c | ||
minimize_source_to_dependency_directives.c | ||
mips-long-double.c | ||
no-knr-functions.c | ||
noderef.c | ||
noderef.cpp | ||
noderef_on_non_pointers.m | ||
noderef_templates.cpp | ||
nostdlib-for-asmpp.s | ||
objc-bool-is-bool.m | ||
opencl.cl | ||
optimization-remark-analysis.c | ||
optimization-remark-extra-analysis.c | ||
optimization-remark-line-directive.c | ||
optimization-remark-new-pm.c | ||
optimization-remark-options.c | ||
optimization-remark-with-hotness-new-pm.c | ||
optimization-remark.c | ||
output-paths.c | ||
plugin-annotate-functions.c | ||
plugin-attribute.cpp | ||
plugin-call-super.cpp | ||
plugin-delayed-template.cpp | ||
plugin-unknown.c | ||
plugin-vs-debug-info.cpp | ||
plugins-order.c | ||
plugins.c | ||
pp-only-no-editor-placeholders.c | ||
preprocessed-input.i | ||
preprocessed-output-macro-first-token.c | ||
print-header-includes.c | ||
profile-sample-use-loc-tracking.c | ||
region-pragmas.c | ||
remarks-hotness.cpp | ||
remove-file-on-signal.c | ||
rewrite-includes-bom.c | ||
rewrite-includes-cli-include.c | ||
rewrite-includes-conditions.c | ||
rewrite-includes-eof.c | ||
rewrite-includes-filenotfound.c | ||
rewrite-includes-header-cmd-line.c | ||
rewrite-includes-invalid-hasinclude.c | ||
rewrite-includes-line-markers.c | ||
rewrite-includes-macros.cpp | ||
rewrite-includes-messages.c | ||
rewrite-includes-missing.c | ||
rewrite-includes-modules.c | ||
rewrite-includes-warnings.c | ||
rewrite-includes.c | ||
rewrite-macros.c | ||
round-trip-cc1-args.c | ||
source-col-map.c | ||
stack-usage-safestack.c | ||
stats-file.c | ||
stdin-input.c | ||
stdin.c | ||
stdlang.c | ||
sycl-aux-triple.cpp | ||
sycl.cpp | ||
system-header-line-directive-ms-lineendings.c | ||
system-header-line-directive.c | ||
system-header-prefix.c | ||
trigraphs.cpp | ||
undef.c | ||
unknown-arg.c | ||
unknown-pragmas.c | ||
valid-cxx-abi.cpp | ||
verify-any-file.c | ||
verify-any-file.h | ||
verify-directive.h | ||
verify-fatal.c | ||
verify-ignore-unexpected.c | ||
verify-marker.c | ||
verify-marker.h | ||
verify-prefixes.c | ||
verify-unknown-arg.c | ||
verify.c | ||
verify2.c | ||
verify2.h | ||
verify3.c | ||
warn-device-init-fun.cu | ||
warning-mapping-1.c | ||
warning-mapping-2.c | ||
warning-mapping-3.c | ||
warning-mapping-4.c | ||
warning-mapping-5.c | ||
warning-mapping-6.c | ||
warning-options.cpp | ||
warning-poison-system-directories.c | ||
windows-exceptions.cpp | ||
windows-nul.c | ||
x86-embed-bitcode.ll | ||
x86-target-cpu.c | ||
x86_64-nacl-types.cpp |