Bug 50491 - [C++0x] [4.6/4.7 Regression] "unexpected ast of kind using_decl" on call to using'ed grandparent member function
Summary: [C++0x] [4.6/4.7 Regression] "unexpected ast of kind using_decl" on call to u...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.2
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-22 23:10 UTC by Jeffrey Yasskin
Modified: 2011-09-23 00:56 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2011-09-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeffrey Yasskin 2011-09-22 23:10:26 UTC
$ cat test.ii
struct GrandParent {
  void *get();
};

template<class OBJ>
struct Parent : public GrandParent{
};

template<typename T>
struct Child : public Parent<T> {
  using GrandParent::get;
  void Foo() {
    void* ex = get();
  }
};

$ clang++ -std=gnu++0x -fsyntax-only test.ii

$ g++-4.6 --version
g++-4.6 (GCC) 4.6.1

$ g++-4.6 -std=gnu++0x -fsyntax-only test.ii
test.ii: In member function 'void Child<T>::Foo()':
test.ii:13:20: sorry, unimplemented: unexpected ast of kind using_decl
test.ii:13: confused by earlier errors, bailing out

$ g++-4.7svn --version
g++-4.7svn (GCC) 4.7.0 20110911 (experimental)

$ g++-4.7svn -std=gnu++0x -fsyntax-only test.ii
test.ii: In member function ‘void Child<T>::Foo()’:
test.ii:13:20: sorry, unimplemented: unexpected ast of kind using_decl
test.ii:13:20: internal compiler error: in potential_constant_expression_1, at cp/semantics.c:8226


If I change the "get()" line to "(void)get();", g++-4.6.1 succeeds, but g++-4.7 still fails with the same error. Making GrandParent non-dependent by passing a concrete type to Parent<> makes both versions succeed.
Comment 1 Jeffrey Yasskin 2011-09-22 23:14:35 UTC
Both g++ versions also succeed when passed -std=c++98.
Comment 2 Paolo Carlini 2011-09-22 23:39:46 UTC
Yes. Luckily the issue seems easy to fix.
Comment 3 Jonathan Wakely 2011-09-22 23:52:15 UTC
This fixes the ICE but I don't know if it's correct and haven't run the testsuite:

Index: semantics.c
===================================================================
--- semantics.c (revision 178930)
+++ semantics.c (working copy)
@@ -7751,6 +7751,7 @@
       /* We can see a FIELD_DECL in a pointer-to-member expression.  */
     case FIELD_DECL:
     case PARM_DECL:
+    case USING_DECL:
       return true;
 
     case AGGR_INIT_EXPR:
Comment 4 paolo@gcc.gnu.org 2011-09-23 00:54:38 UTC
Author: paolo
Date: Fri Sep 23 00:54:32 2011
New Revision: 179109

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179109
Log:
/cp
2011-09-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50491
	* semantics.c (potential_constant_expression_1): Handle USING_DECL.

/testsuite
2011-09-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50491
	* g++.dg/cpp0x/pr50491.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr50491.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/semantics.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 paolo@gcc.gnu.org 2011-09-23 00:55:20 UTC
Author: paolo
Date: Fri Sep 23 00:55:16 2011
New Revision: 179110

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=179110
Log:
/cp
2011-09-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50491
	* semantics.c (potential_constant_expression_1): Handle USING_DECL.

/testsuite
2011-09-22  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50491
	* g++.dg/cpp0x/pr50491.C: New.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/pr50491.C
Modified:
    branches/gcc-4_6-branch/gcc/cp/ChangeLog
    branches/gcc-4_6-branch/gcc/cp/semantics.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 6 Paolo Carlini 2011-09-23 00:56:34 UTC
Fixed mainline and 4.6.2.