diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-08 10:23:53 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-08 10:23:53 +0000 |
commit | 4ac56fde83c3d304f1dabe96946e25f422e374f7 (patch) | |
tree | 39b0e29d39ac466b25e2858b4fdd2c26bedf6590 /gcc | |
parent | 085c0ba662d4e924287d8fa571e637262b32e87f (diff) | |
download | gcc-4ac56fde83c3d304f1dabe96946e25f422e374f7.tar.gz |
/cp
2011-11-08 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50864
* parser.c (cp_parser_postfix_dot_deref_expression): Reject invalid
uses of '->' and '.' as postfix-expression in namespace scope.
/testsuite
2011-11-08 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/50864
* g++.dg/parse/template26.C: New.
* g++.dg/template/crash45.C: Adjust dg-error string.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181151 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/template26.C | 18 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/crash45.C | 2 |
5 files changed, 42 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 98e0fe36fc0..5a492e9ca20 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-11-08 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/50864 + * parser.c (cp_parser_postfix_dot_deref_expression): Reject invalid + uses of '->' and '.' as postfix-expression in namespace scope. + 2011-11-07 Jason Merrill <jason@redhat.com> PR c++/50848 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 697be809adb..7d04971eea5 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5969,10 +5969,17 @@ cp_parser_postfix_dot_deref_expression (cp_parser *parser, { if (name != error_mark_node && !BASELINK_P (name) && parser->scope) { - name = build_qualified_name (/*type=*/NULL_TREE, - parser->scope, - name, - template_p); + if (TREE_CODE (parser->scope) == NAMESPACE_DECL) + { + error_at (token->location, "%<%D::%D%> is not a class member", + parser->scope, name); + postfix_expression = error_mark_node; + } + else + name = build_qualified_name (/*type=*/NULL_TREE, + parser->scope, + name, + template_p); parser->scope = NULL_TREE; parser->qualifying_scope = NULL_TREE; parser->object_scope = NULL_TREE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 875e0997d21..12ad3d45dc7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-11-08 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/50864 + * g++.dg/parse/template26.C: New. + * g++.dg/template/crash45.C: Adjust dg-error string. + 2011-11-07 Jason Merrill <jason@redhat.com> PR c++/50848 diff --git a/gcc/testsuite/g++.dg/parse/template26.C b/gcc/testsuite/g++.dg/parse/template26.C new file mode 100644 index 00000000000..aab9763ccaf --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template26.C @@ -0,0 +1,18 @@ +// PR c++/50864 + +namespace impl +{ + template <class T> T create(); +} + +template <class T, class U, __SIZE_TYPE__ + = sizeof(impl::create<T>()->*impl::create<U>())> +struct foo1; + +template <class T, class U, __SIZE_TYPE__ + = sizeof(impl::create<T>()->impl::create<U>())> // { dg-error "not a class member" } +struct foo2; + +template <class T, class U, __SIZE_TYPE__ + = sizeof(impl::create<T>().impl::create<U>())> // { dg-error "not a class member" } +struct foo3; diff --git a/gcc/testsuite/g++.dg/template/crash45.C b/gcc/testsuite/g++.dg/template/crash45.C index f138e3d6169..f67fd022f63 100644 --- a/gcc/testsuite/g++.dg/template/crash45.C +++ b/gcc/testsuite/g++.dg/template/crash45.C @@ -9,5 +9,5 @@ namespace N void bar(A *p) { - p->N::foo<0>; // { dg-error "not a member" } + p->N::foo<0>; // { dg-error "not a class member" } } |