aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-09-23 19:29:55 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-09-23 19:29:55 +0000
commit0788210f804a2ba451bc9cbda26c256ad9f7c5f3 (patch)
tree1332056024df43e40d4606a485f2d6f9d3111fec /gcc/cp
parent7926a220d853e7c28576e69f90eab1aff684c5ad (diff)
downloadgcc-0788210f804a2ba451bc9cbda26c256ad9f7c5f3.zip
gcc-0788210f804a2ba451bc9cbda26c256ad9f7c5f3.tar.gz
gcc-0788210f804a2ba451bc9cbda26c256ad9f7c5f3.tar.bz2
pt.c (check_explicit_specialization): Use cp_expr_loc_or_input_loc.
/cp 2019-09-23 Paolo Carlini <paolo.carlini@oracle.com> * pt.c (check_explicit_specialization): Use cp_expr_loc_or_input_loc. (process_partial_specialization): Likewise. (convert_nontype_argument_function): Likewise. (invalid_tparm_referent_p): Likewise. (convert_template_argument): Likewise. (check_valid_ptrmem_cst_expr): Tidy. /testsuite 2019-09-23 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/pr68724.C: Check location(s) too. * g++.dg/cpp0x/variadic38.C: Likewise. * g++.dg/cpp1z/nontype2.C: Likewise. * g++.dg/parse/explicit1.C: Likewise. * g++.dg/template/crash11.C: Likewise. * g++.dg/template/non-dependent8.C: Likewise. * g++.dg/template/nontype-array1.C: Likewise. * g++.dg/template/nontype3.C: Likewise. * g++.dg/template/nontype8.C: Likewise. * g++.dg/template/partial5.C: Likewise. * g++.dg/template/spec33.C: Likewise. * g++.old-deja/g++.pt/memtemp64.C: Likewise. * g++.old-deja/g++.pt/spec20.C: Likewise. * g++.old-deja/g++.pt/spec21.C: Likewise. * g++.old-deja/g++.robertl/eb103.C: Likewise. From-SVN: r276064
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/pt.c71
2 files changed, 50 insertions, 30 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 541d018..5b561e6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2019-09-23 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * pt.c (check_explicit_specialization): Use cp_expr_loc_or_input_loc.
+ (process_partial_specialization): Likewise.
+ (convert_nontype_argument_function): Likewise.
+ (invalid_tparm_referent_p): Likewise.
+ (convert_template_argument): Likewise.
+ (check_valid_ptrmem_cst_expr): Tidy.
+
2019-09-23 Jason Merrill <jason@redhat.com>
PR c++/91809 - bit-field and ellipsis.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 4b3993c..e5d6498 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2808,8 +2808,9 @@ check_explicit_specialization (tree declarator,
/* This case handles bogus declarations like template <>
template <class T> void f<int>(); */
- error ("template-id %qD in declaration of primary template",
- declarator);
+ error_at (cp_expr_loc_or_input_loc (declarator),
+ "template-id %qE in declaration of primary template",
+ declarator);
return decl;
}
}
@@ -2867,8 +2868,9 @@ check_explicit_specialization (tree declarator,
template <class T> void f<int>(); */
if (!uses_template_parms (TREE_OPERAND (declarator, 1)))
- error ("template-id %qD in declaration of primary template",
- declarator);
+ error_at (cp_expr_loc_or_input_loc (declarator),
+ "template-id %qE in declaration of primary template",
+ declarator);
else if (variable_template_p (TREE_OPERAND (declarator, 0)))
{
/* Partial specialization of variable template. */
@@ -2877,11 +2879,13 @@ check_explicit_specialization (tree declarator,
goto ok;
}
else if (cxx_dialect < cxx14)
- error ("non-type partial specialization %qD "
- "is not allowed", declarator);
+ error_at (cp_expr_loc_or_input_loc (declarator),
+ "non-type partial specialization %qE "
+ "is not allowed", declarator);
else
- error ("non-class, non-variable partial specialization %qD "
- "is not allowed", declarator);
+ error_at (cp_expr_loc_or_input_loc (declarator),
+ "non-class, non-variable partial specialization %qE "
+ "is not allowed", declarator);
return decl;
ok:;
}
@@ -4958,8 +4962,9 @@ process_partial_specialization (tree decl)
{
if ((!packed_args && tpd.arg_uses_template_parms[i])
|| (packed_args && uses_template_parms (arg)))
- error ("template argument %qE involves template parameter(s)",
- arg);
+ error_at (cp_expr_loc_or_input_loc (arg),
+ "template argument %qE involves template "
+ "parameter(s)", arg);
else
{
/* Look at the corresponding template parameter,
@@ -6258,13 +6263,14 @@ convert_nontype_argument_function (tree type, tree expr,
{
if (complain & tf_error)
{
- error ("%qE is not a valid template argument for type %qT",
- expr, type);
+ location_t loc = cp_expr_loc_or_input_loc (expr);
+ error_at (loc, "%qE is not a valid template argument for type %qT",
+ expr, type);
if (TYPE_PTR_P (type))
- inform (input_location, "it must be the address of a function "
+ inform (loc, "it must be the address of a function "
"with external linkage");
else
- inform (input_location, "it must be the name of a function with "
+ inform (loc, "it must be the name of a function with "
"external linkage");
}
return NULL_TREE;
@@ -6275,14 +6281,15 @@ convert_nontype_argument_function (tree type, tree expr,
{
if (complain & tf_error)
{
+ location_t loc = cp_expr_loc_or_input_loc (expr);
if (cxx_dialect >= cxx11)
- error ("%qE is not a valid template argument for type %qT "
- "because %qD has no linkage",
- expr, type, fn_no_ptr);
+ error_at (loc, "%qE is not a valid template argument for type "
+ "%qT because %qD has no linkage",
+ expr, type, fn_no_ptr);
else
- error ("%qE is not a valid template argument for type %qT "
- "because %qD does not have external linkage",
- expr, type, fn_no_ptr);
+ error_at (loc, "%qE is not a valid template argument for type "
+ "%qT because %qD does not have external linkage",
+ expr, type, fn_no_ptr);
}
return NULL_TREE;
}
@@ -6309,7 +6316,6 @@ static bool
check_valid_ptrmem_cst_expr (tree type, tree expr,
tsubst_flags_t complain)
{
- location_t loc = cp_expr_loc_or_input_loc (expr);
tree orig_expr = expr;
STRIP_NOPS (expr);
if (null_ptr_cst_p (expr))
@@ -6326,6 +6332,7 @@ check_valid_ptrmem_cst_expr (tree type, tree expr,
return true;
if (complain & tf_error)
{
+ location_t loc = cp_expr_loc_or_input_loc (orig_expr);
error_at (loc, "%qE is not a valid template argument for type %qT",
orig_expr, type);
if (TREE_CODE (expr) != PTRMEM_CST)
@@ -6623,24 +6630,27 @@ invalid_tparm_referent_p (tree type, tree expr, tsubst_flags_t complain)
if (!VAR_P (decl))
{
if (complain & tf_error)
- error ("%qE is not a valid template argument of type %qT "
- "because %qE is not a variable", expr, type, decl);
+ error_at (cp_expr_loc_or_input_loc (expr),
+ "%qE is not a valid template argument of type %qT "
+ "because %qE is not a variable", expr, type, decl);
return true;
}
else if (cxx_dialect < cxx11 && !DECL_EXTERNAL_LINKAGE_P (decl))
{
if (complain & tf_error)
- error ("%qE is not a valid template argument of type %qT "
- "in C++98 because %qD does not have external linkage",
- expr, type, decl);
+ error_at (cp_expr_loc_or_input_loc (expr),
+ "%qE is not a valid template argument of type %qT "
+ "in C++98 because %qD does not have external linkage",
+ expr, type, decl);
return true;
}
else if ((cxx_dialect >= cxx11 && cxx_dialect < cxx17)
&& decl_linkage (decl) == lk_none)
{
if (complain & tf_error)
- error ("%qE is not a valid template argument of type %qT "
- "because %qD has no linkage", expr, type, decl);
+ error_at (cp_expr_loc_or_input_loc (expr),
+ "%qE is not a valid template argument of type %qT "
+ "because %qD has no linkage", expr, type, decl);
return true;
}
/* C++17: For a non-type template-parameter of reference or pointer
@@ -8129,8 +8139,9 @@ convert_template_argument (tree parm,
if (val == NULL_TREE)
val = error_mark_node;
else if (val == error_mark_node && (complain & tf_error))
- error ("could not convert template argument %qE from %qT to %qT",
- orig_arg, TREE_TYPE (orig_arg), t);
+ error_at (cp_expr_loc_or_input_loc (orig_arg),
+ "could not convert template argument %qE from %qT to %qT",
+ orig_arg, TREE_TYPE (orig_arg), t);
if (INDIRECT_REF_P (val))
{