re PR c++/22172 (Internal compiler error, seg fault.)
authorJames A. Morrison <phython@gcc.gnu.org>
Sat, 8 Oct 2005 18:11:02 +0000 (18:11 +0000)
committerJames A. Morrison <phython@gcc.gnu.org>
Sat, 8 Oct 2005 18:11:02 +0000 (18:11 +0000)
2005-10-08  James A. Morrison  <phython@gcc.gnu.org>

        PR c++/22172
        * parser.c (cp_parser_postfix_expression) <RID_TYPENAME>: Treat nontype
        scopes as nondependent.

From-SVN: r105120

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

index f3f03619bb9692444e0915e887500bccf8c0959c..4055464a28a34f26277dd366a7d5eaa22d0e5949 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-08  James A. Morrison  <phython@gcc.gnu.org>
+
+       PR c++/22172
+       * parser.c (cp_parser_postfix_expression) <RID_TYPENAME>: Treat nontype
+       scopes as nondependent.
+
 2005-10-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        * call.c (resolve_args): Remove redundant test.
index 08af6e2f49b90830e6d201417ee8f97f770a4377..a4eedc17816842116f8e478e620042a148a16246 100644 (file)
@@ -3986,8 +3986,9 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p)
          return error_mark_node;
        /* If we look up a template-id in a non-dependent qualifying
           scope, there's no need to create a dependent type.  */
-       else if (TREE_CODE (id) == TYPE_DECL
-           && !dependent_type_p (parser->scope))
+       if (TREE_CODE (id) == TYPE_DECL
+           && (!TYPE_P (scope)
+               || !dependent_type_p (parser->scope)))
          type = TREE_TYPE (id);
        /* Create a TYPENAME_TYPE to represent the type to which the
           functional cast is being performed.  */
index d189677cebeae5711473eab8318aa8487eb25cdc..811c6cb6dbb6c2336971a9a6688610802c0bdfc0 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-08  James A. Morrison  <phython@gcc.gnu.org>
+
+       PR c++/22172
+       * g++.dg/parse/crash30.C: New test.
+
 2005-10-07  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/24227
diff --git a/gcc/testsuite/g++.dg/parse/crash30.C b/gcc/testsuite/g++.dg/parse/crash30.C
new file mode 100644 (file)
index 0000000..9b68535
--- /dev/null
@@ -0,0 +1,18 @@
+// { dg-do compile }
+namespace N { template<int> struct A { operator int() const; }; }
+namespace M { template<int> struct A {}; }
+namespace P { typedef int I; }
+
+template<typename> void foo()
+{
+  +typename N::A<0>();  // { dg-bogus "expected" }
+}
+
+template<typename> void bar()
+{
+  +typename M::A<0>;  // { dg-error "expected" }
+}
+
+template<typename T> void baz() {
+  typename P::I i;  // { dg-bogus "expected" }
+}