re PR c/61077 (_Atomic in the return type or argument types of main not diagnosed)
authorMarek Polacek <polacek@redhat.com>
Thu, 8 May 2014 17:42:09 +0000 (17:42 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 8 May 2014 17:42:09 +0000 (17:42 +0000)
PR c/61077
c-family/
* c-common.c (check_main_parameter_types): Warn for _Atomic-qualified
parameter type of main.
c/
* c-decl.c (start_function): Warn for _Atomic-qualified return type
of main.
testsuite/
* gcc.dg/pr61077.c: New test.

From-SVN: r210229

gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr61077.c [new file with mode: 0644]

index b7c65d35ff254041ba850b2b617590fd058dc536..06a1b1468beddba0083e6f4fb0c2438b0301408e 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-08  Marek Polacek  <polacek@redhat.com>
+
+       PR c/61077
+       * c-common.c (check_main_parameter_types): Warn for _Atomic-qualified
+       parameter type of main.
+
 2014-05-07  DJ Delorie  <dj@redhat.com>
 
        * c-cppbuiltin.c (print_bits_of_hex): New.
index 0afe2f5ab38a71dd99a468a79762d84956e60b75..33ad25087731f957e243a871e2b05ab43f53060a 100644 (file)
@@ -2193,6 +2193,20 @@ check_main_parameter_types (tree decl)
       if (type == void_type_node || type == error_mark_node )
        break;
 
+      tree t = type;
+      if (TYPE_ATOMIC (t))
+         pedwarn (input_location, OPT_Wmain,
+                  "%<_Atomic%>-qualified parameter type %qT of %q+D",
+                  type, decl);
+      while (POINTER_TYPE_P (t))
+       {
+         t = TREE_TYPE (t);
+         if (TYPE_ATOMIC (t))
+           pedwarn (input_location, OPT_Wmain,
+                    "%<_Atomic%>-qualified parameter type %qT of %q+D",
+                    type, decl);
+       }
+
       ++argct;
       switch (argct)
        {
index 379b8d749467a47f2df76399d461ce30f3f13c00..892537147d01cf5c647b15404dcf6b952b8aa629 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-08  Marek Polacek  <polacek@redhat.com>
+
+       PR c/61077
+       * c-decl.c (start_function): Warn for _Atomic-qualified return type
+       of main.
+
 2014-05-06  Kenneth Zadeck  <zadeck@naturalbridge.com>
            Mike Stump  <mikestump@comcast.net>
            Richard Sandiford  <rdsandiford@googlemail.com>
index 3abf6b985741657270dc8514844a8062e1fddc64..d8631fc3345012f61d1b9792f999099a1dda8573 100644 (file)
@@ -8045,6 +8045,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
       if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1)))
          != integer_type_node)
        pedwarn (loc, OPT_Wmain, "return type of %qD is not %<int%>", decl1);
+      else if (TYPE_ATOMIC (TREE_TYPE (TREE_TYPE (decl1))))
+       pedwarn (loc, OPT_Wmain, "%<_Atomic%>-qualified return type of %qD",
+                decl1);
 
       check_main_parameter_types (decl1);
 
index 7ea4d9ea91d4593b409520c39bae0f7bbb8e863e..fe0683e511ecff47c7fac0b34652f137e6b8afbb 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-08  Marek Polacek  <polacek@redhat.com>
+
+       PR c/61077
+       * gcc.dg/pr61077.c: New test.
+
 2014-05-08  Tobias Burnus  <burnus@net-b.de>
 
        * gfortran.dg/coarray_collectives_1.f90: New.
diff --git a/gcc/testsuite/gcc.dg/pr61077.c b/gcc/testsuite/gcc.dg/pr61077.c
new file mode 100644 (file)
index 0000000..c0513f7
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR c/61077 */
+/* { dg-do compile } */
+/* { dg-options "-std=c11 -Wall" } */
+
+_Atomic int
+main (_Atomic int argc, _Atomic char **argv)
+/* { dg-warning "qualified return type" "return" { target *-*-* } 6 } */
+/* { dg-warning "qualified parameter type.*int" "parameter" { target *-*-* } 6 } */
+/* { dg-warning "qualified parameter type.*char" "parameter" { target *-*-* } 6 } */
+{
+  return 0;
+}