llvm/clang/test/PCH/cli-macro.c
Luboš Luňák 5c8c9905c2 make sure to not warn about unused macros from -D
If a PCH is used for compilation, SourceManager::isInMainFile()
returns true even for the "<built-in>" predefines area. Using -D
only for the TU compilation may trigger -Wunused-macros for it.
It is admitedly a bit fishy to set a macro only for a TU and not
for the PCH, but this works fine if the PCH does not use the macro
(I couldn't find a statement on this for Clang, but GCC explicitly
allows this in the docs).

Differential Revision: https://reviews.llvm.org/D73846
2020-04-27 21:26:13 +02:00

13 lines
417 B
C

// Test this without pch.
// RUN: %clang_cc1 -Wunused-macros -Dunused=1 -fsyntax-only -verify %s
// Test with pch.
// RUN: %clang_cc1 -Wunused-macros -emit-pch -o %t %s
// RUN: %clang_cc1 -Wunused-macros -Dunused=1 -include-pch %t -fsyntax-only -verify %s
// expected-no-diagnostics
// -Dunused=1 is intentionally not set for the pch.
// There still should be no unused warning for a macro from the command line.