aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/decl.c9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp1z/class-deduction72.C11
4 files changed, 31 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1db1e09..9aaa81a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2020-03-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/91759
+ * decl.c (grokfndecl): Restore old diagnostics about deduction
+ guide declared in different scope if in_namespace is NULL_TREE.
+
2020-03-17 Jakub Jelinek <jakub@redhat.com>
PR c++/90995
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d240436..319b7ee 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9644,6 +9644,15 @@ grokfndecl (tree ctype,
"namespace scope", decl);
return NULL_TREE;
}
+ tree type = TREE_TYPE (DECL_NAME (decl));
+ if (in_namespace == NULL_TREE
+ && CP_DECL_CONTEXT (decl) != CP_TYPE_CONTEXT (type))
+ {
+ error_at (location, "deduction guide %qD must be declared in the "
+ "same scope as %qT", decl, type);
+ inform (location_of (type), " declared here");
+ return NULL_TREE;
+ }
if (funcdef_flag)
error_at (location,
"deduction guide %qD must not have a function body", decl);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 775837d..8efb773 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/91759
+ * g++.dg/cpp1z/class-deduction72.C: New test.
+
2020-03-17 Uroš Bizjak <ubizjak@gmail.com>
* g++.dg/debug/dwarf2/const2b.C (dg-do): Fix target selector.
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction72.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction72.C
new file mode 100644
index 0000000..60c5599
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction72.C
@@ -0,0 +1,11 @@
+// PR c++/91759
+// { dg-do compile { target c++17 } }
+
+namespace N {
+ template <typename T>
+ struct X{ X(int); }; // { dg-message "declared here" }
+}
+
+using N::X;
+
+X(int) -> X<int>; // { dg-error "must be declared in the same scope as" }