]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/29388 (ICE with invalid nested name specifier)
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Thu, 15 Jan 2009 22:10:24 +0000 (22:10 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Thu, 15 Jan 2009 22:10:24 +0000 (14:10 -0800)
2009-01-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/29388
        * decl.c (grokdeclarator): Check for a non namespace/class context.

2009-01-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR C++/29388
        * g++.dg/template/error37.C: New testcase.

From-SVN: r143411

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

index 4b23d3193635c656c75954e89a5aa15b21c7dd38..57ae7570d5fd5f3ff880686e9d2329d882bde3a5 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR C++/29388
+       * decl.c (grokdeclarator): Check for a non namespace/class context.
+
 2009-01-15  Jason Merrill  <jason@redhat.com>
 
        PR c++/36334
index c6ed22d6e7435f69df8faca9dc1ff78ae3368a3b..8476959bff44976f44ae31428d85c229d6b0560d 100644 (file)
@@ -9285,6 +9285,13 @@ grokdeclarator (const cp_declarator *declarator,
                       "declared out of global scope", name);
          }
 
+       if (ctype != NULL_TREE
+           && TREE_CODE (ctype) != NAMESPACE_DECL && !MAYBE_CLASS_TYPE_P (ctype))
+         {
+           error ("%q#T is not a class or a namespace", ctype);
+           ctype = NULL_TREE;
+         }
+
        if (ctype == NULL_TREE)
          {
            if (virtualp)
index 198ba977e5b045f85a1113af87d0281f7ddef49c..3e46d1fc97177b6912dddd9b4e8fa9ec776517d2 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+        PR C++/29388
+       * g++.dg/template/error37.C: New testcase.
+
 2009-01-15  Jason Merrill  <jason@redhat.com>
 
        PR c++/36334
diff --git a/gcc/testsuite/g++.dg/template/error37.C b/gcc/testsuite/g++.dg/template/error37.C
new file mode 100644 (file)
index 0000000..7f1f9ed
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// PR C++/29388
+// We used to ICE in is_ancestor because we would use int as the context of foo
+// but that is invalid.
+
+template<int> struct A
+{
+         typedef int T;
+           void foo();
+};
+
+template<int N> void A<N>::T::foo() {} // { dg-error "" }