trans.c (Pragma_to_gnu): Use optimize_size instead of optimize and adjust warning...
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 22 Jan 2013 10:01:08 +0000 (10:01 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 22 Jan 2013 10:01:08 +0000 (10:01 +0000)
* gcc-interface/trans.c (Pragma_to_gnu) <Name_Space>: Use optimize_size
instead of optimize and adjust warning message.
(Compilation_Unit_to_gnu): Process pragmas preceding the unit.

From-SVN: r195366

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/warn8.adb [new file with mode: 0644]

index 426c9a70ddfe0b796bde0c56967a63d587016eb6..263113b91e55bc62c4639559ae94a45f7414cf76 100644 (file)
@@ -1,3 +1,9 @@
+2013-01-22  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (Pragma_to_gnu) <Name_Space>: Use optimize_size
+       instead of optimize and adjust warning message.
+       (Compilation_Unit_to_gnu): Process pragmas preceding the unit.
+
 2013-01-22  Tristan Gingold  <gingold@adacore.com>
 
        * gcc-interface/gigi.h (ADT_unhandled_except_decl,
index 722ce73ba9ef1e82aa0ec4f53c2260e5c6530c9b..6bb2e5b2723d90d4f46a1d3ed23242782d0adfeb 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2012, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2013, Free Software Foundation, Inc.         *
  *                                                                          *
  * GNAT is free software;  you can  redistribute it  and/or modify it under *
  * terms of the  GNU General Public License as published  by the Free Soft- *
@@ -1254,16 +1254,21 @@ Pragma_to_gnu (Node_Id gnat_node)
       switch (Chars (Expression
                     (First (Pragma_Argument_Associations (gnat_node)))))
        {
-       case Name_Time:  case Name_Space:
-         if (!optimize)
-           post_error ("insufficient -O value?", gnat_node);
-         break;
-
        case Name_Off:
          if (optimize)
            post_error ("must specify -O0?", gnat_node);
          break;
 
+       case Name_Space:
+         if (!optimize_size)
+           post_error ("must specify -Os?", gnat_node);
+         break;
+
+       case Name_Time:
+         if (!optimize)
+           post_error ("insufficient -O value?", gnat_node);
+         break;
+
        default:
          gcc_unreachable ();
        }
@@ -4743,6 +4748,7 @@ Compilation_Unit_to_gnu (Node_Id gnat_node)
   const bool body_p = (Nkind (gnat_unit) == N_Package_Body
                       || Nkind (gnat_unit) == N_Subprogram_Body);
   const Entity_Id gnat_unit_entity = Defining_Entity (gnat_unit);
+  Node_Id gnat_pragma;
   /* Make the decl for the elaboration procedure.  */
   tree gnu_elab_proc_decl
     = create_subprog_decl
@@ -4778,8 +4784,16 @@ Compilation_Unit_to_gnu (Node_Id gnat_node)
        return;
     }
 
+  /* Then process any pragmas and declarations preceding the unit.  */
+  for (gnat_pragma = First (Context_Items (gnat_node));
+       Present (gnat_pragma);
+       gnat_pragma = Next (gnat_pragma))
+    if (Nkind (gnat_pragma) == N_Pragma)
+      add_stmt (gnat_to_gnu (gnat_pragma));
   process_decls (Declarations (Aux_Decls_Node (gnat_node)), Empty, Empty,
                 true, true);
+
+  /* Process the unit itself.  */
   add_stmt (gnat_to_gnu (gnat_unit));
 
   /* If we can inline, generate code for all the inlined subprograms.  */
index 343611c25878693dbb79c2ed0ff389b69371a961..2fe215e41f07e1377f6c7e6d7a3c6b8ca17489b8 100644 (file)
@@ -1,3 +1,7 @@
+2013-01-22  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/warn8.adb: New test.
+
 2013-01-21  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        PR fortran/55919
diff --git a/gcc/testsuite/gnat.dg/warn8.adb b/gcc/testsuite/gnat.dg/warn8.adb
new file mode 100644 (file)
index 0000000..8fddb6f
--- /dev/null
@@ -0,0 +1,8 @@
+-- { dg-do compile }
+
+pragma Optimize (Space); -- { dg-warning "must specify -Os" }
+
+procedure Warn8 is
+begin
+  null;
+end;