Bug 52841 - [4.7 Regression] error: type 'Solvable' is not a base type for type 'Resolvable'
Summary: [4.7 Regression] error: type 'Solvable' is not a base type for type 'Resolvable'
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P2 normal
Target Milestone: 4.7.2
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 53247 53368 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-04-03 12:13 UTC by Richard Biener
Modified: 2012-06-14 12:55 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.6.3, 4.8.0
Known to fail:
Last reconfirmed: 2012-04-12 00:00:00


Attachments
return earlier in cp_parser_alias_declaration (239 bytes, patch)
2012-04-17 21:06 UTC, fabien
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Biener 2012-04-03 12:13:48 UTC
struct Solvable;
namespace sat
{
  class Solvable
    {
  public:
      typedef bool bool_type;
    };
}

class Resolvable : public sat::Solvable
{
public:
  using sat::Solvable::bool_type;
};

when compiled with -std=c++0x is rejected with

T.cc:14:28: error: type 'Solvable' is not a base type for type 'Resolvable'

It works when using

  using Solvable::bool_type

and when

  using ::sat::Solvable::bool_type

and it works without -std=c++0x
Comment 1 Richard Biener 2012-04-03 12:15:51 UTC
The following is rejected as well, with the same error

struct Solvable;
namespace sat
{
  class Solvable
    {
  public:
      typedef bool bool_type;
    };
}
namespace sat2
{
  class Solvable
    {
  public:
      typedef bool bool_type;
    };
}

class Resolvable : public sat::Solvable, sat2::Solvable
{
public:
  using Solvable::bool_type;
};

only qualifying with ::sat[2]::Solvable::bool_type works.
Comment 2 Jonathan Wakely 2012-04-03 13:05:39 UTC
Fabien, could you take a look at this one too?
Comment 3 fabien 2012-04-03 20:06:54 UTC
I'm busy this week, but I will look into it next week.
Comment 4 David Abdurachmanov 2012-04-06 19:39:18 UTC
I can confirm the issue. Run into the problem when re-compiling a project with C++11.

