aboutsummaryrefslogtreecommitdiff
path: root/gcc
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
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')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/pt.c71
-rw-r--r--gcc/testsuite/ChangeLog18
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/pr68724.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/variadic38.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/nontype2.C2
-rw-r--r--gcc/testsuite/g++.dg/parse/explicit1.C2
-rw-r--r--gcc/testsuite/g++.dg/template/crash11.C4
-rw-r--r--gcc/testsuite/g++.dg/template/non-dependent8.C3
-rw-r--r--gcc/testsuite/g++.dg/template/nontype-array1.C4
-rw-r--r--gcc/testsuite/g++.dg/template/nontype3.C2
-rw-r--r--gcc/testsuite/g++.dg/template/nontype8.C6
-rw-r--r--gcc/testsuite/g++.dg/template/partial5.C2
-rw-r--r--gcc/testsuite/g++.dg/template/spec33.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C3
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/spec20.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.pt/spec21.C4
-rw-r--r--gcc/testsuite/g++.old-deja/g++.robertl/eb103.C3
18 files changed, 93 insertions, 48 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))
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a9b108d..6d84a01 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,21 @@
+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.
+
2019-09-23 Sandra Loosemore <sandra@codesourcery.com>
* lib/target-supports.exp
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr68724.C b/gcc/testsuite/g++.dg/cpp0x/pr68724.C
index ff6d84d..4e99d53 100644
--- a/gcc/testsuite/g++.dg/cpp0x/pr68724.C
+++ b/gcc/testsuite/g++.dg/cpp0x/pr68724.C
@@ -9,7 +9,7 @@ struct integral_constant
integral_constant<bool, true> inst;
template <typename _Tp>
-struct integral_constant<bool, __is_enum(_Tp)> // { dg-error "" }
+struct integral_constant<bool, __is_enum(_Tp)> // { dg-error "32:template argument" }
{
};
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic38.C b/gcc/testsuite/g++.dg/cpp0x/variadic38.C
index 62031a3..b569404 100644
--- a/gcc/testsuite/g++.dg/cpp0x/variadic38.C
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic38.C
@@ -3,4 +3,4 @@ template<int... Values>
struct int_vec {};
template<int... Values>
-struct int_vec<0, (Values+1)...> {}; // { dg-error "involves template parameter" }
+struct int_vec<0, (Values+1)...> {}; // { dg-error "26:template argument" }
diff --git a/gcc/testsuite/g++.dg/cpp1z/nontype2.C b/gcc/testsuite/g++.dg/cpp1z/nontype2.C
index 393c833..75dc760 100644
--- a/gcc/testsuite/g++.dg/cpp1z/nontype2.C
+++ b/gcc/testsuite/g++.dg/cpp1z/nontype2.C
@@ -8,7 +8,7 @@ template<int* p> class X { };
template<const char *s> class Y {};
template<const std::type_info &> class Z {};
-X<&s.m> x7; // { dg-error "" }
+X<&s.m> x7; // { dg-error "3:.& s.S::m. is not a valid template argument" }
Y<"foo"> y1; // { dg-error "string literal" }
Z<typeid(p)> z1; // { dg-error "" }
diff --git a/gcc/testsuite/g++.dg/parse/explicit1.C b/gcc/testsuite/g++.dg/parse/explicit1.C
index 3535874..23c8264 100644
--- a/gcc/testsuite/g++.dg/parse/explicit1.C
+++ b/gcc/testsuite/g++.dg/parse/explicit1.C
@@ -7,5 +7,5 @@
struct foo {
template<typename T> void bar (T &t) {}
- template<> void bar<double>(double &t) {} // { dg-error "non-namespace|template|function" }
+ template<> void bar<double>(double &t) {} // { dg-error "25:template-id .bar<double>. in declaration|explicit specialization" }
};
diff --git a/gcc/testsuite/g++.dg/template/crash11.C b/gcc/testsuite/g++.dg/template/crash11.C
index 3c69514..229aec9 100644
--- a/gcc/testsuite/g++.dg/template/crash11.C
+++ b/gcc/testsuite/g++.dg/template/crash11.C
@@ -6,4 +6,6 @@
// substitution.
template <class T, class U> void foo(T, U) {}
-template <class T> void foo<T,void>(T, void) {} // { dg-error "incomplete|invalid|partial" }
+template <class T> void foo<T,void>(T, void) {} // { dg-error "40:invalid use of type .void." }
+// { dg-error "25:non-class, non-variable partial specialization" "" { target c++14 } .-1 }
+// { dg-error "25:non-type partial specialization" "" { target c++11_down } .-2 }
diff --git a/gcc/testsuite/g++.dg/template/non-dependent8.C b/gcc/testsuite/g++.dg/template/non-dependent8.C
index 369e137..f99691b 100644
--- a/gcc/testsuite/g++.dg/template/non-dependent8.C
+++ b/gcc/testsuite/g++.dg/template/non-dependent8.C
@@ -17,5 +17,6 @@ struct X
template <class T>
struct Foo
{
- X<&S::i> x; // { dg-error "convert|no type" }
+ X<&S::i> x; // { dg-error "5:could not convert" "" { target c++17 } }
+ // { dg-error "could not convert" "" { target c++14_down } .-1 }
};
diff --git a/gcc/testsuite/g++.dg/template/nontype-array1.C b/gcc/testsuite/g++.dg/template/nontype-array1.C
index f22551b..2a227b9 100644
--- a/gcc/testsuite/g++.dg/template/nontype-array1.C
+++ b/gcc/testsuite/g++.dg/template/nontype-array1.C
@@ -26,14 +26,14 @@ int main()
Message<s2> m2; // OK for clang since C++14, for gcc since C++17
Message<s3> m3; // OK for clang/gcc since C++11
- A<f2()> a1; // { dg-error "" "" { target c++14_down } }
+ A<f2()> a1; // { dg-error "7:.f2\\(\\). is not a valid template argument" "" { target c++14_down } }
static char const s4[] = "hi";
static constexpr char const s5[] = "hi"; // OK since C++11
Message<s4> m4; // { dg-error "no linkage" "" { target c++14_down } }
Message<s5> m5; // { dg-error "no linkage" "" { target c++14_down } }
Message<f()> m6; // { dg-error "" "" { target c++14_down } }
- Message<B{}> m7; // { dg-error "" "" { target c++14_down } }
+ Message<B{}> m7; // { dg-error "11:could not convert template argument" "" { target c++14_down } }
char const s8[] = "hi";
diff --git a/gcc/testsuite/g++.dg/template/nontype3.C b/gcc/testsuite/g++.dg/template/nontype3.C
index 2269e0f..0f5accf 100644
--- a/gcc/testsuite/g++.dg/template/nontype3.C
+++ b/gcc/testsuite/g++.dg/template/nontype3.C
@@ -16,7 +16,7 @@ template <int *PI>
void dep6(bar<PI+1> *); // { dg-error "" "integral or enumeration" }
template <int I>
-void dep7(bar<I+1> *); // { dg-error "" }
+void dep7(bar<I+1> *); // { dg-error "16:could not convert template argument" }
template <int *PI>
void dep8(foo< *PI > *); // { dg-error "" "integral or enumeration" }
diff --git a/gcc/testsuite/g++.dg/template/nontype8.C b/gcc/testsuite/g++.dg/template/nontype8.C
index 86d39f3..b4fbeae 100644
--- a/gcc/testsuite/g++.dg/template/nontype8.C
+++ b/gcc/testsuite/g++.dg/template/nontype8.C
@@ -6,8 +6,10 @@ template<int* p> class X { };
int a[10];
struct S { int m; static int s; } s;
-X<&a[2]> x3; // { dg-error "" } address of array element
-X<&s.m> x4; // { dg-error "" } address of non-static member
+X<&a[2]> x3; // { dg-error "3:.& a\\\[2\\\]. is not a valid template argument" "" { target c++17 } }
+// { dg-error "" "" { target c++14_down } .-1 }
+X<&s.m> x4; // { dg-error "3:.& s.S::m. is not a valid template argument" "" { target c++17 } }
+// { dg-error "" "" { target c++14_down } .-1 }
X<&s.s> x5; // { dg-error "" "" { target { ! c++17 } } } &S::s must be used
X<&S::s> x6; // OK: address of static member
diff --git a/gcc/testsuite/g++.dg/template/partial5.C b/gcc/testsuite/g++.dg/template/partial5.C
index 464408e..a562297 100644
--- a/gcc/testsuite/g++.dg/template/partial5.C
+++ b/gcc/testsuite/g++.dg/template/partial5.C
@@ -21,4 +21,4 @@ template<typename T, T V>
struct Z { };
template<typename T>
-struct Z<T, (T)0> { }; // { dg-error "involves template parameter" }
+struct Z<T, (T)0> { }; // { dg-error "13:template argument" }
diff --git a/gcc/testsuite/g++.dg/template/spec33.C b/gcc/testsuite/g++.dg/template/spec33.C
index 7b7a751..2cdf85b 100644
--- a/gcc/testsuite/g++.dg/template/spec33.C
+++ b/gcc/testsuite/g++.dg/template/spec33.C
@@ -3,5 +3,5 @@
struct A
{
template<int> static void foo () {}
- template<> static void foo<0>() {} // { dg-error "explicit|template" }
+ template<> static void foo<0>() {} // { dg-error "31:template-id .foo<0>. in declaration|explicit specialization" }
};
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C
index dda0a63..47b4ded 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/memtemp64.C
@@ -10,7 +10,8 @@ template <class C>
struct S2
{
template <class T>
- void f<S1<T> >(T) {} // { dg-error "" } bad specialization.
+ void f<S1<T> >(T) {} // { dg-error "8:non-class, non-variable partial specialization" "" { target c++14 } }
+ // { dg-error "8:non-type partial specialization" "" { target c++11_down } .-1 }
};
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec20.C b/gcc/testsuite/g++.old-deja/g++.pt/spec20.C
index b6148e5..610e6c7 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/spec20.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/spec20.C
@@ -8,7 +8,7 @@
template <class T>
struct S {
template <class U> void f(U);
- template <> void f<int>(int); // { dg-error "" } invalid specialization
+ template <> void f<int>(int); // { dg-error "20:template-id .f<int>. in declaration|explicit specialization" }
template <class V> struct I {}; // { dg-error "template" }
template <class V> struct I<V*> {}; // { dg-error "template" }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/spec21.C b/gcc/testsuite/g++.old-deja/g++.pt/spec21.C
index 4107306..cf89d6b 100644
--- a/gcc/testsuite/g++.old-deja/g++.pt/spec21.C
+++ b/gcc/testsuite/g++.old-deja/g++.pt/spec21.C
@@ -4,8 +4,8 @@ template <class T> struct S {};
template <class T = int> struct S<T*> {}; // { dg-error "" } default argument
template <int I, int J> struct A {};
-template <int I> struct A<I+5, I*2> {}; // { dg-error "" } argument involves parameter
-
+template <int I> struct A<I+5, I*2> {}; // { dg-error "28:template argument" }
+// { dg-error "33:template argument" "" { target *-*-* } .-1 }
template <class T, T t> struct C {};
template <class T> struct C<T, 1>; // { dg-error "" } type depends on parameter
int i;
diff --git a/gcc/testsuite/g++.old-deja/g++.robertl/eb103.C b/gcc/testsuite/g++.old-deja/g++.robertl/eb103.C
index ffc51ee..de181ab 100644
--- a/gcc/testsuite/g++.old-deja/g++.robertl/eb103.C
+++ b/gcc/testsuite/g++.old-deja/g++.robertl/eb103.C
@@ -4,7 +4,8 @@
template <int nlimb, int i>
inline unsigned f (unsigned* ptr);
template <int nlimb>
-inline unsigned f<nlimb,nlimb> (unsigned* ptr) // { dg-error "partial specialization" }
+inline unsigned f<nlimb,nlimb> (unsigned* ptr) // { dg-error "17:non-class, non-variable partial specialization" "" { target c++14 } }
+// { dg-error "17:non-type partial specialization" "" { target c++11_down } .-1 }
{
return 1;
}