OSDN Git Service

PR c++/50298
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Sep 2011 17:11:49 +0000 (17:11 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 Sep 2011 17:11:49 +0000 (17:11 +0000)
* parser.c (cp_parser_member_declaration): Don't require a constant
rvalue here in C++0x.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@178652 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-ref3.C [new file with mode: 0644]

index ea67d2d..1c6c5a1 100644 (file)
@@ -1,5 +1,9 @@
 2011-09-07  Jason Merrill  <jason@redhat.com>
 
+       PR c++/50298
+       * parser.c (cp_parser_member_declaration): Don't require a constant
+       rvalue here in C++0x.
+
        * pt.c (type_unification_real): Correct complain arg for tsubsting
        default template args.
 
index 7d766d1..6346aa0 100644 (file)
@@ -18187,6 +18187,17 @@ cp_parser_member_declaration (cp_parser* parser)
                  initializer_token_start = cp_lexer_peek_token (parser->lexer);
                  if (function_declarator_p (declarator))
                    initializer = cp_parser_pure_specifier (parser);
+                 else if (cxx_dialect >= cxx0x)
+                   {
+                     bool nonconst;
+                     /* Don't require a constant rvalue in C++11, since we
+                        might want a reference constant.  We'll enforce
+                        constancy later.  */
+                     cp_lexer_consume_token (parser->lexer);
+                     /* Parse the initializer.  */
+                     initializer = cp_parser_initializer_clause (parser,
+                                                                 &nonconst);
+                   }
                  else
                    /* Parse the initializer.  */
                    initializer = cp_parser_constant_initializer (parser);
index 5247ac6..f3d6ddb 100644 (file)
@@ -1,5 +1,7 @@
 2011-09-07  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/constexpr-ref3.C: New.
+
        * g++.dg/cpp0x/sfinae11.C: Check for explanatory diagnostic.
 
 2011-09-07  Georg-Johann Lay  <avr@gjlay.de>
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-ref3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-ref3.C
new file mode 100644 (file)
index 0000000..24cc9c8
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/50298
+// { dg-options -std=c++0x }
+
+int global_variable;
+
+template <class T> struct X {
+  static constexpr T r = global_variable;
+};
+
+X<int&> x;