OSDN Git Service

2007-03-26 Paolo Carlini <pcarlini@suse.de>
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Mar 2007 21:55:03 +0000 (21:55 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Mar 2007 21:55:03 +0000 (21:55 +0000)
PR c++/30500
* pt.c (instantiate_decl): Set in_system_header.

2007-03-26  Paolo Carlini  <pcarlini@suse.de>

PR c++/30500
* g++.dg/warn/pragma-system_header1.C: New test.
* g++.dg/warn/pragma-system_header2.C: New test.
* g++.dg/warn/pragma-system_header1.h. New.
* g++.dg/warn/pragma-system_header2.h. New.

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

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/warn/pragma-system_header1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/pragma-system_header1.h [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/pragma-system_header2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/pragma-system_header2.h [new file with mode: 0644]

index 42a57d0..98758dd 100644 (file)
@@ -1,3 +1,8 @@
+2007-03-26  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/30500
+       * pt.c (instantiate_decl): Set in_system_header.
+
 2007-03-22  Mark Mitchell  <mark@codesourcery.com>
 
        * cp-tree.h (current_tempalte_parms): Improve documentation.
index 69c60b4..da3cd23 100644 (file)
@@ -13829,6 +13829,7 @@ instantiate_decl (tree d, int defer_ok,
   bool pattern_defined;
   int need_push;
   location_t saved_loc = input_location;
+  int saved_in_system_header = in_system_header;
   bool external_p;
 
   /* This function should only be used to instantiate templates for
@@ -13911,6 +13912,7 @@ instantiate_decl (tree d, int defer_ok,
     mark_definable (d);
 
   input_location = DECL_SOURCE_LOCATION (d);
+  in_system_header = DECL_IN_SYSTEM_HEADER (d);
 
   /* If D is a member of an explicitly instantiated class template,
      and no definition is available, treat it like an implicit
@@ -14178,6 +14180,7 @@ instantiate_decl (tree d, int defer_ok,
 
 out:
   input_location = saved_loc;
+  in_system_header = saved_in_system_header;
   pop_deferring_access_checks ();
   pop_tinst_level ();
 
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header1.C b/gcc/testsuite/g++.dg/warn/pragma-system_header1.C
new file mode 100644 (file)
index 0000000..489761b
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/30500
+// { dg-options "-Wconversion" }
+
+#include "pragma-system_header1.h"
+
+void f()
+{
+  g<int>();
+  h<int>();
+}
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header1.h b/gcc/testsuite/g++.dg/warn/pragma-system_header1.h
new file mode 100644 (file)
index 0000000..684c6bf
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma GCC system_header
+
+template <typename T>
+  int g() { double d = 0.1; return d; }
+   
+template <typename T>
+  T h() { double d = 0.1; return d; }
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header2.C b/gcc/testsuite/g++.dg/warn/pragma-system_header2.C
new file mode 100644 (file)
index 0000000..be29474
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/30500
+// { dg-options "-Wconversion" }
+
+#include "pragma-system_header2.h"
+
+void f()
+{
+  g<int>();
+  h<int>();
+}
+
+// { dg-warning "conversion" "" { target *-*-* } 2 }
+// { dg-warning "conversion" "" { target *-*-* } 5 }
diff --git a/gcc/testsuite/g++.dg/warn/pragma-system_header2.h b/gcc/testsuite/g++.dg/warn/pragma-system_header2.h
new file mode 100644 (file)
index 0000000..aa4f0e9
--- /dev/null
@@ -0,0 +1,5 @@
+template <typename T>
+  int g() { double d = 0.1; return d; }
+   
+template <typename T>
+  T h() { double d = 0.1; return d; }