From: Andrew Pinski Date: Thu, 15 Jan 2009 22:10:24 +0000 (+0000) Subject: re PR c++/29388 (ICE with invalid nested name specifier) X-Git-Tag: releases/gcc-4.4.0~851 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a2712544dcf3e154674455f0143c3a5974011b61;p=thirdparty%2Fgcc.git re PR c++/29388 (ICE with invalid nested name specifier) 2009-01-15 Andrew Pinski PR C++/29388 * decl.c (grokdeclarator): Check for a non namespace/class context. 2009-01-15 Andrew Pinski PR C++/29388 * g++.dg/template/error37.C: New testcase. From-SVN: r143411 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4b23d3193635..57ae7570d5fd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2009-01-15 Andrew Pinski + + PR C++/29388 + * decl.c (grokdeclarator): Check for a non namespace/class context. + 2009-01-15 Jason Merrill PR c++/36334 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c6ed22d6e743..8476959bff44 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 198ba977e5b0..3e46d1fc9717 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-01-15 Andrew Pinski + + PR C++/29388 + * g++.dg/template/error37.C: New testcase. + 2009-01-15 Jason Merrill 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 index 000000000000..7f1f9ed783d6 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/error37.C @@ -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 struct A +{ + typedef int T; + void foo(); +}; + +template void A::T::foo() {} // { dg-error "" }