From 3e66d096990519fcf0408a3bfc5b92e7d32b6462 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 2 Feb 2007 13:23:18 +0100 Subject: [PATCH] re PR c++/30536 (ICE with __thread and register) PR c++/30536 * decl.c (grokdeclarator): If __thread is used together with a storage class other than extern and static, clear thread_p after issuing diagnostics and fall through to checking the storage class. * g++.dg/tls/diag-5.C: New test. From-SVN: r121496 --- gcc/cp/ChangeLog | 8 ++++++++ gcc/cp/decl.c | 18 +++++++++--------- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/tls/diag-5.C | 5 +++++ 4 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/tls/diag-5.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c89e3836055..47ac05fe867 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2007-02-02 Jakub Jelinek + + PR c++/30536 + * decl.c (grokdeclarator): If __thread is used together with + a storage class other than extern and static, clear thread_p + after issuing diagnostics and fall through to checking the + storage class. + 2007-01-30 Roger Sayle * error.c (dump_type_suffix): Avoid use of cp_build_binary_op when diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index cea649ad731..a98d902da93 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7470,20 +7470,20 @@ grokdeclarator (const cp_declarator *declarator, /* Warn about storage classes that are invalid for certain kinds of declarations (parameters, typenames, etc.). */ + if (thread_p + && ((storage_class + && storage_class != sc_extern + && storage_class != sc_static) + || declspecs->specs[(int)ds_typedef])) + { + error ("multiple storage classes in declaration of %qs", name); + thread_p = false; + } if (declspecs->conflicting_specifiers_p) { error ("conflicting specifiers in declaration of %qs", name); storage_class = sc_none; } - else if (thread_p - && ((storage_class - && storage_class != sc_extern - && storage_class != sc_static) - || declspecs->specs[(int)ds_typedef])) - { - error ("multiple storage classes in declaration of %qs", name); - thread_p = false; - } else if (decl_context != NORMAL && ((storage_class != sc_none && storage_class != sc_mutable) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e699db6c61f..1a461681469 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2007-02-02 Jakub Jelinek + PR c++/30536 + * g++.dg/tls/diag-5.C: New test. + PR middle-end/30473 * gcc.dg/pr30473.c: New test. * gcc.c-torture/execute/20070201-1.c: New test. diff --git a/gcc/testsuite/g++.dg/tls/diag-5.C b/gcc/testsuite/g++.dg/tls/diag-5.C new file mode 100644 index 00000000000..ca92b307428 --- /dev/null +++ b/gcc/testsuite/g++.dg/tls/diag-5.C @@ -0,0 +1,5 @@ +// PR c++/30536 +// Invalid __thread specifiers. +// { dg-require-effective-target tls } + +struct A { __thread register int i; }; // { dg-error "multiple storage classes|storage class specified" }