Works fine in C++98/03, does not compile in C++11. Both work-arounds suggested in the first comment works.
Comment 5 Richard Biener 2012-04-12 12:28:55 UTC
Ping?
Comment 6 fabien 2012-04-12 12:50:31 UTC
(In reply to comment #5)
> Ping?

I haven't yet finished the investigation. Something is broken in c++11 mode, the parsing of Solvable in "using sat::Solvable::bool_type;" is failing in c++11 mode, debug_tree() is crashing while debugging it.
Comment 7 fabien 2012-04-17 21:06:52 UTC
Created attachment 27180 [details]
return earlier in cp_parser_alias_declaration
Comment 8 fabien 2012-04-17 21:08:13 UTC
It is related to alias declarations. It seems that we do not recover properly from a failure in cp_parser_alias_declaration, in the block introduced by this check: "if (!(flags & CP_PARSER_FLAGS_NO_USER_DEFINED_TYPES))", around here:

#0  cp_parser_simple_type_specifier (parser=0x7ffff571b738, decl_specs=0x7fffffffdd00, flags=1) at ../../gcc/gcc/cp/parser.c:13651
#1  0x00000000006be5e0 in cp_parser_type_specifier (parser=0x7ffff571b738, flags=1, decl_specs=0x7fffffffdd00, is_declaration=0 '\000', declares_class_or_enum=0x0, is_cv_qualifier=0x7fffffffdcde "") at ../../gcc/gcc/cp/parser.c:13434
#2  0x00000000006c5c96 in cp_parser_type_specifier_seq (parser=0x7ffff571b738, is_declaration=0 '\000', is_trailing_return=0 '\000', type_specifier_seq=0x7fffffffdd00) at ../../gcc/gcc/cp/parser.c:16887
#3  0x00000000006c5a63 in cp_parser_type_id_1 (parser=0x7ffff571b738, is_template_arg=0 '\000', is_trailing_return=0 '\000') at ../../gcc/gcc/cp/parser.c:16771
#4  0x00000000006c5b57 in cp_parser_type_id (parser=0x7ffff571b738) at ../../gcc/gcc/cp/parser.c:16810
#5  0x00000000006c1987 in cp_parser_alias_declaration (parser=0x7ffff571b738) at ../../gcc/gcc/cp/parser.c:15101

I can't find what goes wrong there. The good news is that it seems to work if we return earlier in cp_parser_alias_declaration -- which I think is better --, like in the attached patch.

Perhaps Dodji (or Jason) can take a closer look ?
Comment 9 Richard Biener 2012-05-03 11:23:33 UTC
Ping?
Comment 10 fabien 2012-05-04 19:45:46 UTC
I no longer work on it, so it is more honest to set this bug as unassigned.

The patch I attached here fixes the problem, because it bypasses a deeper issues.
Returning the earliest possible in cp_parser_alias_declaration makes sense to me because there are probably much more using-declarations than alias-declarations to parse at the moment. However, I do not want to submit it because I think we should fix the real issue as well.

I had a look on non-matching parse_tentatively/definitely, without finding anything suspect. If one needs some details about what goes wrong -- if I was unclear here and in previous comments --, do not hesitate to ask me.
Comment 11 Jonathan Wakely 2012-05-04 19:50:04 UTC
then it should really be status=NEW, you're not waiting for details from the reporter
Comment 12 fabien 2012-05-05 17:57:27 UTC
*** Bug 53247 has been marked as a duplicate of this bug. ***
Comment 13 Paul Pluzhnikov 2012-05-16 03:09:56 UTC
*** Bug 53368 has been marked as a duplicate of this bug. ***
Comment 14 H.J. Lu 2012-05-16 03:22:36 UTC
This is triggered by revision 181118:

http://gcc.gnu.org/ml/gcc-cvs/2011-11/msg00406.html
Comment 15 Paul Pluzhnikov 2012-05-30 19:13:02 UTC
I've got another small reproducer, that shows up as a slightly different failure, but very likely is the same problem:

namespace util { }   // comment out => problem disappears
namespace foo {
  namespace util {
    struct Printer {
      struct Convert {
      };
    };
    class XPrinter: Printer {
      // using ::foo::util::Printer::Convert;  // ok
      // using Printer::Convert;               // ok
      using foo::util::Printer::Convert;       // error
    };
  }
}


g++ --version
g++ (GCC) 4.8.0 20120515 (experimental)

g++ -c pp.ii -std=c++11
pp.ii:13:24: error: ‘util::Printer’ has not been declared
       using foo::util::Printer::Convert; // error

g++ -c pp.ii -std=c++98 && echo ok
ok
Comment 16 Richard Biener 2012-06-06 12:22:25 UTC
Author: rguenth
Date: Wed Jun  6 12:22:16 2012
New Revision: 188264

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188264
Log:
2012-06-06  Fabien Chene  <fabien@gcc.gnu.org>

	PR c++/52841
	* parser.c (cp_parser_alias_declaration): Return earlier
	if an error occured.

	* g++.dg/cpp0x/pr52841.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr52841.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
Comment 17 Richard Biener 2012-06-06 12:23:00 UTC
Fixed for trunk for now.
Comment 18 Richard Biener 2012-06-14 08:44:41 UTC
GCC 4.7.1 is being released, adjusting target milestone.
Comment 19 Richard Biener 2012-06-14 12:55:19 UTC
Author: rguenth
Date: Thu Jun 14 12:55:11 2012
New Revision: 188613

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188613
Log:
2012-06-14  Richard Guenther  <rguenther@suse.de>

        Backport from mainline
        2012-06-06  Fabien Chene  <fabien@gcc.gnu.org>

	PR c++/52841
	* parser.c (cp_parser_alias_declaration): Return earlier
	if an error occured.

	* g++.dg/cpp0x/pr52841.C: New testcase.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/pr52841.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/parser.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 20 Richard Biener 2012-06-14 12:55:42 UTC
Fixed.