re PR c++/3902 ([parser] ambiguous 8.2/7)
authorNathan Sidwell <nathan@codesourcery.com>
Tue, 28 Jan 2003 17:36:11 +0000 (17:36 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 28 Jan 2003 17:36:11 +0000 (17:36 +0000)
cp:
PR c++/3902
* parser.c (cp_parser_decl_specifier_seq): Cannot have constructor
inside a declarator.
testsuite:
PR c++/3902
* g++.dg/parse/template5.C: New test.

From-SVN: r61987

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/template5.C [new file with mode: 0644]

index 180fccb..09445a0 100644 (file)
@@ -1,3 +1,9 @@
+2003-01-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/3902
+       * parser.c (cp_parser_decl_specifier_seq): Cannot have constructor
+       inside a declarator.
+
 2003-01-27  Nathan Sidwell  <nathan@codesourcery.com>
 
        * class.c (update_vtable_entry_for_fn): Add index parameter.
index 7e172ab..1561f4c 100644 (file)
@@ -6518,8 +6518,8 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
 {
   tree decl_specs = NULL_TREE;
   bool friend_p = false;
-  bool constructor_possible_p = true;
-
+  bool constructor_possible_p = !parser->in_declarator_p;
+  
   /* Assume no class or enumeration type is declared.  */
   *declares_class_or_enum = false;
 
index dcf4842..cc38d83 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/3902
+       * g++.dg/parse/template5.C: New test.
+
 2003-01-28  Toon Moene  <toon@moene.indiv.nluug.nl>
 
        PR fortran/9258
diff --git a/gcc/testsuite/g++.dg/parse/template5.C b/gcc/testsuite/g++.dg/parse/template5.C
new file mode 100644 (file)
index 0000000..adc5986
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do compile }
+
+// Copyright (C) 2003 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 28 Jan 2003 <nathan@codesourcery.com>
+
+// PR 3902. More type/decl confusion.
+
+template <class T>
+struct S
+{
+  S foo (T (T));
+  S foo (T(const T&));
+};
+
+int main ()
+{
+  S<int> (S<int>::*pf1)(int (int)) = &S<int>::foo;
+  S<int> (S<int>::*pf2)(int (const int&)) = &S<int>::foo;
+}