diff options
author | Paolo Carlini <paolo.carlini@oracle.com> | 2018-07-02 21:42:10 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2018-07-02 21:42:10 +0000 |
commit | a5eae716f66322842da21c17002c66b10c6f6b40 (patch) | |
tree | cc166090c6dc9638364d6616d940031863f435fa /gcc | |
parent | ee896276f6483832d45c9280915367c825c32098 (diff) | |
download | gcc-a5eae716f66322842da21c17002c66b10c6f6b40.zip gcc-a5eae716f66322842da21c17002c66b10c6f6b40.tar.gz gcc-a5eae716f66322842da21c17002c66b10c6f6b40.tar.bz2 |
parser.c (set_and_check_decl_spec_loc): Use rich_location::add_range in error message about __thread and thread_local...
/cp
2018-07-02 Paolo Carlini <paolo.carlini@oracle.com>
* parser.c (set_and_check_decl_spec_loc): Use rich_location::add_range
in error message about __thread and thread_local at the same time.
/testsuite
2018-07-02 Paolo Carlini <paolo.carlini@oracle.com>
* g++.dg/diagnostic/thread-thread_local.C: New.
From-SVN: r262321
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/parser.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/diagnostic/thread-thread_local.C | 13 |
4 files changed, 28 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 556b154..53bcb1f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-07-02 Paolo Carlini <paolo.carlini@oracle.com> + + * parser.c (set_and_check_decl_spec_loc): Use rich_location::add_range + in error message about __thread and thread_local at the same time. + 2018-06-29 Marek Polacek <polacek@redhat.com> PR c++/86184 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a076de1..5edd0ee 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -28377,12 +28377,15 @@ set_and_check_decl_spec_loc (cp_decl_specifier_seq *decl_specs, else if (ds == ds_thread) { bool gnu = token_is__thread (token); + gcc_rich_location richloc (location); if (gnu != decl_specs->gnu_thread_keyword_p) - error_at (location, - "both %<__thread%> and %<thread_local%> specified"); + { + richloc.add_range (decl_specs->locations[ds_thread], false); + error_at (&richloc, + "both %<__thread%> and %<thread_local%> specified"); + } else { - gcc_rich_location richloc (location); richloc.add_fixit_remove (); error_at (&richloc, "duplicate %qD", token->u.value); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b4eabd9..f2485db 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-07-02 Paolo Carlini <paolo.carlini@oracle.com> + + * g++.dg/diagnostic/thread-thread_local.C: New. + 2018-07-02 Martin Liska <mliska@suse.cz> PR testsuite/86366 diff --git a/gcc/testsuite/g++.dg/diagnostic/thread-thread_local.C b/gcc/testsuite/g++.dg/diagnostic/thread-thread_local.C new file mode 100644 index 0000000..4f2264c --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/thread-thread_local.C @@ -0,0 +1,13 @@ +// { dg-options "-fdiagnostics-show-caret" } +// { dg-do compile { target c++11 } } + +thread_local __thread int a; // { dg-error "14:both .__thread. and .thread_local. specified" } +/* { dg-begin-multiline-output "" } + thread_local __thread int a; + ~~~~~~~~~~~~ ^~~~~~~~ + { dg-end-multiline-output "" } */ +__thread thread_local int b; // { dg-error "10:both .__thread. and .thread_local. specified" } +/* { dg-begin-multiline-output "" } + __thread thread_local int b; + ~~~~~~~~ ^~~~~~~~~~~~ + { dg-end-multiline-output "" } */ |