aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-09-10 08:12:28 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-09-10 08:12:28 +0000
commitb08bcba5dc1775618e67f6486240188260084122 (patch)
tree63cf4ce79d85ce717807eee9a1fa0d04b1e46242
parenta360a359b784acdb53e20cbb85576b4b3662703a (diff)
downloadgcc-b08bcba5dc1775618e67f6486240188260084122.zip
gcc-b08bcba5dc1775618e67f6486240188260084122.tar.gz
gcc-b08bcba5dc1775618e67f6486240188260084122.tar.bz2
decl.c (has_designator_problem): Use cp_expr_loc_or_input_loc in error_at.
/cp 2019-09-10 Paolo Carlini <paolo.carlini@oracle.com> * decl.c (has_designator_problem): Use cp_expr_loc_or_input_loc in error_at. (build_enumerator): Likewise. (cp_finish_decl): Use DECL_SOURCE_LOCATION. (grokdeclarator): Use id_loc in two error_at; change errror message about constinit together constexpr to use two ranges. /testsuite 2019-09-10 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/cpp0x/enum29.C: Test location(s) too. * g++.dg/cpp0x/lambda/lambda-ice10.C: Likewise. * g++.dg/cpp2a/constinit3.C: Likewise. * g++.dg/ext/desig4.C: Likewise. * g++.dg/ext/label10.C: Likewise. * g++.old-deja/g++.other/dtor3.C: Likewise. From-SVN: r275585
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/decl.c28
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/enum29.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C2
-rw-r--r--gcc/testsuite/g++.dg/cpp2a/constinit3.C6
-rw-r--r--gcc/testsuite/g++.dg/ext/desig4.C8
-rw-r--r--gcc/testsuite/g++.dg/ext/label10.C2
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/dtor3.C8
9 files changed, 49 insertions, 25 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2b98a06..2c48829 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2019-09-10 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * decl.c (has_designator_problem): Use cp_expr_loc_or_input_loc
+ in error_at.
+ (build_enumerator): Likewise.
+ (cp_finish_decl): Use DECL_SOURCE_LOCATION.
+ (grokdeclarator): Use id_loc in two error_at; change errror
+ message about constinit together constexpr to use two ranges.
+
2019-09-09 Marek Polacek <polacek@redhat.com>
PR c++/84374 - diagnose invalid uses of decltype(auto).
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index dfcd7b1..8bb398b 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6114,8 +6114,9 @@ has_designator_problem (reshape_iter *d, tsubst_flags_t complain)
if (d->cur->index)
{
if (complain & tf_error)
- error ("C99 designator %qE outside aggregate initializer",
- d->cur->index);
+ error_at (cp_expr_loc_or_input_loc (d->cur->index),
+ "C99 designator %qE outside aggregate initializer",
+ d->cur->index);
else
return true;
}
@@ -7288,8 +7289,9 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
if ((flags & LOOKUP_CONSTINIT)
&& !(dk == dk_thread || dk == dk_static))
{
- error ("%<constinit%> can only be applied to a variable with static "
- "or thread storage duration");
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "%<constinit%> can only be applied to a variable with "
+ "static or thread storage duration");
return;
}
@@ -10628,8 +10630,9 @@ grokdeclarator (const cp_declarator *declarator,
&& !uniquely_derived_from_p (ctype,
current_class_type))
{
- error ("invalid use of qualified-name %<%T::%D%>",
- qualifying_scope, decl);
+ error_at (id_declarator->id_loc,
+ "invalid use of qualified-name %<%T::%D%>",
+ qualifying_scope, decl);
return error_mark_node;
}
}
@@ -10816,8 +10819,9 @@ grokdeclarator (const cp_declarator *declarator,
keywords shall appear in a decl-specifier-seq." */
if (constinit_p && constexpr_p)
{
- error_at (min_location (declspecs->locations[ds_constinit],
- declspecs->locations[ds_constexpr]),
+ gcc_rich_location richloc (declspecs->locations[ds_constinit]);
+ richloc.add_range (declspecs->locations[ds_constexpr]);
+ error_at (&richloc,
"can use at most one of the %<constinit%> and %<constexpr%> "
"specifiers");
return error_mark_node;
@@ -11831,7 +11835,8 @@ grokdeclarator (const cp_declarator *declarator,
&& inner_declarator->u.id.sfk == sfk_destructor
&& arg_types != void_list_node)
{
- error ("destructors may not have parameters");
+ error_at (declarator->id_loc,
+ "destructors may not have parameters");
arg_types = void_list_node;
parms = NULL_TREE;
}
@@ -15171,8 +15176,9 @@ build_enumerator (tree name, tree value, tree enumtype, tree attributes,
if (! INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P
(TREE_TYPE (value)))
{
- error ("enumerator value for %qD must have integral or "
- "unscoped enumeration type", name);
+ error_at (cp_expr_loc_or_input_loc (value),
+ "enumerator value for %qD must have integral or "
+ "unscoped enumeration type", name);
value = NULL_TREE;
}
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9db40e4..31b54f8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2019-09-10 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/cpp0x/enum29.C: Test location(s) too.
+ * g++.dg/cpp0x/lambda/lambda-ice10.C: Likewise.
+ * g++.dg/cpp2a/constinit3.C: Likewise.
+ * g++.dg/ext/desig4.C: Likewise.
+ * g++.dg/ext/label10.C: Likewise.
+ * g++.old-deja/g++.other/dtor3.C: Likewise.
+
2019-09-10 Christophe Lyon <christophe.lyon@st.com>
* lib/target-supports.exp (check_effective_target_static): Disable
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum29.C b/gcc/testsuite/g++.dg/cpp0x/enum29.C
index 63ecf7e..b7048f1 100644
--- a/gcc/testsuite/g++.dg/cpp0x/enum29.C
+++ b/gcc/testsuite/g++.dg/cpp0x/enum29.C
@@ -38,7 +38,7 @@ enum E0 { e0 = X0() };
enum E1 { e1 = X1() };
enum E2 { e2 = X2() };
enum E3 { e3 = X3() };
-enum E4 { e4 = X4() }; // { dg-error "integral" }
+enum E4 { e4 = X4() }; // { dg-error "16:enumerator value for .e4. must have integral" }
enum E5 { e5 = X5() }; // { dg-error "ambiguous" }
enum F0 : int { f0 = X0() };
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C
index 1ea59c2..235bfeb 100644
--- a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice10.C
@@ -4,5 +4,5 @@
template<int> struct A
{
static const int i;
- template<int N> const int A<N>::i = []{ return 0; }(); // { dg-error "invalid use" }
+ template<int N> const int A<N>::i = []{ return 0; }(); // { dg-error "29:invalid use" }
};
diff --git a/gcc/testsuite/g++.dg/cpp2a/constinit3.C b/gcc/testsuite/g++.dg/cpp2a/constinit3.C
index 316937e..1db16fe 100644
--- a/gcc/testsuite/g++.dg/cpp2a/constinit3.C
+++ b/gcc/testsuite/g++.dg/cpp2a/constinit3.C
@@ -31,8 +31,8 @@ int
fn1 ()
{
// Not static storage
- constinit int a1 = 42; // { dg-error ".constinit. can only be applied to a variable with static or thread storage" }
- constinit int a2 = 42; // { dg-error ".constinit. can only be applied to a variable with static or thread storage" }
+ constinit int a1 = 42; // { dg-error "17:.constinit. can only be applied to a variable with static or thread storage" }
+ constinit int a2 = 42; // { dg-error "17:.constinit. can only be applied to a variable with static or thread storage" }
extern constinit int e1;
return 0;
@@ -46,7 +46,7 @@ fn3 ()
void
fn2 (int i, constinit int p) // { dg-error "a parameter cannot be declared .constinit." }
{
- constinit auto l = [i](){ return i; }; // { dg-error ".constinit. can only be applied to a variable with static or thread storage" }
+ constinit auto l = [i](){ return i; }; // { dg-error "18:.constinit. can only be applied to a variable with static or thread storage" }
}
struct B { int d; };
diff --git a/gcc/testsuite/g++.dg/ext/desig4.C b/gcc/testsuite/g++.dg/ext/desig4.C
index 62c3c58..902bd1f 100644
--- a/gcc/testsuite/g++.dg/ext/desig4.C
+++ b/gcc/testsuite/g++.dg/ext/desig4.C
@@ -1,18 +1,18 @@
// PR c++/51458
// { dg-options "" }
-char g[] = { [7] = "abcd" }; // { dg-error "designator" }
+char g[] = { [7] = "abcd" }; // { dg-error "15:designator .7." }
int a = { .foo = 6 }; // { dg-error "designator" }
-int b = { [0] = 1 }; // { dg-error "designator" }
+int b = { [0] = 1 }; // { dg-error "12:designator .0." }
_Complex float c = { .foo = 0, 1 }; // { dg-error "designator" }
// { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++2a } .-1 }
// { dg-error "cannot convert" "" { target *-*-* } .-2 }
-_Complex float d = { [0] = 0, 1 }; // { dg-error "designator" }
+_Complex float d = { [0] = 0, 1 }; // { dg-error "23:designator .0." }
// { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++2a } .-1 }
// { dg-error "cannot convert" "" { target *-*-* } .-2 }
_Complex float e = { 0, .foo = 1 }; // { dg-error "designator" }
// { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++2a } .-1 }
// { dg-error "cannot convert" "" { target *-*-* } .-2 }
-_Complex float f = { 0, [0] = 1 }; // { dg-error "designator" }
+_Complex float f = { 0, [0] = 1 }; // { dg-error "26:designator .0." }
// { dg-error "either all initializer clauses should be designated or none of them should be" "" { target c++2a } .-1 }
// { dg-error "cannot convert" "" { target *-*-* } .-2 }
diff --git a/gcc/testsuite/g++.dg/ext/label10.C b/gcc/testsuite/g++.dg/ext/label10.C
index 62d235d..4ba5ae7 100644
--- a/gcc/testsuite/g++.dg/ext/label10.C
+++ b/gcc/testsuite/g++.dg/ext/label10.C
@@ -12,6 +12,6 @@ A<0> a;
void foo ()
{
__label__ P;
- enum { O = && P }; // { dg-error "cannot appear in|integral" }
+ enum { O = && P }; // { dg-error "14:enumerator value for .O. must have integral|cannot appear in" }
P:;
}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/dtor3.C b/gcc/testsuite/g++.old-deja/g++.other/dtor3.C
index f5a00ed..22eca46 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/dtor3.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/dtor3.C
@@ -2,27 +2,27 @@
struct S1
{
- ~S1(int); // { dg-error "" } destructors may not have parameters
+ ~S1(int); // { dg-error "3:destructors may not have parameters" }
};
template <class T>
struct S2
{
- ~S2(int); // { dg-error "" } destructors may not have parameters
+ ~S2(int); // { dg-error "3:destructors may not have parameters" }
};
struct S3
{
- ~S3(double) {} // { dg-error "" } destructors may not have parameters
+ ~S3(double) {} // { dg-error "3:destructors may not have parameters" }
};
template <class T>
struct S4
{
- ~S4(double) {} // { dg-error "" } destructors may not have parameters
+ ~S4(double) {} // { dg-error "3:destructors may not have parameters" }
};