OSDN Git Service

gcc
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Nov 2007 15:57:02 +0000 (15:57 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Nov 2007 15:57:02 +0000 (15:57 +0000)
PR c++/32256, PR c++/32368:
* function.c (saved_in_system_header): New global.
(push_cfun): Save in_system_header.
(pop_cfun): Restore in_system_header.
(push_struct_function): Save in_system_header.
gcc/testsuite
PR c++/32368:
* g++.dg/warn/pragma-system_header3.h: New.
* g++.dg/warn/pragma-system_header3.C: New.

PR c++/32256:
* g++.dg/warn/pragma-system_header4.C: New.
* g++.dg/warn/pragma-system_header4.h: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129936 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/function.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/warn/pragma-system_header3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/pragma-system_header3.h [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/pragma-system_header4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/pragma-system_header4.h [new file with mode: 0644]

index 6c8c570..0025efa 100644 (file)
@@ -1,3 +1,11 @@
+2007-11-06  Tom Tromey  <tromey@redhat.com>
+
+       PR c++/32256, PR c++/32368:
+       * function.c (saved_in_system_header): New global.
+       (push_cfun): Save in_system_header.
+       (pop_cfun): Restore in_system_header.
+       (push_struct_function): Save in_system_header.
+
 2007-11-06  Douglas Gregor  <doug.gregor@gmail.com>
 
        PR c++/33977
index 05bbd64..56abe4d 100644 (file)
@@ -3834,12 +3834,22 @@ DEF_VEC_ALLOC_P(function_p,heap);
 
 static VEC(function_p,heap) *cfun_stack;
 
+/* We save the value of in_system_header here when pushing the first
+   function on the cfun stack, and we restore it from here when
+   popping the last function.  */
+
+static bool saved_in_system_header;
+
 /* Push the current cfun onto the stack, and set cfun to new_cfun.  */
 
 void
 push_cfun (struct function *new_cfun)
 {
+  if (cfun == NULL)
+    saved_in_system_header = in_system_header;
   VEC_safe_push (function_p, heap, cfun_stack, cfun);
+  if (new_cfun)
+    in_system_header = DECL_IN_SYSTEM_HEADER (new_cfun->decl);
   set_cfun (new_cfun);
 }
 
@@ -3848,7 +3858,10 @@ push_cfun (struct function *new_cfun)
 void
 pop_cfun (void)
 {
-  set_cfun (VEC_pop (function_p, cfun_stack));
+  struct function *new_cfun = VEC_pop (function_p, cfun_stack);
+  in_system_header = ((new_cfun == NULL) ? saved_in_system_header
+                     : DECL_IN_SYSTEM_HEADER (new_cfun->decl));
+  set_cfun (new_cfun);
 }
 
 /* Return value of funcdef and increase it.  */
@@ -3922,7 +3935,11 @@ allocate_struct_function (tree fndecl)
 void
 push_struct_function (tree fndecl)
 {
+  if (cfun == NULL)
+    saved_in_system_header = in_system_header;
   VEC_safe_push (function_p, heap, cfun_stack, cfun);
+  if (fndecl)
+    in_system_header = DECL_IN_SYSTEM_HEADER (fndecl);
   allocate_struct_function (fndecl);
 }
 
index 76b42c9..405068c 100644 (file)
@@ -1,3 +1,13 @@
+2007-11-06  Tom Tromey  <tromey@redhat.com>
+
+       PR c++/32368:
+       * g++.dg/warn/pragma-system_header3.h: New.
+       * g++.dg/warn/pragma-system_header3.C: New.
+
+       PR c++/32256:
+       * g++.dg/warn/pragma-system_header4.C: New.
+       * g++.dg/warn/pragma-system_header4.h: New.
+
 2007-11-06  Douglas Gregor  <doug.gregor@gmail.com>
 
        PR c++/33977
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header3.C b/gcc/testsuite/g++.dg/warn/pragma-system_header3.C
new file mode 100644 (file)
index 0000000..a9255c9
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/32368
+// { dg-options "-Wall -O" }
+
+#include "pragma-system_header3.h"
+
+int main()
+{
+       return f();
+}
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header3.h b/gcc/testsuite/g++.dg/warn/pragma-system_header3.h
new file mode 100644 (file)
index 0000000..e16f38f
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma GCC system_header
+
+static inline int f()
+{
+       int i;
+       return i;
+}
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header4.C b/gcc/testsuite/g++.dg/warn/pragma-system_header4.C
new file mode 100644 (file)
index 0000000..898e108
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/32256
+// { dg-options "-Wall" }
+
+#include "pragma-system_header4.h"
+
+void ok() { }
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header4.h b/gcc/testsuite/g++.dg/warn/pragma-system_header4.h
new file mode 100644 (file)
index 0000000..c3abae0
--- /dev/null
@@ -0,0 +1,2 @@
+#pragma GCC system_header
+int noreturn() { }