aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-09-25 08:50:29 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-09-25 08:50:29 +0000
commita4cd9ac5f05bd0a6f73b1ec70fce841990ada959 (patch)
tree6dbc3c7d2cca70f1ad84e10d2c248125c4894256 /gcc
parent1ed0d9f8ded4cfcff1c0409b183c5b64f69200be (diff)
downloadgcc-a4cd9ac5f05bd0a6f73b1ec70fce841990ada959.zip
gcc-a4cd9ac5f05bd0a6f73b1ec70fce841990ada959.tar.gz
gcc-a4cd9ac5f05bd0a6f73b1ec70fce841990ada959.tar.bz2
name-lookup.c (check_extern_c_conflict): Use DECL_SOURCE_LOCATION.
/cp 2019-09-25 Paolo Carlini <paolo.carlini@oracle.com> * name-lookup.c (check_extern_c_conflict): Use DECL_SOURCE_LOCATION. (check_local_shadow): Use it in three additional places. /testsuite 2019-09-25 Paolo Carlini <paolo.carlini@oracle.com> * g++.dg/diagnostic/redeclaration-1.C: New. * g++.dg/lookup/extern-c-hidden.C: Test location(s) too. * g++.dg/lookup/extern-c-redecl.C: Likewise. * g++.dg/lookup/extern-c-redecl6.C: Likewise. * g++.old-deja/g++.other/using9.C: Likewise. From-SVN: r276119
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/name-lookup.c13
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/diagnostic/redeclaration-1.C20
-rw-r--r--gcc/testsuite/g++.dg/lookup/extern-c-hidden.C4
-rw-r--r--gcc/testsuite/g++.dg/lookup/extern-c-redecl.C2
-rw-r--r--gcc/testsuite/g++.dg/lookup/extern-c-redecl6.C8
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/using9.C2
8 files changed, 49 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e5edd80..ca317e7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2019-09-25 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * name-lookup.c (check_extern_c_conflict): Use DECL_SOURCE_LOCATION.
+ (check_local_shadow): Use it in three additional places.
+
2019-09-24 Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_postfix_expression): Do set location of
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 74f1072..4d01a54 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -2549,12 +2549,12 @@ check_extern_c_conflict (tree decl)
if (mismatch)
{
auto_diagnostic_group d;
- pedwarn (input_location, 0,
+ pedwarn (DECL_SOURCE_LOCATION (decl), 0,
"conflicting C language linkage declaration %q#D", decl);
inform (DECL_SOURCE_LOCATION (old),
"previous declaration %q#D", old);
if (mismatch < 0)
- inform (input_location,
+ inform (DECL_SOURCE_LOCATION (decl),
"due to different exception specifications");
}
else
@@ -2674,7 +2674,8 @@ check_local_shadow (tree decl)
/* ARM $8.3 */
if (b->kind == sk_function_parms)
{
- error ("declaration of %q#D shadows a parameter", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "declaration of %q#D shadows a parameter", decl);
return;
}
}
@@ -2700,7 +2701,8 @@ check_local_shadow (tree decl)
&& (old_scope->kind == sk_cond || old_scope->kind == sk_for))
{
auto_diagnostic_group d;
- error ("redeclaration of %q#D", decl);
+ error_at (DECL_SOURCE_LOCATION (decl),
+ "redeclaration of %q#D", decl);
inform (DECL_SOURCE_LOCATION (old),
"%q#D previously declared here", old);
return;
@@ -2723,7 +2725,8 @@ check_local_shadow (tree decl)
&& in_function_try_handler))
{
auto_diagnostic_group d;
- if (permerror (input_location, "redeclaration of %q#D", decl))
+ if (permerror (DECL_SOURCE_LOCATION (decl),
+ "redeclaration of %q#D", decl))
inform (DECL_SOURCE_LOCATION (old),
"%q#D previously declared here", old);
return;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f1f670b..44fc3e3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2019-09-25 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * g++.dg/diagnostic/redeclaration-1.C: New.
+ * g++.dg/lookup/extern-c-hidden.C: Test location(s) too.
+ * g++.dg/lookup/extern-c-redecl.C: Likewise.
+ * g++.dg/lookup/extern-c-redecl6.C: Likewise.
+ * g++.old-deja/g++.other/using9.C: Likewise.
+
2019-09-23 Martin Sebor <msebor@redhat.com>
PR tree-optimization/91570
diff --git a/gcc/testsuite/g++.dg/diagnostic/redeclaration-1.C b/gcc/testsuite/g++.dg/diagnostic/redeclaration-1.C
new file mode 100644
index 0000000..a41a2b8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/redeclaration-1.C
@@ -0,0 +1,20 @@
+void
+foo (int i)
+{
+ int i // { dg-error "7:declaration of .int i. shadows a parameter" }
+ (0);
+
+ for (int j ;;) // { dg-message "12:.int j. previously declared here" }
+ int j // { dg-error "9:redeclaration of .int j." }
+ (0);
+}
+
+void
+bar (int i) // { dg-message "10:.int i. previously declared here" }
+ try
+ { }
+ catch (...)
+ {
+ int i // { dg-error "11:redeclaration of .int i." }
+ (0);
+ }
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-hidden.C b/gcc/testsuite/g++.dg/lookup/extern-c-hidden.C
index 80593db..2b4a462 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-hidden.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-hidden.C
@@ -4,8 +4,8 @@ extern "C" float fabsf (float); // { dg-message "previous declaration" }
namespace Bob
{
- extern "C" float fabsf (float, float); // { dg-error "C language" }
+ extern "C" float fabsf (float, float); // { dg-error "20:conflicting C language" }
extern "C" double fabs (double, double); // { dg-message "previous declaration" }
}
-extern "C" double fabs (double); // { dg-error "C language" }
+extern "C" double fabs (double); // { dg-error "19:conflicting C language" }
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl.C
index fd49868..4ffb822 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-redecl.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-redecl.C
@@ -8,4 +8,4 @@ namespace A {
// next line should trigger an error because
// it conflicts with previous declaration of foo_func (), due to
// different exception specifications.
-extern "C" void foo_func (); // { dg-error "C language linkage|exception specifications" }
+extern "C" void foo_func (); // { dg-error "17:conflicting C language linkage|exception specifications" }
diff --git a/gcc/testsuite/g++.dg/lookup/extern-c-redecl6.C b/gcc/testsuite/g++.dg/lookup/extern-c-redecl6.C
index b4537d6..1d6c571 100644
--- a/gcc/testsuite/g++.dg/lookup/extern-c-redecl6.C
+++ b/gcc/testsuite/g++.dg/lookup/extern-c-redecl6.C
@@ -16,10 +16,10 @@ extern "C" {
namespace BAD
{
- long i; // { dg-error "C language linkage" }
- double f; // { dg-error "C language linkage" }
- int fn (); // { dg-error "C language linkage" }
- int ai1[2]; // { dg-error "C language linkage" }
+ long i; // { dg-error "10:conflicting C language linkage" }
+ double f; // { dg-error "12:conflicting C language linkage" }
+ int fn (); // { dg-error "9:conflicting C language linkage" }
+ int ai1[2]; // { dg-error "9:conflicting C language linkage" }
}
}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/using9.C b/gcc/testsuite/g++.old-deja/g++.other/using9.C
index c79f993..e1b5aa7 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/using9.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/using9.C
@@ -16,6 +16,6 @@ using ::a;
extern "C" void foo (); // { dg-message "previous declaration" }
namespace {
- extern "C" int foo (); // { dg-error "C.*linkage" }
+ extern "C" int foo (); // { dg-error "18:conflicting C.*linkage" }
using ::foo; // { dg-error "" } already in use
}