OSDN Git Service

gcc/cp/
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Mar 2009 13:36:33 +0000 (13:36 +0000)
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Mar 2009 13:36:33 +0000 (13:36 +0000)
2009-03-27  Andrew Pinski  <andrew_pinski@playstation.sony.com>

PR c++/38638
* parser.c (cp_parser_elaborated_type_specifier): If we have a
typename tag and don't have either a TYPE_DECL or a
TEMPLATE_ID_EXPR, set the type to NULL.

gcc/testsuite/

2009-03-27  Andrew Pinski  <andrew_pinski@playstation.sony.com>

PR c++/38638
* g++.dg/template/typename17.C: New testcase.
* g++.dg/template/typename18.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145107 138bc75d-0d04-0410-961f-82ee72b054a4

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

index d120594..6fcd92a 100644 (file)
@@ -1,3 +1,10 @@
+2009-03-27  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR c++/38638
+       * parser.c (cp_parser_elaborated_type_specifier): If we have a
+       typename tag and don't have either a TYPE_DECL or a
+       TEMPLATE_ID_EXPR, set the type to NULL.
+
 2009-03-27  Simon Martin  <simartin@users.sourceforge.net>
 
        PR c++/37647
index 02a96cc..63ac070 100644 (file)
@@ -11588,7 +11588,11 @@ cp_parser_elaborated_type_specifier (cp_parser* parser,
        type = make_typename_type (parser->scope, decl,
                                   typename_type,
                                   /*complain=*/tf_error);
-      else
+      /* If the `typename' keyword is in effect and DECL is not a type
+        decl. Then type is non existant.   */
+      else if (tag_type == typename_type && TREE_CODE (decl) != TYPE_DECL)
+        type = NULL_TREE; 
+      else 
        type = TREE_TYPE (decl);
     }
 
index 1a3843e..c5e9545 100644 (file)
@@ -1,5 +1,11 @@
 2009-03-27  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
+       PR c++/38638
+       * g++.dg/template/typename17.C: New testcase.
+       * g++.dg/template/typename18.C: New testcase.
+
+2009-03-27  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
        PR c++/36799
        * g++.dg/other/var_copy-1.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/template/typename17.C b/gcc/testsuite/g++.dg/template/typename17.C
new file mode 100644 (file)
index 0000000..748b1f7
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-do compile }
+
+// This should fail as A::foo<0> is not a typename at all.
+struct A
+{
+  template<int> void foo(int i)
+  {
+    typename A::foo<0>(i1); // { dg-error "" }
+  }
+};
diff --git a/gcc/testsuite/g++.dg/template/typename18.C b/gcc/testsuite/g++.dg/template/typename18.C
new file mode 100644 (file)
index 0000000..4134ef6
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile }
+
+// These typename should work as they are types.
+struct A
+{
+  typedef int a;
+  template <int>
+  struct f {};
+  template<int> void foo(int i)
+  {
+    typename A::a(i1);
+    typename A::f<0>(i2);
+  }
+};