(do_include): Diagnose #import and #include_next if pedantic and if not in a system...
authorRichard Kenner <kenner@gcc.gnu.org>
Sun, 13 Apr 1997 18:30:13 +0000 (14:30 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Sun, 13 Apr 1997 18:30:13 +0000 (14:30 -0400)
(do_include): Diagnose #import and #include_next if pedantic and if
not in a system header.
(do_warning): #warning now causes an error if -pedantic-errors is
given; this is needed since #warning isn't ANSI.

From-SVN: r13887

gcc/cccp.c
gcc/cpplib.c

index 5baa257d2829a415f8be054eace3ed5091c90706..0725465841c9ee26a0f2f13158d5b51d9646f158 100644 (file)
@@ -4220,6 +4220,14 @@ do_include (buf, limit, op, keyword)
   char *pcfbuflimit;
   int pcfnum;
 
+  if (pedantic && !instack[indepth].system_header_p)
+    {
+      if (importing)
+       pedwarn ("ANSI C does not allow `#import'");
+      if (skip_dirs)
+       pedwarn ("ANSI C does not allow `#include_next'");
+    }
+
   if (importing && warn_import && !inhibit_warnings
       && !instack[indepth].system_header_p && !import_warning) {
     import_warning = 1;
@@ -6752,7 +6760,9 @@ do_warning (buf, limit, op, keyword)
   bcopy ((char *) buf, (char *) copy, length);
   copy[length] = 0;
   SKIP_WHITE_SPACE (copy);
-  warning ("#warning %s", copy);
+  /* Use `pedwarn' not `warning', because #warning isn't in the C Standard;
+     if -pedantic-errors is given, #warning should cause an error.  */
+  pedwarn ("#warning %s", copy);
   return 0;
 }
 
index 6e2177e30035fd7300addb3e652301b07ebef96c..697cea8f71f6533f80cec94c475239c8ccdb9508 100644 (file)
@@ -3112,6 +3112,14 @@ do_include (pfile, keyword, unused1, unused2)
   int pcfnum;
   f= -1;                       /* JF we iz paranoid! */
 
+  if (CPP_PEDANTIC (pfile) && !CPP_BUFFER (pfile)->system_header_p)
+    {
+      if (importing)
+       cpp_pedwarn (pfile, "ANSI C does not allow `#import'");
+      if (skip_dirs)
+       cpp_pedwarn (pfile, "ANSI C does not allow `#include_next'");
+    }
+
   if (importing && CPP_OPTIONS (pfile)->warn_import
       && !CPP_OPTIONS (pfile)->inhibit_warnings
       && !CPP_BUFFER (pfile)->system_header_p && !pfile->import_warning)
@@ -3905,7 +3913,9 @@ do_warning (pfile, keyword, buf, limit)
   bcopy (buf, copy, length);
   copy[length] = 0;
   SKIP_WHITE_SPACE (copy);
-  cpp_warning (pfile, "#warning %s", copy);
+  /* Use `pedwarn' not `warning', because #warning isn't in the C Standard;
+     if -pedantic-errors is given, #warning should cause an error.  */
+  cpp_pedwarn (pfile, "#warning %s", copy);
   return 0;
 }