aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>2006-08-03 02:30:49 +0000
committerVolker Reichelt <reichelt@gcc.gnu.org>2006-08-03 02:30:49 +0000
commit4a2f6dc05bb975426ff56d3656694684d292efbd (patch)
treefafca9eda28c4750146f1b5d20f8b090a70fe978 /gcc
parent74c5a70c23271e0f9af1a6eb6232a8f90681dbc0 (diff)
downloadgcc-4a2f6dc05bb975426ff56d3656694684d292efbd.zip
gcc-4a2f6dc05bb975426ff56d3656694684d292efbd.tar.gz
gcc-4a2f6dc05bb975426ff56d3656694684d292efbd.tar.bz2
re PR c++/28274 (Redeclaration with extra default argument doesn't work)
PR c++/28274 * decl.c (duplicate_decls): Call check_default_args here. (start_preparsed_function): Do not call check_default_args. * name-lookup.c (pushdecl_maybe_friend): Only call check_default_args if duplicate_decls got bypassed. * g++.dg/other/default5.C: New test. From-SVN: r115893
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/decl.c5
-rw-r--r--gcc/cp/name-lookup.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/other/default5.C47
5 files changed, 66 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 38ac607..93d4d23 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2006-08-03 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+ PR c++/28274
+ * decl.c (duplicate_decls): Call check_default_args here.
+ (start_preparsed_function): Do not call check_default_args.
+ * name-lookup.c (pushdecl_maybe_friend): Only call
+ check_default_args if duplicate_decls got bypassed.
+
2006-08-02 Richard Guenther <rguenther@suse.de>
PR c++/28479
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index fe73942..0e2a87e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1691,6 +1691,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
check_redeclaration_exception_specification (newdecl, olddecl);
TREE_TYPE (newdecl) = TREE_TYPE (olddecl) = newtype;
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ check_default_args (newdecl);
+
/* Lay the type out, unless already done. */
if (! same_type_p (newtype, oldtype)
&& TREE_TYPE (newdecl) != error_mark_node
@@ -10435,8 +10438,6 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
you declare a function, these types can be incomplete, but they
must be complete when you define the function. */
check_function_type (decl1, current_function_parms);
- /* Make sure no default arg is missing. */
- check_default_args (decl1);
/* Build the return declaration for the function. */
restype = TREE_TYPE (fntype);
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index cdf9ccf..b32ebfd 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -606,9 +606,6 @@ pushdecl_maybe_friend (tree x, bool is_friend)
{
int different_binding_level = 0;
- if (TREE_CODE (x) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (x))
- check_default_args (x);
-
if (TREE_CODE (name) == TEMPLATE_ID_EXPR)
name = TREE_OPERAND (name, 0);
@@ -751,6 +748,9 @@ pushdecl_maybe_friend (tree x, bool is_friend)
}
}
+ if (TREE_CODE (x) == FUNCTION_DECL || DECL_FUNCTION_TEMPLATE_P (x))
+ check_default_args (x);
+
check_template_shadow (x);
/* If this is a function conjured up by the backend, massage it
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0cda1a5..8f17cab 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-08-03 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+ PR c++/28274
+ * g++.dg/other/default5.C: New test.
+
2006-08-02 Richard Guenther <rguenther@suse.de>
* g++.dg/tree-ssa/copyprop-1.C: XFAIL.
diff --git a/gcc/testsuite/g++.dg/other/default5.C b/gcc/testsuite/g++.dg/other/default5.C
new file mode 100644
index 0000000..ad7eb01
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/default5.C
@@ -0,0 +1,47 @@
+// PR c++/28274
+// { dg-do "compile" }
+
+void f1(int, int, int, int, int = 0);
+void f1(int, int, int, int = 0, int);
+void f1(int, int, int = 0, int, int);
+void f1(int = 0, int, int, int, int); // { dg-error "default" }
+
+void f2(int, int, int, int, int = 0) {}
+void f2(int, int, int, int = 0, int);
+void f2(int, int, int = 0, int, int);
+void f2(int = 0, int, int, int, int); // { dg-error "default" }
+
+void f3(int, int, int, int, int = 0);
+void f3(int, int, int, int = 0, int) {}
+void f3(int, int, int = 0, int, int);
+void f3(int = 0, int, int, int, int); // { dg-error "default" }
+
+void f4(int, int, int, int, int = 0);
+void f4(int, int, int, int = 0, int);
+void f4(int, int, int = 0, int, int) {}
+void f4(int = 0, int, int, int, int); // { dg-error "default" }
+
+void f5(int, int, int, int, int = 0);
+void f5(int, int, int, int = 0, int);
+void f5(int, int, int = 0, int, int);
+void f5(int = 0, int, int, int, int) {} // { dg-error "default" }
+
+
+struct A
+{
+ void F1(int, int, int = 0);
+ void F2(int, int, int = 0);
+};
+
+void A::F1(int, int = 0, int) {}
+void A::F2(int = 0, int, int) {} // { dg-error "default" }
+
+
+template<int> struct B
+{
+ void F1(int, int, int = 0);
+ void F2(int, int, int = 0);
+};
+
+template<int N> void B<N>::F1(int, int = 0, int) {}
+template<int N> void B<N>::F2(int = 0, int, int) {} // { dg-error "default" }