From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../TestInheritTypeAnnotationsFromTemplateArgs.cpp | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 build/clang-plugin/tests/TestInheritTypeAnnotationsFromTemplateArgs.cpp (limited to 'build/clang-plugin/tests/TestInheritTypeAnnotationsFromTemplateArgs.cpp') diff --git a/build/clang-plugin/tests/TestInheritTypeAnnotationsFromTemplateArgs.cpp b/build/clang-plugin/tests/TestInheritTypeAnnotationsFromTemplateArgs.cpp new file mode 100644 index 0000000000..0c04c3b2bd --- /dev/null +++ b/build/clang-plugin/tests/TestInheritTypeAnnotationsFromTemplateArgs.cpp @@ -0,0 +1,46 @@ +#define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS \ + __attribute__((annotate("moz_inherit_type_annotations_from_template_args"))) +#define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class"))) +#define MOZ_NON_MEMMOVABLE __attribute__((annotate("moz_non_memmovable"))) +#define MOZ_NEEDS_MEMMOVABLE_TYPE __attribute__((annotate("moz_needs_memmovable_type"))) + +class Normal {}; +class MOZ_STACK_CLASS Stack {}; +class IndirectStack : Stack {}; // expected-note {{'IndirectStack' is a stack type because it inherits from a stack type 'Stack'}} +class ContainsStack { Stack m; }; // expected-note {{'ContainsStack' is a stack type because member 'm' is a stack type 'Stack'}} +class MOZ_NON_MEMMOVABLE Pointery {}; +class IndirectPointery : Pointery {}; // expected-note {{'IndirectPointery' is a non-memmove()able type because it inherits from a non-memmove()able type 'Pointery'}} +class ContainsPointery { Pointery m; }; // expected-note {{'ContainsPointery' is a non-memmove()able type because member 'm' is a non-memmove()able type 'Pointery'}} + +template +class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS Template {}; // expected-note-re 5 {{'Template<{{.*}}>' is a stack type because it has a template argument stack type '{{.*}}'}} expected-note-re 5 {{'Template<{{.*}}>' is a non-memmove()able type because it has a template argument non-memmove()able type '{{.*}}'}} +class IndirectTemplate : Template {}; // expected-note {{'IndirectTemplate' is a stack type because it inherits from a stack type 'Template'}} +class ContainsTemplate { Template m; }; // expected-note {{'ContainsTemplate' is a stack type because member 'm' is a stack type 'Template'}} + +static Template a; // expected-error {{variable of type 'Template' only valid on the stack}} expected-note {{value incorrectly allocated in a global variable}} +static Template b; // expected-error {{variable of type 'Template' only valid on the stack}} expected-note {{value incorrectly allocated in a global variable}} +static Template c; // expected-error {{variable of type 'Template' only valid on the stack}} expected-note {{value incorrectly allocated in a global variable}} +static IndirectTemplate d; // expected-error {{variable of type 'IndirectTemplate' only valid on the stack}} expected-note {{value incorrectly allocated in a global variable}} +static ContainsTemplate e; // expected-error {{variable of type 'ContainsTemplate' only valid on the stack}} expected-note {{value incorrectly allocated in a global variable}} +static Template f; + +template +class MOZ_NEEDS_MEMMOVABLE_TYPE Mover { // expected-error-re 8 {{Cannot instantiate 'Mover<{{.*}}>' with non-memmovable template argument '{{.*}}'}} + char mForceInstantiation[sizeof(T)]; +}; +class IndirectTemplatePointery : Template {}; // expected-note {{'IndirectTemplatePointery' is a non-memmove()able type because it inherits from a non-memmove()able type 'Template'}} +class ContainsTemplatePointery { Template m; }; // expected-note {{'ContainsTemplatePointery' is a non-memmove()able type because member 'm' is a non-memmove()able type 'Template'}} + +static Mover> n; // expected-note-re {{instantiation of 'Mover{{ ?}}>' requested here}} +static Mover> o; // expected-note-re {{instantiation of 'Mover{{ ?}}>' requested here}} +static Mover> p; // expected-note-re {{instantiation of 'Mover{{ ?}}>' requested here}} +static Mover q; // expected-note {{instantiation of 'Mover' requested here}} +static Mover r; // expected-note {{instantiation of 'Mover' requested here}} +static Mover> s; + +template +class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS ManyTs {}; // expected-note-re 3 {{'ManyTs<{{.*}}>' is a non-memmove()able type because it has a template argument non-memmove()able type '{{.*}}'}} + +static Mover> t; // expected-note-re {{instantiation of 'Mover{{ ?}}>' requested here}} +static Mover> u; // expected-note-re {{instantiation of 'Mover{{ ?}}>' requested here}} +static Mover> v; // expected-note-re {{instantiation of 'Mover{{ ?}}>' requested here}} -- cgit v1.2.3