summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2013-01-16 19:32:21 +0000
committerAaron Ballman <aaron@aaronballman.com>2013-01-16 19:32:21 +0000
commit6ce0000dd52815db5ad3e7ff67fd14df244a2d81 (patch)
treea4c5533bc291655897c0519843ca6ae0d909056a /clang/test
parent0fab22544f065c4be06e3f3eda495a76dce17ae7 (diff)
downloadbcm5719-llvm-6ce0000dd52815db5ad3e7ff67fd14df244a2d81.tar.gz
bcm5719-llvm-6ce0000dd52815db5ad3e7ff67fd14df244a2d81.zip
No longer crashing with an assert when __has_include or __has_include_next is used outside of a preprocessor directive. This fixes PR14837.
llvm-svn: 172639
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Preprocessor/has_include.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/clang/test/Preprocessor/has_include.c b/clang/test/Preprocessor/has_include.c
index 985501a2151..4e71a369747 100644
--- a/clang/test/Preprocessor/has_include.c
+++ b/clang/test/Preprocessor/has_include.c
@@ -91,6 +91,28 @@
#error "__has_include with macro failed (2)."
#endif
+// Try as non-preprocessor directives
+void foo( void ) {
+ __has_include_next("stdint.h") // expected-warning {{#include_next in primary source file}} expected-error {{__has_include_next must be used within a preprocessing directive}}
+ __has_include("stdint.h") // expected-error {{__has_include must be used within a preprocessing directive}}
+}
+
+MACRO1 // expected-error {{__has_include must be used within a preprocessing directive}}
+
+#if 1
+MACRO1 // expected-error {{__has_include must be used within a preprocessing directive}}
+#endif
+
+#if 0
+#elif 1
+MACRO1 // expected-error {{__has_include must be used within a preprocessing directive}}
+#endif
+
+#if 0
+MACRO1 // This should be fine because it is never actually reached
+#endif
+
+
// Try badly formed expressions.
// FIXME: We can recover better in almost all of these cases. (PR13335)
@@ -126,7 +148,7 @@
#if __has_include(stdint.h>)
#endif
-// expected-error@+1 {{missing '(' after '__has_include'}}
+// expected-error@+1 {{__has_include must be used within a preprocessing directive}}
__has_include
// expected-error@+1 {{missing ')' after '__has_include'}} // expected-error@+1 {{expected value in expression}} // expected-note@+1 {{to match this '('}}
OpenPOWER on IntegriCloud