Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 llvm-svn: 276653
- Loading branch information
Sunil Srivastava
committed
Jul 25, 2016
1 parent
0cdbe7a
commit fe58327
Showing
3 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
/* For use with the pragma-once.c test */ | ||
|
||
int x = 3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } |