Bug 37875 - [c++0x] misinterpreted closing angle bracket in decltype operand
Summary: [c++0x] misinterpreted closing angle bracket in decltype operand
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.3
Assignee: Jason Merrill
URL:
Keywords: monitored, rejects-valid
Depends on:
Blocks:
 
Reported: 2008-10-20 11:12 UTC by Eelis
Modified: 2009-10-18 05:17 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-10-12 05:51:46


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eelis 2008-10-20 11:12:03 UTC
I think g++ incorrectly rejects the following code when compiled with -std=c++0x:

  template <typename> struct X {};
  X<decltype(1 > 2)> x;
    // t.cpp:2: error: template argument 1 is invalid
    // t.cpp:2: error: invalid type in declaration before ‘;’ token

For comparison, here is very similar code that is accepted:

  template <int> struct Y {};
  Y<sizeof(1 > 2)> y;

Hence, I suspect it is a problem with decltype.
Comment 1 Volker Reichelt 2008-12-28 23:08:38 UTC
Confirmed.

Btw, the following is accepted:

  template <typename> struct X {};
  X<decltype((1 > 2))> x;
Comment 2 Jason Merrill 2009-10-12 21:04:49 UTC
Subject: Bug 37875

Author: jason
Date: Mon Oct 12 21:04:35 2009
New Revision: 152686

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152686
Log:
	PR c++/37875
	* parser.c (cp_parser_decltype): Set greater_than_is_operator_p.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype18.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 3 Jason Merrill 2009-10-12 21:49:26 UTC
Fixed for 4.5; will backport for 4.4.3 once branch reopens.
Comment 4 Jason Merrill 2009-10-18 05:13:29 UTC
Subject: Bug 37875

Author: jason
Date: Sun Oct 18 05:13:05 2009
New Revision: 152966

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=152966
Log:
	PR c++/38798
	* parser.c (CP_PARSER_FLAGS_NO_TYPE_DEFINITIONS): New.
	(cp_parser_type_specifier): Don't try to parse a class-specifier
	or enum-specifier in that case.
	(cp_parser_trailing_type_id): New.
	(cp_parser_late_return_type_opt): Call it.
	(cp_parser_type_id_1): Add is_trailing_return parm.
	(cp_parser_type_specifier_seq): Likewise.

	PR c++/40092
	* tree.c (cp_tree_equal): Add test for TEMPLATE_PARM_PARAMETER_PACK
	equality.

	PR c++/37875
	* parser.c (cp_parser_decltype): Set greater_than_is_operator_p.

	PR c++/37766
	* pt.c (type_unification_real): Call convert_template_argument
	for function default template arguments.
	(check_default_tmpl_args): Suggest -std=c++0x when function default
	template args seen in C++98 mode.

	PR c++/37204
	* typeck.c (build_reinterpret_cast_1): Handle rvalue refs
	properly.


Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/decltype18.C
      - copied unchanged from r152686, trunk/gcc/testsuite/g++.dg/cpp0x/decltype18.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C
      - copied unchanged from r152686, trunk/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg1.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/rv-reinterpret.C
      - copied unchanged from r152661, trunk/gcc/testsuite/g++.dg/cpp0x/rv-reinterpret.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/trailing1.C
      - copied unchanged from r152924, trunk/gcc/testsuite/g++.dg/cpp0x/trailing1.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/trailing2.C
      - copied unchanged from r152924, trunk/gcc/testsuite/g++.dg/cpp0x/trailing2.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/trailing3.C
      - copied unchanged from r152924, trunk/gcc/testsuite/g++.dg/cpp0x/trailing3.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/trailing4.C
      - copied unchanged from r152924, trunk/gcc/testsuite/g++.dg/cpp0x/trailing4.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/trailing5.C
      - copied unchanged from r152924, trunk/gcc/testsuite/g++.dg/cpp0x/trailing5.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/vt-40092.C
      - copied unchanged from r152751, trunk/gcc/testsuite/g++.dg/cpp0x/vt-40092.C
Removed:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/auto12.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/auto13.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/auto6.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/auto8.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/parser.c
    branches/gcc-4_4-branch/gcc/cp/pt.c
    branches/gcc-4_4-branch/gcc/cp/tree.c
    branches/gcc-4_4-branch/gcc/cp/typeck.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 5 Jason Merrill 2009-10-18 05:17:40 UTC
Fixed for 4.4.3.
Comment 6 Jason Merrill 2009-10-18 05:17:58 UTC
.