Skip to content

Commit 681f91a

Browse files
author
jason
committed
* pt.c (primary_template_specialization_p): Rename from
primary_template_instantiation_p. Don't check DECL_TEMPLATE_INSTANTIATION. * call.c, cp-tree.h, decl2.c: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255179 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent dfa4aef commit 681f91a

File tree

5 files changed

+50
-14
lines changed

5 files changed

+50
-14
lines changed

gcc/cp/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2017-11-27 Jason Merrill <[email protected]>
2+
3+
* pt.c (primary_template_specialization_p): Rename from
4+
primary_template_instantiation_p. Don't check
5+
DECL_TEMPLATE_INSTANTIATION.
6+
* call.c, cp-tree.h, decl2.c: Adjust.
7+
18
2017-11-27 Jakub Jelinek <[email protected]>
29

310
PR c++/81675

gcc/cp/call.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3895,7 +3895,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
38953895
= bad_arg_conversion_rejection (NULL_TREE, -2,
38963896
rettype, totype);
38973897
}
3898-
else if (primary_template_instantiation_p (cand->fn)
3898+
else if (primary_template_specialization_p (cand->fn)
38993899
&& ics->rank > cr_exact)
39003900
{
39013901
/* 13.3.3.1.2: If the user-defined conversion is specified by
@@ -6111,7 +6111,7 @@ aligned_deallocation_fn_p (tree t)
61116111
/* A template instance is never a usual deallocation function,
61126112
regardless of its signature. */
61136113
if (TREE_CODE (t) == TEMPLATE_DECL
6114-
|| primary_template_instantiation_p (t))
6114+
|| primary_template_specialization_p (t))
61156115
return false;
61166116

61176117
tree a = FUNCTION_ARG_CHAIN (t);
@@ -6136,7 +6136,7 @@ usual_deallocation_fn_p (tree t)
61366136
/* A template instance is never a usual deallocation function,
61376137
regardless of its signature. */
61386138
if (TREE_CODE (t) == TEMPLATE_DECL
6139-
|| primary_template_instantiation_p (t))
6139+
|| primary_template_specialization_p (t))
61406140
return false;
61416141

61426142
/* If a class T has a member deallocation function named operator delete

gcc/cp/cp-tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6556,7 +6556,7 @@ extern void init_template_processing (void);
65566556
extern void print_template_statistics (void);
65576557
bool template_template_parameter_p (const_tree);
65586558
bool template_type_parameter_p (const_tree);
6559-
extern bool primary_template_instantiation_p (const_tree);
6559+
extern bool primary_template_specialization_p (const_tree);
65606560
extern tree get_primary_template_innermost_parameters (const_tree);
65616561
extern tree get_template_parms_at_level (tree, int);
65626562
extern tree get_template_innermost_arguments (const_tree);

gcc/cp/pt.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,7 +3219,7 @@ get_function_template_decl (const_tree primary_func_tmpl_inst)
32193219
{
32203220
if (! primary_func_tmpl_inst
32213221
|| TREE_CODE (primary_func_tmpl_inst) != FUNCTION_DECL
3222-
|| ! primary_template_instantiation_p (primary_func_tmpl_inst))
3222+
|| ! primary_template_specialization_p (primary_func_tmpl_inst))
32233223
return NULL;
32243224

32253225
return DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (primary_func_tmpl_inst));
@@ -3287,21 +3287,23 @@ make_ith_pack_parameter_name (tree name, int i)
32873287
}
32883288

32893289
/* Return true if T is a primary function, class or alias template
3290-
instantiation. */
3290+
specialization, not including the template pattern. */
32913291

32923292
bool
3293-
primary_template_instantiation_p (const_tree t)
3293+
primary_template_specialization_p (const_tree t)
32943294
{
32953295
if (!t)
32963296
return false;
32973297

3298-
if (TREE_CODE (t) == FUNCTION_DECL)
3299-
return DECL_LANG_SPECIFIC (t)
3300-
&& DECL_TEMPLATE_INSTANTIATION (t)
3301-
&& PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t));
3298+
if (TREE_CODE (t) == FUNCTION_DECL || VAR_P (t))
3299+
return (DECL_LANG_SPECIFIC (t)
3300+
&& DECL_USE_TEMPLATE (t)
3301+
&& DECL_TEMPLATE_INFO (t)
3302+
&& PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)));
33023303
else if (CLASS_TYPE_P (t) && !TYPE_DECL_ALIAS_P (TYPE_NAME (t)))
3303-
return CLASSTYPE_TEMPLATE_INSTANTIATION (t)
3304-
&& PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t));
3304+
return (CLASSTYPE_TEMPLATE_INFO (t)
3305+
&& CLASSTYPE_USE_TEMPLATE (t)
3306+
&& PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)));
33053307
else if (alias_template_specialization_p (t))
33063308
return true;
33073309
return false;
@@ -3336,7 +3338,7 @@ get_primary_template_innermost_parameters (const_tree t)
33363338
tree parms = NULL, template_info = NULL;
33373339

33383340
if ((template_info = get_template_info (t))
3339-
&& primary_template_instantiation_p (t))
3341+
&& primary_template_specialization_p (t))
33403342
parms = INNERMOST_TEMPLATE_PARMS
33413343
(DECL_TEMPLATE_PARMS (TI_TEMPLATE (template_info)));
33423344

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// PR c++/46831
2+
// { dg-do compile { target c++11 } }
3+
// { dg-options "" }
4+
5+
struct B { };
6+
struct D : B { };
7+
struct A {
8+
template<typename T = void> operator D&(); // { dg-message "template conversion" }
9+
operator long();
10+
};
11+
12+
template <> A::operator D&();
13+
14+
void f(long);
15+
void f(B&);
16+
17+
struct A2 {
18+
template<typename T = void> operator B&();
19+
};
20+
21+
void f2(const B&);
22+
23+
int main() {
24+
f(A());
25+
f2(A2());
26+
f2(A()); // { dg-error "" }
27+
}

0 commit comments

Comments
 (0)