aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2014-05-07 14:30:23 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2014-05-07 14:30:23 +0000
commitef2662bf65271c7723e797a11891d8085cd01fa5 (patch)
treeee8b0c4370ec99eae42b92e1888996ea0abd5759
parent50f0aa20742add8e1a59154ce76f45c157142fe3 (diff)
downloadgcc-ef2662bf65271c7723e797a11891d8085cd01fa5.zip
gcc-ef2662bf65271c7723e797a11891d8085cd01fa5.tar.gz
gcc-ef2662bf65271c7723e797a11891d8085cd01fa5.tar.bz2
re PR c++/61080 (Spurious no return statement warning with deleted operators)
/cp 2014-05-07 Paolo Carlini <paolo.carlini@oracle.com> PR c++/61080 * pt.c (instantiate_decl): Avoid generating the body of a deleted function. /testsuite 2014-05-07 Paolo Carlini <paolo.carlini@oracle.com> PR c++/61080 * g++.dg/cpp0x/deleted7.C: New. From-SVN: r210161
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/pt.c39
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/deleted7.C36
4 files changed, 70 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index d3eb4f2..938fbf5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-05-07 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/61080
+ * pt.c (instantiate_decl): Avoid generating the body of a
+ deleted function.
+
2014-05-06 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60999
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d9e273e..f23eec3 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -19542,6 +19542,7 @@ instantiate_decl (tree d, int defer_ok,
int saved_unevaluated_operand = cp_unevaluated_operand;
int saved_inhibit_evaluation_warnings = c_inhibit_evaluation_warnings;
bool external_p;
+ bool deleted_p;
tree fn_context;
bool nested;
@@ -19623,11 +19624,17 @@ instantiate_decl (tree d, int defer_ok,
args = gen_args;
if (TREE_CODE (d) == FUNCTION_DECL)
- pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE
- || DECL_DEFAULTED_OUTSIDE_CLASS_P (code_pattern)
- || DECL_DELETED_FN (code_pattern));
+ {
+ deleted_p = DECL_DELETED_FN (code_pattern);
+ pattern_defined = (DECL_SAVED_TREE (code_pattern) != NULL_TREE
+ || DECL_DEFAULTED_OUTSIDE_CLASS_P (code_pattern)
+ || deleted_p);
+ }
else
- pattern_defined = ! DECL_IN_AGGR_P (code_pattern);
+ {
+ deleted_p = false;
+ pattern_defined = ! DECL_IN_AGGR_P (code_pattern);
+ }
/* We may be in the middle of deferred access check. Disable it now. */
push_deferring_access_checks (dk_no_deferred);
@@ -19671,7 +19678,10 @@ instantiate_decl (tree d, int defer_ok,
elsewhere, we don't want to instantiate the entire data
member, but we do want to instantiate the initializer so that
we can substitute that elsewhere. */
- || (external_p && VAR_P (d)))
+ || (external_p && VAR_P (d))
+ /* Handle here a deleted function too, avoid generating
+ its body (c++/61080). */
+ || deleted_p)
{
/* The definition of the static data member is now required so
we must substitute the initializer. */
@@ -19867,17 +19877,14 @@ instantiate_decl (tree d, int defer_ok,
tf_warning_or_error, tmpl,
/*integral_constant_expression_p=*/false);
- if (DECL_STRUCT_FUNCTION (code_pattern))
- {
- /* Set the current input_location to the end of the function
- so that finish_function knows where we are. */
- input_location
- = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus;
-
- /* Remember if we saw an infinite loop in the template. */
- current_function_infinite_loop
- = DECL_STRUCT_FUNCTION (code_pattern)->language->infinite_loop;
- }
+ /* Set the current input_location to the end of the function
+ so that finish_function knows where we are. */
+ input_location
+ = DECL_STRUCT_FUNCTION (code_pattern)->function_end_locus;
+
+ /* Remember if we saw an infinite loop in the template. */
+ current_function_infinite_loop
+ = DECL_STRUCT_FUNCTION (code_pattern)->language->infinite_loop;
}
/* We don't need the local specializations any more. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 723967f..97ce690 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-05-07 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/61080
+ * g++.dg/cpp0x/deleted7.C: New.
+
2014-05-07 Richard Biener <rguenther@suse.de>
PR tree-optimization/61034
diff --git a/gcc/testsuite/g++.dg/cpp0x/deleted7.C b/gcc/testsuite/g++.dg/cpp0x/deleted7.C
new file mode 100644
index 0000000..6afa9f7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/deleted7.C
@@ -0,0 +1,36 @@
+// PR c++/61080
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wreturn-type" }
+
+struct AAA
+{
+ int a1, a2, a3;
+ void *p;
+};
+
+template <typename K, typename V>
+class WeakMapPtr
+{
+ public:
+ WeakMapPtr() : ptr(nullptr) {};
+ bool init(AAA *cx);
+ private:
+ void *ptr;
+ WeakMapPtr(const WeakMapPtr &wmp) = delete;
+ WeakMapPtr &operator=(const WeakMapPtr &wmp) = delete;
+};
+
+template <typename K, typename V>
+bool WeakMapPtr<K, V>::init(AAA *cx)
+{
+ ptr = cx->p;
+ return true;
+}
+
+struct JSObject
+{
+ int blah;
+ float meh;
+};
+
+template class WeakMapPtr<JSObject*, JSObject*>;