Hi!
On the following testcase we ICE because name is BIT_NOT_EXPR and
suggest_alternative_in_scoped_enum assumes it is called on IDENTIFIER_NODE
only.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
There is another issue, starting with 7.x we don't use sensible location in
the diagnostics, 6.x emitted
pr89390.C: In function ‘void foo()’:
pr89390.C:9:3: error: ‘~A’ is not a member of ‘A’
A::~A (); // { dg-error "'~A' is not a member of 'A'" }
^
but 7.x and later emits:
In function ‘void foo()’:
cc1plus: error: ‘~A’ is not a member of ‘A’
This patch doesn't deal with that, but would be nice to provide location,
dunno if it is enough to just use location of ~, or if we need to spend
memory and build ~A as combined range with caret on ~.
2019-02-18 Jakub Jelinek <[email protected]>
PR c++/89390
* error.c (qualified_name_lookup_error): Only call
suggest_alternative_in_scoped_enum if name is IDENTIFIER_NODE.
* g++.dg/diagnostic/pr89390.C: New test.
--- gcc/cp/error.c.jj 2019-01-17 09:03:11.486787567 +0100
+++ gcc/cp/error.c 2019-02-18 20:56:48.047604338 +0100
@@ -4276,7 +4276,7 @@ qualified_name_lookup_error (tree scope,
else
{
name_hint hint;
- if (SCOPED_ENUM_P (scope))
+ if (SCOPED_ENUM_P (scope) && TREE_CODE (name) == IDENTIFIER_NODE)
hint = suggest_alternative_in_scoped_enum (name, scope);
if (const char *suggestion = hint.suggestion ())
{
--- gcc/testsuite/g++.dg/diagnostic/pr89390.C.jj 2019-02-18
20:58:47.358646700 +0100
+++ gcc/testsuite/g++.dg/diagnostic/pr89390.C 2019-02-18 20:58:13.746198205
+0100
@@ -0,0 +1,10 @@
+// PR c++/89390
+// { dg-do compile { target c++11 } }
+
+enum class A { B, C };
+
+void
+foo ()
+{
+ A::~A (); // { dg-error "'~A' is not a member of 'A'" "" { target *-*-* }
0 }
+}
Jakub