aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-11-01 11:57:32 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2024-11-01 11:57:32 +0100
commit7fdb66f0db6275118986ed8d77c94d6cfe5155c2 (patch)
treef6b675350783cc5ba06f271808ea92ed3602b206 /gcc/cp
parent7f93910a8b5d606ad742a3594750f0c2b20d8bda (diff)
downloadgcc-7fdb66f0db6275118986ed8d77c94d6cfe5155c2.zip
gcc-7fdb66f0db6275118986ed8d77c94d6cfe5155c2.tar.gz
gcc-7fdb66f0db6275118986ed8d77c94d6cfe5155c2.tar.bz2
openmp: Return error_mark_node from tsubst_attribute for errneous varid
We incorrectly accept some invalid declare variant cases as if declare variant wasn't there, in particular if a function template has some dependent arguments and variant name lookup fails, because that is during fn_type_unification with complain=tf_none, it just sets it to error_mark_node and doesn't complain further, because it doesn't know the substitution failed (we don't return error_mark_node from tsubst_attribute, just create TREE_LIST with error_mark_node TREE_PURPOSE). The following patch fixes it by returning error_mark_node in that case, then fn_type_unification caller can see it failed and can redo it with explain_p so that errors are reported. 2024-11-01 Jakub Jelinek <jakub@redhat.com> * pt.cc (tsubst_attribute): For "omp declare variant base" attribute if varid is error_mark_node, set val to error_mark_node rather than creating a TREE_LIST with error_mark_node TREE_PURPOSE. * g++.dg/gomp/declare-variant-10.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/pt.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 15d6d82f..334dbb3 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -12163,7 +12163,10 @@ tsubst_attribute (tree t, tree *decl_p, tree args,
}
OMP_TSS_TRAIT_SELECTORS (tss) = nreverse (selectors);
}
- val = tree_cons (varid, ctx, chain);
+ if (varid == error_mark_node)
+ val = error_mark_node;
+ else
+ val = tree_cons (varid, ctx, chain);
}
/* If the first attribute argument is an identifier, don't
pass it through tsubst. Attributes like mode, format,