libcpp
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.
From-SVN: r120441
+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
2007-01-03 Josh Conner <jconner@apple.com>
PR middle-end/29683
--- /dev/null
+/* 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" } */
+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
2006-12-29 Ian Lance Taylor <iant@google.com>
* lex.c (_cpp_clean_line): Add uses of __builtin_expect. Don't
/* CPP Library. (Directive handling.)
Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
/* 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
Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
/* If this is the primary source file, warn and use the normal
search logic. */
/* 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");
{
cpp_error (pfile, CPP_DL_WARNING,
"#include_next in primary source file");
static void
do_pragma_once (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);
cpp_error (pfile, CPP_DL_WARNING, "#pragma once in main file");
check_eol (pfile);
static void
do_pragma_system_header (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
cpp_error (pfile, CPP_DL_WARNING,
"#pragma system_header ignored outside include file");
else
- 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
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
#define CPP_PEDANTIC(PF) CPP_OPTION (PF, pedantic)
#define CPP_WTRADITIONAL(PF) CPP_OPTION (PF, warn_traditional)
#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);
/* In errors.c */
extern int _cpp_begin_message (cpp_reader *, int,
source_location, unsigned int);