Commit aedf4e12 by Marek Polacek Committed by Marek Polacek

re PR c++/70513 (ICE on invalid C++ code on x86_64-linux-gnu: Segmentation fault)

	PR c++/70513
	* parser.c (cp_parser_enum_specifier): Check and possibly error for
	extra qualification.

	* g++.dg/cpp0x/forw_enum12.C: New test.
	* g++.dg/cpp0x/forw_enum13.C: New test.

From-SVN: r235347
parent 2074d80a
2016-04-21 Marek Polacek <polacek@redhat.com>
PR c++/70513
* parser.c (cp_parser_enum_specifier): Check and possibly error for
extra qualification.
2016-04-20 Nathan Sidwell <nathan@acm.org> 2016-04-20 Nathan Sidwell <nathan@acm.org>
PR c++/55635 PR c++/55635
......
...@@ -17233,6 +17233,16 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -17233,6 +17233,16 @@ cp_parser_enum_specifier (cp_parser* parser)
type, prev_scope, nested_name_specifier); type, prev_scope, nested_name_specifier);
type = error_mark_node; type = error_mark_node;
} }
/* If that scope is the scope where the declaration is being placed
the program is invalid. */
else if (CLASS_TYPE_P (nested_name_specifier)
&& CLASS_TYPE_P (prev_scope)
&& same_type_p (nested_name_specifier, prev_scope))
{
permerror (type_start_token->location,
"extra qualification not allowed");
nested_name_specifier = NULL_TREE;
}
} }
if (scoped_enum_p) if (scoped_enum_p)
2016-04-21 Marek Polacek <polacek@redhat.com>
PR c++/70513
* g++.dg/cpp0x/forw_enum12.C: New test.
* g++.dg/cpp0x/forw_enum13.C: New test.
2016-04-21 Kirill Yukhin <kirill.yukhin@intel.com> 2016-04-21 Kirill Yukhin <kirill.yukhin@intel.com>
PR target/70728 PR target/70728
......
// PR c++/70513
// { dg-do compile { target c++11 } }
struct S1
{
enum E : int;
enum S1::E : int { X } e; // { dg-error "extra qualification not allowed" }
};
struct S2
{
enum class E : int;
enum class S2::E : int { X } e; // { dg-error "extra qualification not allowed" }
};
struct S3
{
enum struct E : int;
enum struct S3::E : int { X } e; // { dg-error "extra qualification not allowed" }
};
struct S4
{
struct S5
{
enum E : char;
enum S4::S5::E : char { X } e; // { dg-error "extra qualification not allowed" }
};
};
// PR c++/70513
// { dg-do compile { target c++11 } }
template <typename T>
class D1
{
enum A : int;
enum D1::A : int { foo } c; // { dg-error "extra qualification not allowed" }
};
template <typename T>
class D2
{
enum A : int;
enum D2<T>::A : int { foo } c; // { dg-error "extra qualification not allowed" }
};
template <typename T>
class D3
{
enum D3::A { foo } c; // { dg-error "extra qualification not allowed" }
};
template <typename T>
class D4
{
enum D4<T>::A { foo } c; // { dg-error "extra qualification not allowed" }
};
template <typename T>
class D5
{
class D6
{
enum D6::A { foo } c; // { dg-error "extra qualification not allowed" }
};
};
template <typename T>
class D7
{
class D8
{
enum A : int;
enum D8::A : int { foo } c; // { dg-error "extra qualification not allowed" }
};
};
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