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
+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
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);
}
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.
--- /dev/null
+// { 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 "" }
+ }
+};
--- /dev/null
+// { 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);
+ }
+};