Add test coverage for recent behavior change in GNU line marker pre-processing

llvm-svn: 303642
This commit is contained in:
Reid Kleckner 2017-05-23 16:09:13 +00:00
parent a96ec3f360
commit 1ace0049fe
4 changed files with 18 additions and 6 deletions

View File

@ -0,0 +1,2 @@
#line 10 "foo.h"
foo(); // will warn if not treated as a system header

View File

@ -1,20 +1,23 @@
// RUN: %clang_cc1 -Wall %s -isystem %S/Inputs/SystemHeaderPrefix -verify
// RUN: %clang_cc1 %s -E -o - -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s
// RUN: %clang_cc1 -Wall %s -I %S/Inputs -isystem %S/Inputs/SystemHeaderPrefix -verify
// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s
#include <noline.h>
#include <line.h>
#include <line-directive-in-system.h>
// expected-warning@line-directive.h:* {{type specifier missing, defaults to 'int'}}
#include "line-directive.h"
// This tests that "#line" directives in system headers preserve system
// header-ness just like GNU line markers that don't have filenames. This was
// PR30752.
// expected-no-diagnostics
// CHECK: # {{[0-9]+}} "{{.*}}system-header-line-directive.c" 2
// CHECK: # 1 "{{.*}}noline.h" 1 3
// CHECK: foo();
// CHECK: # 4 "{{.*}}system-header-line-directive.c" 2
// CHECK: # 1 "{{.*}}line.h" 1 3
// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
// The "3" below indicates that "foo.h" is considered a system header.
// CHECK: # 1 "foo.h" 3
// CHECK: foo();
// CHECK: # {{[0-9]+}} "{{.*}}system-header-line-directive.c" 2
// CHECK: # 1 "{{.*}}line-directive.h" 1
// CHECK: # 10 "foo.h"{{$}}

View File

@ -76,3 +76,10 @@ extern int z;
// CHECK: # 50 "a\n.c"
# 50 "a\012.c"
# 1 "system.h" 3
# 2
void sys_foo(void);
// CHECK: # 1 "system.h" 3
// CHECK-NEXT: # 2 "system.h" 3
// CHECK-NEXT: void sys_foo(void);