aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-01-03 20:25:16 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-01-03 20:25:16 +0000
commit2b59b5284fe61754d1b91d9a43a8ecba27644c42 (patch)
tree11d31f2ae11eccff2f30dd820196cc858c6990c1 /gcc
parent0239db9272f141e7cdc0844eaf9cb7011e71ce24 (diff)
downloadgcc-2b59b5284fe61754d1b91d9a43a8ecba27644c42.zip
gcc-2b59b5284fe61754d1b91d9a43a8ecba27644c42.tar.gz
gcc-2b59b5284fe61754d1b91d9a43a8ecba27644c42.tar.bz2
re PR c++/51738 (C++11 initializer list does not work correctly with operator[])
/gcc/cp 2012-01-03 Paolo Carlini <paolo.carlini@oracle.com> PR c++/51738 * parser.c (cp_parser_postfix_open_square_expression): Handle postfix-expression [ braced-init-list ]. /gcc/testsuite 2012-01-03 Paolo Carlini <paolo.carlini@oracle.com> PR c++/51738 * g++.dg/cpp0x/initlist-postfix-open-square.C: New. /libstdc++-v3 2012-01-03 Paolo Carlini <paolo.carlini@oracle.com> PR c++/51738 * testsuite/23_containers/map/element_access/39901.cc: New. From-SVN: r182856
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/parser.c12
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/initlist-postfix-open-square.C18
4 files changed, 40 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a5387da..f4f491d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,11 @@
2012-01-03 Paolo Carlini <paolo.carlini@oracle.com>
+ PR c++/51738
+ * parser.c (cp_parser_postfix_open_square_expression): Handle
+ postfix-expression [ braced-init-list ].
+
+2012-01-03 Paolo Carlini <paolo.carlini@oracle.com>
+
PR c++/29273
* rtti.c (build_dynamic_cast_1): In case of T a pointer type,
call decay_conversion on v.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7e6915c..8f2357e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -5831,6 +5831,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
by cp_parser_builtin_offsetof. We're looking for
postfix-expression [ expression ]
+ postfix-expression [ braced-init-list ] (C++11)
FOR_OFFSETOF is set if we're being called in that context, which
changes how we deal with integer constant expressions. */
@@ -5856,7 +5857,16 @@ cp_parser_postfix_open_square_expression (cp_parser *parser,
if (for_offsetof)
index = cp_parser_constant_expression (parser, false, NULL);
else
- index = cp_parser_expression (parser, /*cast_p=*/false, NULL);
+ {
+ if (cp_lexer_next_token_is (parser->lexer, CPP_OPEN_BRACE))
+ {
+ bool expr_nonconst_p;
+ maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
+ index = cp_parser_braced_list (parser, &expr_nonconst_p);
+ }
+ else
+ index = cp_parser_expression (parser, /*cast_p=*/false, NULL);
+ }
/* Look for the closing `]'. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e7ad900..8fa86a8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-03 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/51738
+ * g++.dg/cpp0x/initlist-postfix-open-square.C: New.
+
2012-01-03 Andrew Pinski <apinski@cavium.com>
* lib/scanasm.exp (dg-function-on-line): Always use a special format
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-postfix-open-square.C b/gcc/testsuite/g++.dg/cpp0x/initlist-postfix-open-square.C
new file mode 100644
index 0000000..38b1782
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-postfix-open-square.C
@@ -0,0 +1,18 @@
+// PR c++/51738
+// { dg-options -std=c++0x }
+
+struct Index
+{
+ Index(unsigned, unsigned){ }
+};
+
+struct Matrix
+{
+ void operator[](Index){ }
+};
+
+int main()
+{
+ Matrix m;
+ m[{0,1}];
+}