re PR c++/30536 (ICE with __thread and register)
authorJakub Jelinek <jakub@redhat.com>
Fri, 2 Feb 2007 12:23:18 +0000 (13:23 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 2 Feb 2007 12:23:18 +0000 (13:23 +0100)
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
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tls/diag-5.C [new file with mode: 0644]

index c89e3836055fc64595b8d6516023e6dec9967874..47ac05fe867069b1a902d59af56d09b57b753b89 100644 (file)
@@ -1,3 +1,11 @@
+2007-02-02  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <roger@eyesopen.com>
 
        * error.c (dump_type_suffix): Avoid use of cp_build_binary_op when
index cea649ad7316d9282bcd0ccaea1e690bcc893e3b..a98d902da93bb7db07567ec1af2a08ff33e4180a 100644 (file)
@@ -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)
index e699db6c61ff001f5e768d928babf075342b4d22..1a4616814690f20e3cd2c2b6ea79c41e2a51fc90 100644 (file)
@@ -1,5 +1,8 @@
 2007-02-02  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..ca92b30
--- /dev/null
@@ -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" }