]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libcpp
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Jan 2007 15:32:26 +0000 (15:32 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Jan 2007 15:32:26 +0000 (15:32 +0000)
PR preprocessor/28165:
* internal.h (cpp_in_primary_file): New function.
* directives.c (do_include_next): Use cpp_in_primary_file.
(do_pragma_once): Likewise.
(do_pragma_system_header): Likewise.
gcc/testsuite
PR preprocessor/28165:
* gcc.dg/cpp/pr28165.c: New file.

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

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/pr28165.c [new file with mode: 0644]
libcpp/ChangeLog
libcpp/directives.c
libcpp/internal.h

index 240666861916d47e3fea8d1316975c093f05abee..0663f79bb8e5fb8a9517e57eb542c62ec0fad1f9 100644 (file)
@@ -1,3 +1,8 @@
+2007-01-04  Tom Tromey  <tromey@redhat.com>
+
+       PR preprocessor/28165:
+       * gcc.dg/cpp/pr28165.c: New file.
+
 2007-01-03  Josh Conner  <jconner@apple.com>
 
        PR middle-end/29683
diff --git a/gcc/testsuite/gcc.dg/cpp/pr28165.c b/gcc/testsuite/gcc.dg/cpp/pr28165.c
new file mode 100644 (file)
index 0000000..71c7c1d
--- /dev/null
@@ -0,0 +1,6 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.  */
+/* PR preprocessor/28165 */
+
+/* { dg-do preprocess } */
+#pragma GCC system_header   /* { dg-warning "system_header" "ignored" } */
+_Pragma ("GCC system_header")   /* { dg-warning "system_header" "ignored" } */
index 96c5140e7077562d7b2eb72d98b69d5ea4004e1f..072c6aadbb99fa5b98c0384cc4d25e0a8e8c9ac4 100644 (file)
@@ -1,3 +1,11 @@
+2007-01-04  Tom Tromey  <tromey@redhat.com>
+
+       PR preprocessor/28165:
+       * internal.h (cpp_in_primary_file): New function.
+       * directives.c (do_include_next): Use cpp_in_primary_file.
+       (do_pragma_once): Likewise.
+       (do_pragma_system_header): Likewise.
+
 2006-12-29  Ian Lance Taylor  <iant@google.com>
 
        * lex.c (_cpp_clean_line): Add uses of __builtin_expect.  Don't
index 7fb142e48c798354c3639695ea00472db6b540c8..2ef914a435e99dcc6ecc7d199d9167245e83a023 100644 (file)
@@ -1,6 +1,7 @@
 /* CPP Library. (Directive handling.)
    Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2007 Free Software Foundation, Inc.
    Contributed by Per Bothner, 1994-95.
    Based on CCCP program by Paul Rubin, June 1986
    Adapted to ANSI C, Richard Stallman, Jan 1987
@@ -772,7 +773,7 @@ do_include_next (cpp_reader *pfile)
 
   /* If this is the primary source file, warn and use the normal
      search logic.  */
-  if (! pfile->buffer->prev)
+  if (cpp_in_primary_file (pfile))
     {
       cpp_error (pfile, CPP_DL_WARNING,
                 "#include_next in primary source file");
@@ -1346,7 +1347,7 @@ do_pragma (cpp_reader *pfile)
 static void
 do_pragma_once (cpp_reader *pfile)
 {
-  if (pfile->buffer->prev == NULL)
+  if (cpp_in_primary_file (pfile))
     cpp_error (pfile, CPP_DL_WARNING, "#pragma once in main file");
 
   check_eol (pfile);
@@ -1396,9 +1397,7 @@ do_pragma_poison (cpp_reader *pfile)
 static void
 do_pragma_system_header (cpp_reader *pfile)
 {
-  cpp_buffer *buffer = pfile->buffer;
-
-  if (buffer->prev == 0)
+  if (cpp_in_primary_file (pfile))
     cpp_error (pfile, CPP_DL_WARNING,
               "#pragma system_header ignored outside include file");
   else
index 857bfe1d8c586ddd15d7e558cdd0455853320372..20f423580517d73fe6196efa2dcc4b2628d0dc31 100644 (file)
@@ -1,5 +1,5 @@
 /* Part of CPP library.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
    Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
@@ -488,6 +488,13 @@ cpp_in_system_header (cpp_reader *pfile)
 #define CPP_PEDANTIC(PF) CPP_OPTION (PF, pedantic)
 #define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional)
 
+static inline int cpp_in_primary_file (cpp_reader *);
+static inline int
+cpp_in_primary_file (cpp_reader *pfile)
+{
+  return pfile->line_table->depth == 1;
+}
+
 /* In errors.c  */
 extern int _cpp_begin_message (cpp_reader *, int,
                               source_location, unsigned int);