PR c++/18757
* parser.c (cp_parser_template_id): Don't create a CPP_TEMPLATE_ID
if parsing failed.
gcc/testsuite/ChangeLog:
* g++.dg/parse/typename5.C: Adjust for new error.
* g++.dg/parse/typename7.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91935
138bc75d-0d04-0410-961f-
82ee72b054a4
+2004-12-09 Alexandre Oliva <aoliva@redhat.com>
+
+ PR c++/18757
+ * parser.c (cp_parser_template_id): Don't create a CPP_TEMPLATE_ID
+ if parsing failed.
+
2004-12-09 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/18073
should we re-parse the token stream, we will not have to repeat
the effort required to do the parse, nor will we issue duplicate
error messages about problems during instantiation of the
- template. */
- if (start_of_id)
+ template. Do so only if parsing succeeded, otherwise we may
+ silently accept template arguments with syntax errors. */
+ if (start_of_id && !cp_parser_error_occurred (parser))
{
cp_token *token = cp_lexer_token_at (parser->lexer, start_of_id);
+2004-12-09 Alexandre Oliva <aoliva@redhat.com>
+
+ * g++.dg/parse/typename5.C: Adjust for new error.
+ * g++.dg/parse/typename7.C: New.
+
2004-12-09 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/18073
template <typename> struct B
{
- typedef A<typename X::Y> C; // { dg-error "declared|invalid|no type" }
+ typedef A<typename X::Y> C; // { dg-error "declared|invalid|no type|expected" }
};
--- /dev/null
+// { dg-do compile }
+
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de> and
+// Alexandre Oliva <aoliva@redhat.com>
+
+// PR c++/18757: ICE in get_innermost_template_args
+
+struct A
+{
+ template<typename> void foo(int);
+ template<typename T> void bar(T t) {
+ this->foo<typename T>(t); } // { dg-error "expected" }
+ template<typename T> void bad(T t) {
+ foo<typename T>(t); } // { dg-error "expected" }
+};
+
+template <typename T>
+struct B
+{
+ void bar(T t) {
+ A().bar<typename T>(t); } // { dg-error "expected" }
+ void bad(T t) {
+ B<typename T>::bar(t); } // { dg-error "invalid|not a template" }
+};
+
+void baz()
+{
+ A().bar(0);
+ A().bad(0);
+ B<int>().bar(0);
+}