diff mbox

[C++] PR 59361

Message ID 53BA6AFA.1050605@oracle.com
State New
Headers show

Commit Message

Paolo Carlini July 7, 2014, 9:40 a.m. UTC
Hi,

in April Andrew figured out that:

"The problem occurs in cp_parser_cast_expression. A term of having the 
form (T())... cannot be parsed as a cast expression since the the 
expansion is only applied to a part of the cast expression. If ... 
follows the closing paren, the expression must be parsed as unary 
expression."

Today I simplified a bit his patch, moving the CPP_ELLIPSIS handling 
inside cp_parser_tokens_start_cast_expression. Tested x86_64-linux.

Thanks,
Paolo.

//////////////////////
/cp
2014-07-07  Andrew Sutton  <andrew.n.sutton@gmail.com>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/59361
	* parser.c (cp_parser_tokens_start_cast_expression): Return 0 for
	CPP_ELLIPSIS too.

/testsuite
2014-07-07  Andrew Sutton  <andrew.n.sutton@gmail.com>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/59361
	* g++.dg/cpp0x/vt-59361.C: New.

Comments

Jason Merrill July 9, 2014, 1:04 a.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 212324)
+++ cp/parser.c	(working copy)
@@ -7666,6 +7666,7 @@  cp_parser_tokens_start_cast_expression (cp_parser
     case CPP_OR:
     case CPP_OR_OR:
     case CPP_EOF:
+    case CPP_ELLIPSIS:
       return 0;
 
     case CPP_OPEN_PAREN:
Index: testsuite/g++.dg/cpp0x/vt-59361.C
===================================================================
--- testsuite/g++.dg/cpp0x/vt-59361.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/vt-59361.C	(working copy)
@@ -0,0 +1,20 @@ 
+// PR c++/59361
+// { dg-do compile { target c++11 } }
+
+template<bool ...Bs>
+struct and_ 
+{
+  constexpr static bool value{true};
+};
+
+template<typename T>
+struct true_
+{
+  constexpr operator bool() const { return true; }
+};
+
+template<typename ...Ts>
+constexpr bool foo(Ts...)
+{
+  return and_<(true_<Ts>())...>::value;
+}