diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2012-09-25 14:44:52 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2012-09-25 14:44:52 +0000 |
commit | 5677bc1fe96a31d293fbea713456b0bcbc581eeb (patch) | |
tree | f40e9d1cf7d28aa731ef197576c07fff191960d0 /gcc | |
parent | c985a8e929684dcbd781778c8fbf7e1edcbecec4 (diff) | |
download | gcc-5677bc1fe96a31d293fbea713456b0bcbc581eeb.zip gcc-5677bc1fe96a31d293fbea713456b0bcbc581eeb.tar.gz gcc-5677bc1fe96a31d293fbea713456b0bcbc581eeb.tar.bz2 |
re PR c++/54526 ([C++11] <:: is incorrectly treated as digraph <: followed by colon)
/cp
2012-09-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54526
* parser.c (cp_parser_template_id): In C++11 mode simply accept
X<::A>.
/testsuite
2012-09-25 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54526
* g++.dg/cpp0x/parse2.C: New.
* g++.dg/parse/error11.C: Adjust.
* g++.dg/parse/error12.C: Likewise.
From-SVN: r191712
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/parser.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/parse2.C | 12 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/error11.C | 34 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/parse/error12.C | 6 |
6 files changed, 53 insertions, 25 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ba1f775c0..ef89bae 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-09-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54526 + * parser.c (cp_parser_template_id): In C++11 mode simply accept + X<::A>. + 2012-09-25 Zhenqiang Chen <zhenqiang.chen@linaro.org> PR c++/50970 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index e8c0378..40aa306 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -12479,9 +12479,11 @@ cp_parser_template_id (cp_parser *parser, return error_mark_node; } /* Otherwise, emit an error about the invalid digraph, but continue - parsing because we got our argument list. */ - if (permerror (next_token->location, - "%<<::%> cannot begin a template-argument list")) + parsing because we got our argument list. In C++11 do not emit + any error, per 2.5/3. */ + if (cxx_dialect < cxx0x + && permerror (next_token->location, + "%<<::%> cannot begin a template-argument list")) { static bool hint = false; inform (next_token->location, @@ -12489,8 +12491,9 @@ cp_parser_template_id (cp_parser *parser, " Insert whitespace between %<<%> and %<::%>"); if (!hint && !flag_permissive) { - inform (next_token->location, "(if you use %<-fpermissive%>" - " G++ will accept your code)"); + inform (next_token->location, "(if you use %<-fpermissive%> " + "or %<-std=c++11%>, or %<-std=gnu++11%> G++ will " + "accept your code)"); hint = true; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e5a481f..41d75a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2012-09-25 Paolo Carlini <paolo.carlini@oracle.com> + + PR c++/54526 + * g++.dg/cpp0x/parse2.C: New. + * g++.dg/parse/error11.C: Adjust. + * g++.dg/parse/error12.C: Likewise. + 2012-09-25 Igor Zamyatin <igor.zamyatin@intel.com> * gcc.target/i386/20030217-1.c: Added check for diff --git a/gcc/testsuite/g++.dg/cpp0x/parse2.C b/gcc/testsuite/g++.dg/cpp0x/parse2.C new file mode 100644 index 0000000..eea6b41 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/parse2.C @@ -0,0 +1,12 @@ +// PR c++/54526 +// { dg-do compile { target c++11 } } + +template <class T> +struct X { }; + +struct A { }; + +int main() +{ + X<::A> x; +} diff --git a/gcc/testsuite/g++.dg/parse/error11.C b/gcc/testsuite/g++.dg/parse/error11.C index 39039a8..ec0058e 100644 --- a/gcc/testsuite/g++.dg/parse/error11.C +++ b/gcc/testsuite/g++.dg/parse/error11.C @@ -16,22 +16,22 @@ struct Foo }; void method(void) { - typename Foo<::B>::template Nested<::B> n; // { dg-error "17:'<::' cannot begin" "17-begin" } -// { dg-message "17:'<:' is an alternate spelling" "17-alt" { target *-*-* } 19 } -// { dg-error "39:'<::' cannot begin" "39-begin" { target *-*-* } 19 } -// { dg-message "39:'<:' is an alternate spelling" "39-alt" { target *-*-* } 19 } + typename Foo<::B>::template Nested<::B> n; // { dg-error "17:'<::' cannot begin" "17-begin" { target c++98 } } +// { dg-message "17:'<:' is an alternate spelling" "17-alt" { target c++98 } 19 } +// { dg-error "39:'<::' cannot begin" "39-begin" { target c++98 } 19 } +// { dg-message "39:'<:' is an alternate spelling" "39-alt" { target c++98 } 19 } n.template Nested<B>::method(); - n.template Nested<::B>::method(); // { dg-error "22:'<::' cannot begin" "error" } -// { dg-message "22:'<:' is an alternate" "note" { target *-*-* } 24 } + n.template Nested<::B>::method(); // { dg-error "22:'<::' cannot begin" "error" { target c++98 } } +// { dg-message "22:'<:' is an alternate" "note" { target c++98 } 24 } Nested<B>::method(); - Nested<::B>::method(); // { dg-error "11:'<::' cannot begin" "error" } -// { dg-message "11:'<:' is an alternate" "note" { target *-*-* } 27 } + Nested<::B>::method(); // { dg-error "11:'<::' cannot begin" "error" { target c++98 } } +// { dg-message "11:'<:' is an alternate" "note" { target c++98 } 27 } } }; template <int N> struct Foo2 {}; -template struct Foo2<::B>; // { dg-error "21:'<::' cannot begin" "begin" } -// { dg-message "21:'<:' is an alternate" "alt" { target *-*-* } 33 } +template struct Foo2<::B>; // { dg-error "21:'<::' cannot begin" "begin" { target c++98 } } +// { dg-message "21:'<:' is an alternate" "alt" { target c++98 } 33 } // { dg-message "25:type/value mismatch" "mismatch" { target *-*-* } 33 } // { dg-error "25:expected a constant" "const" { target *-*-* } 33 } @@ -39,11 +39,11 @@ int value = 0; void func(void) { - Foo<::B> f; // { dg-error "cannot begin" "begin" } -// { dg-message "alternate spelling" "alt" { target *-*-* } 42 } + Foo<::B> f; // { dg-error "cannot begin" "begin" { target c++98 } } +// { dg-message "alternate spelling" "alt" { target c++98 } 42 } f.Foo<B>::method(); - f.Foo<::B>::method(); // { dg-error "8:cannot begin" "begin" } -// { dg-message "8:alternate spelling" "alt" { target *-*-* } 45 } + f.Foo<::B>::method(); // { dg-error "8:cannot begin" "begin" { target c++98 } } +// { dg-message "8:alternate spelling" "alt" { target c++98 } 45 } // Check cases where we the token sequence is the correct one, but there // was no digraph or whitespaces in the middle, so we should not emit @@ -63,9 +63,9 @@ void func(void) Foo[::value] = 0; } -template struct Foo<::B>; // { dg-error "20:'<::' cannot begin" "begin" } -// { dg-message "20:is an alternate" "alt" { target *-*-* } 66 } +template struct Foo<::B>; // { dg-error "20:'<::' cannot begin" "begin" { target c++98 } } +// { dg-message "20:is an alternate" "alt" { target c++98 } 66 } // On the first error message, an additional note about the use of // -fpermissive should be present -// { dg-message "17:\\(if you use '-fpermissive' G\\+\\+ will accept your code\\)" "-fpermissive" { target *-*-* } 19 } +// { dg-message "17:\\(if you use '-fpermissive' or '-std=c\\+\\+11', or '-std=gnu\\+\\+11' G\\+\\+ will accept your code\\)" "-fpermissive" { target c++98 } 19 } diff --git a/gcc/testsuite/g++.dg/parse/error12.C b/gcc/testsuite/g++.dg/parse/error12.C index 3ebcf38..203ca3f 100644 --- a/gcc/testsuite/g++.dg/parse/error12.C +++ b/gcc/testsuite/g++.dg/parse/error12.C @@ -8,6 +8,6 @@ struct B; template <class A> struct Foo {}; -Foo<::B> foo; // { dg-bogus "error" "error in place of warning" } -// { dg-warning "4: '<::' cannot begin a template-argument list" "warning <::" { target *-*-* } 11 } -// { dg-message "4:'<:' is an alternate spelling for '.'. Insert whitespace between '<' and '::'" "note <:" { target *-*-* } 11 } +Foo<::B> foo; // { dg-bogus "error" "error in place of warning" { target c++98 } } +// { dg-warning "4: '<::' cannot begin a template-argument list" "warning <::" { target c++98 } 11 } +// { dg-message "4:'<:' is an alternate spelling for '.'. Insert whitespace between '<' and '::'" "note <:" { target c++98 } 11 } |