aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2015-01-08 15:48:36 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2015-01-08 15:48:36 +0000
commit247ecdf3b8568e4b489598858b7586dccf9f95e5 (patch)
tree1616c404b687f28401bb54f5d40ed995afa1d327
parent45f46750a3513790573791c0eec6b600b42f2042 (diff)
downloadgcc-247ecdf3b8568e4b489598858b7586dccf9f95e5.zip
gcc-247ecdf3b8568e4b489598858b7586dccf9f95e5.tar.gz
gcc-247ecdf3b8568e4b489598858b7586dccf9f95e5.tar.bz2
re PR c++/60753 (Deleted definition of an explicit function template specialization, following a declaration, incorrectly accepted)
/cp 2015-01-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/60753 * decl.c (grokfndecl): Add bool parameter. (grokdeclarator): Adjust calls. (start_decl): Don't set DECL_DELETED_FN here. /testsuite 2015-01-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/60753 * g++.dg/cpp0x/deleted10.C: New. From-SVN: r219347
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c38
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/deleted10.C15
4 files changed, 43 insertions, 22 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f9322bf..5c576bc 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2015-01-08 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/60753
+ * decl.c (grokfndecl): Add bool parameter.
+ (grokdeclarator): Adjust calls.
+ (start_decl): Don't set DECL_DELETED_FN here.
+
2015-01-06 Jason Merrill <jason@redhat.com>
* parser.c (cp_parser_nested_name_specifier_opt): Diagnose invalid
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 2fea106..65ccf77 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4631,26 +4631,15 @@ start_decl (const cp_declarator *declarator,
if (context != global_namespace)
*pushed_scope_p = push_scope (context);
- if (initialized)
- /* Is it valid for this decl to have an initializer at all?
- If not, set INITIALIZED to zero, which will indirectly
- tell `cp_finish_decl' to ignore the initializer once it is parsed. */
- switch (TREE_CODE (decl))
- {
- case TYPE_DECL:
- error ("typedef %qD is initialized (use decltype instead)", decl);
- return error_mark_node;
-
- case FUNCTION_DECL:
- if (initialized == SD_DELETED)
- /* We'll handle the rest of the semantics later, but we need to
- set this now so it's visible to duplicate_decls. */
- DECL_DELETED_FN (decl) = 1;
- break;
-
- default:
- break;
- }
+ /* Is it valid for this decl to have an initializer at all?
+ If not, set INITIALIZED to zero, which will indirectly
+ tell `cp_finish_decl' to ignore the initializer once it is parsed. */
+ if (initialized
+ && TREE_CODE (decl) == TYPE_DECL)
+ {
+ error ("typedef %qD is initialized (use decltype instead)", decl);
+ return error_mark_node;
+ }
if (initialized)
{
@@ -7630,6 +7619,7 @@ grokfndecl (tree ctype,
int friendp,
int publicp,
int inlinep,
+ bool deletedp,
special_function_kind sfk,
bool funcdef_flag,
int template_count,
@@ -7768,6 +7758,9 @@ grokfndecl (tree ctype,
DECL_CONTEXT (decl) = ctype;
}
+ if (deletedp)
+ DECL_DELETED_FN (decl) = 1;
+
if (ctype)
{
DECL_CONTEXT (decl) = ctype;
@@ -10756,7 +10749,7 @@ grokdeclarator (const cp_declarator *declarator,
virtualp, flags, memfn_quals, rqual, raises,
friendp ? -1 : 0, friendp, publicp,
inlinep | (2 * constexpr_p),
- sfk,
+ initialized == SD_DELETED, sfk,
funcdef_flag, template_count, in_namespace,
attrlist, declarator->id_loc);
decl = set_virt_specifiers (decl, virt_specifiers);
@@ -10978,7 +10971,8 @@ grokdeclarator (const cp_declarator *declarator,
decl = grokfndecl (ctype, type, original_name, parms, unqualified_id,
virtualp, flags, memfn_quals, rqual, raises,
1, friendp,
- publicp, inlinep | (2 * constexpr_p), sfk,
+ publicp, inlinep | (2 * constexpr_p),
+ initialized == SD_DELETED, sfk,
funcdef_flag,
template_count, in_namespace, attrlist,
declarator->id_loc);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 356d20f..e692f46 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-08 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/60753
+ * g++.dg/cpp0x/deleted10.C: New.
+
2015-01-07 David Malcolm <dmalcolm@redhat.com>
* jit.dg/test-error-dereferencing-void-ptr.c: New test case.
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted10.C b/gcc/testsuite/g++.dg/cpp0x/deleted10.C
new file mode 100644
index 0000000..4fbee27
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/deleted10.C
@@ -0,0 +1,15 @@
+// PR c++/60753
+// { dg-do compile { target c++11 } }
+
+template<class T> void foo (T);
+
+template<> void foo<int> (int);
+template<> void foo<int> (int) = delete; // { dg-error "deleted" }
+
+struct S
+{
+ template<class T> void bar (T);
+};
+
+template<> void S::bar<int> (int);
+template<> void S::bar<int> (int) = delete; // { dg-error "deleted" }