blob: fdcae78b751e1e1b5c31f18eacdb2079c8bd93ad [file] [log] [blame]
Chandler Carruthba772ba2010-11-16 10:26:08 +00001// RUN: %clang_cc1 -ffreestanding -Eonly -verify %s
John Thompson92bd8c72009-11-02 22:28:12 +00002
3// Try different path permutations of __has_include with existing file.
Chandler Carruthba772ba2010-11-16 10:26:08 +00004#if __has_include("stdint.h")
John Thompson92bd8c72009-11-02 22:28:12 +00005#else
6 #error "__has_include failed (1)."
7#endif
8
Chandler Carruthba772ba2010-11-16 10:26:08 +00009#if __has_include(<stdint.h>)
John Thompson92bd8c72009-11-02 22:28:12 +000010#else
11 #error "__has_include failed (2)."
12#endif
13
14// Try unary expression.
Chandler Carruthba772ba2010-11-16 10:26:08 +000015#if !__has_include("stdint.h")
John Thompson92bd8c72009-11-02 22:28:12 +000016 #error "__has_include failed (5)."
17#endif
18
19// Try binary expression.
Chandler Carruthba772ba2010-11-16 10:26:08 +000020#if __has_include("stdint.h") && __has_include("stddef.h")
John Thompson92bd8c72009-11-02 22:28:12 +000021#else
22 #error "__has_include failed (6)."
23#endif
24
25// Try non-existing file.
26#if __has_include("blahblah.h")
27 #error "__has_include failed (7)."
28#endif
29
30// Try defined.
31#if !defined(__has_include)
32 #error "defined(__has_include) failed (8)."
33#endif
34
35// Try different path permutations of __has_include_next with existing file.
36#if __has_include_next("stddef.h") // expected-warning {{#include_next in primary source file}}
37#else
38 #error "__has_include failed (1)."
39#endif
40
41#if __has_include_next(<stddef.h>) // expected-warning {{#include_next in primary source file}}
42#else
43 #error "__has_include failed (2)."
44#endif
45
46// Try unary expression.
Chandler Carruthba772ba2010-11-16 10:26:08 +000047#if !__has_include_next("stdint.h") // expected-warning {{#include_next in primary source file}}
John Thompson92bd8c72009-11-02 22:28:12 +000048 #error "__has_include_next failed (5)."
49#endif
50
51// Try binary expression.
Chandler Carruthba772ba2010-11-16 10:26:08 +000052#if __has_include_next("stdint.h") && __has_include("stddef.h") // expected-warning {{#include_next in primary source file}}
John Thompson92bd8c72009-11-02 22:28:12 +000053#else
54 #error "__has_include_next failed (6)."
55#endif
56
57// Try non-existing file.
58#if __has_include_next("blahblah.h") // expected-warning {{#include_next in primary source file}}
59 #error "__has_include_next failed (7)."
60#endif
61
62// Try defined.
63#if !defined(__has_include_next)
64 #error "defined(__has_include_next) failed (8)."
65#endif
66
67// Try badly formed expressions.
68// FIXME: I don't quite know how to avoid preprocessor side effects.
69// Use FileCheck?
70// It also assert due to unterminated #if's.
Chandler Carruthba772ba2010-11-16 10:26:08 +000071//#if __has_include("stdint.h"
72//#if __has_include "stdint.h")
73//#if __has_include(stdint.h)
John Thompson92bd8c72009-11-02 22:28:12 +000074//#if __has_include()
75//#if __has_include(
76//#if __has_include)
77//#if __has_include
Chandler Carruthba772ba2010-11-16 10:26:08 +000078//#if __has_include(<stdint.h>
79//#if __has_include<stdint.h>)
80//#if __has_include("stdint.h)
81//#if __has_include(stdint.h")
82//#if __has_include(<stdint.h)
83//#if __has_include(stdint.h>)