llvm-project/clang/test/Preprocessor/line-directive-suppressed.c
macurtis-amd 2ddf0caaed
[clang][driver] Suppress gnu-line-marker when saving temps (#134621)
When passing `-save-temps` to clang, the generated preprocessed output
uses gnu line markers. This unexpectedly triggers gnu-line-marker
warnings when used with `-Weverything` or `-pedantic`. Even worse,
compilation fails if `-Werror` is used.

This change suppresses gnu-line-marker warnings when invoking clang with
input from a preprocessor job and the user has not otherwise explictly
specified `-Wgnu-line-marker` somewhere on the command line. Note that
this does apply to user provided preprocessed files.

fixes #63802
2025-06-10 11:54:50 -05:00

17 lines
612 B
C

// RUN: %clang_cc1 -std=c99 -fsyntax-only -pedantic %s 2>&1 | FileCheck %s
// RUN: cp %s %t.i
// RUN: %clang_cc1 -std=c99 -fsyntax-only -pedantic %t.i 2>&1 | FileCheck %s --check-prefix=NO-WARNING --allow-empty
// RUN: %clang_cc1 -std=c99 -fsyntax-only -pedantic -x cpp-output %s 2>&1 | FileCheck %s --check-prefix=NO-WARNING --allow-empty
# 0 "zero"
// CHECK: line-directive-suppressed.c:[[@LINE-1]]:5: warning: {{.*}} [-Wgnu-line-marker]
# 1 "one" 1
// CHECK: zero:2:5: warning: {{.*}} [-Wgnu-line-marker]
# 2 "two" 1 3 4
// CHECK: one:3:5: warning: {{.*}} [-Wgnu-line-marker]
// NO-WARNING-NOT: warning: