diff options
author | Sunil Srivastava <sunil_srivastava@playstation.sony.com> | 2016-07-25 17:17:06 +0000 |
---|---|---|
committer | Sunil Srivastava <sunil_srivastava@playstation.sony.com> | 2016-07-25 17:17:06 +0000 |
commit | b17dedc4e2f3828d043ebce3032d820d454ab5d8 (patch) | |
tree | 94ecf6aac7cc69eff7fd5f0506c5ff3325d0f4b7 /test/PCH | |
parent | 705ef1994eeed85831dd5f30193ad21db0363b90 (diff) |
Support '#pragma once' in headers when using PCH
The '#pragma once' directive was erroneously ignored when encountered
in the header-file specified in generate-PCH-mode. This resulted in
compile-time errors in some cases with legal code, and also a misleading
warning being produced.
Patch by Warren Ristow!
Differential Revision: http://reviews.llvm.org/D19815
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@276653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/Inputs/pragma-once.h | 5 | ||||
-rw-r--r-- | test/PCH/pragma-once.c | 13 |
2 files changed, 18 insertions, 0 deletions
diff --git a/test/PCH/Inputs/pragma-once.h b/test/PCH/Inputs/pragma-once.h new file mode 100644 index 0000000000..831cf553c7 --- /dev/null +++ b/test/PCH/Inputs/pragma-once.h @@ -0,0 +1,5 @@ +#pragma once + +/* For use with the pragma-once.c test */ + +int x = 3; diff --git a/test/PCH/pragma-once.c b/test/PCH/pragma-once.c new file mode 100644 index 0000000000..15e8503c11 --- /dev/null +++ b/test/PCH/pragma-once.c @@ -0,0 +1,13 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %S/Inputs/pragma-once.h -fsyntax-only -verify %s + +// Test with pch. +// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/pragma-once.h +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s + +// expected-no-diagnostics + +// Including "pragma-once.h" twice, to verify the 'once' aspect is honored. +#include "Inputs/pragma-once.h" +#include "Inputs/pragma-once.h" +int foo(void) { return 0; } |