Commit a633b93e by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/51401 ([c++0x] [4.7 Regression] ICE with invalid use of auto in template)

	PR c++/51401
	* decl.c (grokdeclarator): Error for auto on non-static data members.

	* g++.dg/cpp0x/auto7.C: Adjust expected error message.
	* g++.dg/cpp0x/auto29.C: New test.

From-SVN: r182097
parent 2df708d9
2011-12-07 Jakub Jelinek <jakub@redhat.com> 2011-12-07 Jakub Jelinek <jakub@redhat.com>
PR c++/51401
* decl.c (grokdeclarator): Error for auto on non-static data members.
PR c++/51429 PR c++/51429
* typeck2.c (cxx_incomplete_type_diagnostic): Don't * typeck2.c (cxx_incomplete_type_diagnostic): Don't
ICE if TREE_OPERAND (value, 1) is overloaded. ICE if TREE_OPERAND (value, 1) is overloaded.
......
...@@ -9971,6 +9971,12 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -9971,6 +9971,12 @@ grokdeclarator (const cp_declarator *declarator,
} }
else if (decl_context == FIELD) else if (decl_context == FIELD)
{ {
if (!staticp && type_uses_auto (type))
{
error ("non-static data member declared %<auto%>");
type = error_mark_node;
}
/* The C99 flexible array extension. */ /* The C99 flexible array extension. */
if (!staticp && TREE_CODE (type) == ARRAY_TYPE if (!staticp && TREE_CODE (type) == ARRAY_TYPE
&& TYPE_DOMAIN (type) == NULL_TREE) && TYPE_DOMAIN (type) == NULL_TREE)
......
2011-12-07 Jakub Jelinek <jakub@redhat.com> 2011-12-07 Jakub Jelinek <jakub@redhat.com>
PR c++/51401
* g++.dg/cpp0x/auto7.C: Adjust expected error message.
* g++.dg/cpp0x/auto29.C: New test.
PR c++/51429 PR c++/51429
* g++.dg/parse/error45.C: New test. * g++.dg/parse/error45.C: New test.
......
// PR c++/51401
// { dg-do compile }
// { dg-options "-std=c++11" }
template <int>
struct A
{
auto i; // { dg-error "non-static data member declared" }
};
template <int>
struct B
{
auto i = 0; // { dg-error "non-static data member declared" }
};
struct C
{
auto i; // { dg-error "non-static data member declared" }
};
struct D
{
auto i = 0; // { dg-error "non-static data member declared" }
};
...@@ -9,5 +9,5 @@ template<int> struct A ...@@ -9,5 +9,5 @@ template<int> struct A
{ {
static auto k = 7; // { dg-error "non-const" } static auto k = 7; // { dg-error "non-const" }
static auto l; // { dg-error "has no initializer" } static auto l; // { dg-error "has no initializer" }
auto m; // { dg-error "has no initializer" } auto m; // { dg-error "non-static data member declared" }
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment