[gcc(refs/users/marxin/heads/PR99108-target-attr-local-fn)] C++: target attribute - local decl
Martin Liska
marxin@gcc.gnu.org
Thu Feb 18 11:24:38 GMT 2021
https://gcc.gnu.org/g:4a135c94a60da5ec0e47671e1a947d9268fd2756
commit 4a135c94a60da5ec0e47671e1a947d9268fd2756
Author: Martin Liska <mliska@suse.cz>
Date: Thu Feb 18 12:23:46 2021 +0100
C++: target attribute - local decl
gcc/cp/ChangeLog:
PR c++/99108
* call.c (get_function_version_dispatcher): Do not parse
target attribute for a function with a missing declaration.
gcc/testsuite/ChangeLog:
PR c++/99108
* g++.target/i386/pr99108.C: New test.
Diff:
---
gcc/cp/call.c | 8 +++++++-
gcc/testsuite/g++.target/i386/pr99108.C | 18 ++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 186feef6fe3..844853e504e 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -8386,8 +8386,14 @@ get_function_version_dispatcher (tree fn)
&& DECL_FUNCTION_VERSIONED (fn));
gcc_assert (targetm.get_function_versions_dispatcher);
- dispatcher_decl = targetm.get_function_versions_dispatcher (fn);
+ if (cgraph_node::get (fn) == NULL)
+ {
+ error_at (DECL_SOURCE_LOCATION (fn), "missing declaration "
+ "for a multiversioned function");
+ return NULL;
+ }
+ dispatcher_decl = targetm.get_function_versions_dispatcher (fn);
if (dispatcher_decl == NULL)
{
error_at (input_location, "use of multiversioned function "
diff --git a/gcc/testsuite/g++.target/i386/pr99108.C b/gcc/testsuite/g++.target/i386/pr99108.C
new file mode 100644
index 00000000000..b0c4ffa2688
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr99108.C
@@ -0,0 +1,18 @@
+/* PR c++/99108 */
+/* { dg-do compile { target c++20 } } */
+/* { dg-require-ifunc "" } */
+
+struct A {
+ void foo(auto);
+};
+void A::foo(auto)
+{
+ int f(void) __attribute__((target("default")));
+ int f(void) __attribute__((target("arch=atom"))); /* { dg-error "missing declaration for a multiversioned function" } */
+ int b = f();
+}
+void bar(void)
+{
+ A c;
+ c.foo(7);
+}
More information about the Gcc-cvs
mailing list