aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/using-enum-3.C21
4 files changed, 34 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1ce758b..a2d16e1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2019-02-27 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89511 - ICE with using-declaration and unscoped enumerator.
+ * parser.c (cp_parser_using_declaration): For an unscoped enum
+ only use its context if it's not a function declaration.
+
2019-02-27 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/89488
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index d9824e4..5f69403 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -19412,7 +19412,8 @@ cp_parser_using_declaration (cp_parser* parser,
/*is_declaration=*/true);
if (!qscope)
qscope = global_namespace;
- else if (UNSCOPED_ENUM_P (qscope))
+ else if (UNSCOPED_ENUM_P (qscope)
+ && !TYPE_FUNCTION_SCOPE_P (qscope))
qscope = CP_TYPE_CONTEXT (qscope);
if (access_declaration_p && cp_parser_error_occurred (parser))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9d6742c..eff4a81 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-02-27 Marek Polacek <polacek@redhat.com>
+
+ PR c++/89511 - ICE with using-declaration and unscoped enumerator.
+ * g++.dg/cpp0x/using-enum-3.C: New test.
+
2019-02-27 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/89280
diff --git a/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C b/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C
new file mode 100644
index 0000000..edc1689
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/using-enum-3.C
@@ -0,0 +1,21 @@
+// PR c++/89511
+// { dg-do compile { target c++11 } }
+
+void f ()
+{
+ enum e { a };
+ using e::a; // { dg-error "not a namespace or unscoped enum" }
+}
+
+struct S {
+ enum E { A };
+ using E::A; // { dg-error "type .S. is not a base type for type .S." }
+};
+
+namespace N {
+ enum E { B };
+}
+
+struct T {
+ using N::E::B; // { dg-error "using-declaration for non-member at class scope" }
+};