llvm-project/clang/test/PCH/chain-staticvar-instantiation.cpp
Jordan Rose b13eb8dca5 Allow -verify directives to be filtered by preprocessing.
This is accomplished by making VerifyDiagnosticsConsumer a CommentHandler,
which then only reads the -verify directives that are actually in live
blocks of code. It also makes it simpler to handle -verify directives that
appear in header files, though we still have to manually reparse some files
depending on how they are generated.

This requires some test changes. In particular, all PCH tests now have their
-verify directives outside the "header" portion of the file, using the @line
syntax added in r159978. Other tests have been modified mostly to make it
clear what is being tested, and to prevent polluting the expected output with
the directives themselves.

Patch by Andy Gibbs! (with slight modifications)

The new Frontend/verify-* tests exercise the functionality of this commit,
as well as r159978, r159979, and r160053 (Andy's other -verify enhancements).

llvm-svn: 160068
2012-07-11 19:58:23 +00:00

46 lines
1.0 KiB
C++

// Without PCH
// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s
// With PCH
// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s
#ifndef HEADER1
#define HEADER1
//===----------------------------------------------------------------------===//
namespace NS {
template <class _Tp, _Tp __v>
struct TS
{
static const _Tp value = __v;
};
template <class _Tp, _Tp __v>
const _Tp TS<_Tp, __v>::value;
TS<int, 2> g1;
}
//===----------------------------------------------------------------------===//
#elif not defined(HEADER2)
#define HEADER2
#if !defined(HEADER1)
#error Header inclusion order messed up
#endif
int g2 = NS::TS<int, 2>::value;
//===----------------------------------------------------------------------===//
#else
//===----------------------------------------------------------------------===//
// expected-warning@+1 {{reached main file}}
#warning reached main file
int g3 = NS::TS<int, 2>::value;
//===----------------------------------------------------------------------===//
#endif