summaryrefslogtreecommitdiffstats
path: root/test/Lexer
diff options
context:
space:
mode:
Diffstat (limited to 'test/Lexer')
-rw-r--r--test/Lexer/11-27-2007-FloatLiterals.c7
-rw-r--r--test/Lexer/badstring_in_if0.c8
-rw-r--r--test/Lexer/block_cmt_end.c38
-rw-r--r--test/Lexer/c90.c13
-rw-r--r--test/Lexer/comment-escape.c6
-rw-r--r--test/Lexer/constants.c35
-rw-r--r--test/Lexer/counter.c16
-rw-r--r--test/Lexer/cxx0x_keyword.cpp2
-rw-r--r--test/Lexer/cxx0x_keyword_as_cxx98.cpp2
-rw-r--r--test/Lexer/digraph.c15
-rw-r--r--test/Lexer/dollar-idents.c7
-rw-r--r--test/Lexer/escape_newline.c7
-rw-r--r--test/Lexer/multiple-include.c27
-rw-r--r--test/Lexer/numeric-literal-trash.c13
-rw-r--r--test/Lexer/pragma-mark.c11
-rw-r--r--test/Lexer/rdr-6096838-2.c5
-rw-r--r--test/Lexer/rdr-6096838.c6
-rw-r--r--test/Lexer/token-concat.c4
-rw-r--r--test/Lexer/unknown-char.c2
19 files changed, 224 insertions, 0 deletions
diff --git a/test/Lexer/11-27-2007-FloatLiterals.c b/test/Lexer/11-27-2007-FloatLiterals.c
new file mode 100644
index 0000000..f3ea7cb
--- /dev/null
+++ b/test/Lexer/11-27-2007-FloatLiterals.c
@@ -0,0 +1,7 @@
+// RUN: clang-cc %s -emit-llvm -o - | grep 0x3BFD83C940000000 | count 2 &&
+// RUN: clang-cc %s -emit-llvm -o - | grep 2.000000e+32 | count 2
+
+float F = 1e-19f;
+double D = 2e32;
+float F2 = 01e-19f;
+double D2 = 02e32;
diff --git a/test/Lexer/badstring_in_if0.c b/test/Lexer/badstring_in_if0.c
new file mode 100644
index 0000000..5fa5a2b
--- /dev/null
+++ b/test/Lexer/badstring_in_if0.c
@@ -0,0 +1,8 @@
+// RUN: clang-cc -E %s 2>&1 | not grep error
+#if 0
+
+ "
+
+ '
+
+#endif
diff --git a/test/Lexer/block_cmt_end.c b/test/Lexer/block_cmt_end.c
new file mode 100644
index 0000000..d85cf81
--- /dev/null
+++ b/test/Lexer/block_cmt_end.c
@@ -0,0 +1,38 @@
+/*
+ RUN: clang-cc -E -trigraphs %s | grep bar &&
+ RUN: clang-cc -E -trigraphs %s | grep foo &&
+ RUN: clang-cc -E -trigraphs %s | not grep abc &&
+ RUN: clang-cc -E -trigraphs %s | not grep xyz &&
+ RUN: clang-cc -fsyntax-only -trigraphs -verify %s
+*/
+
+// This is a simple comment, /*/ does not end a comment, the trailing */ does.
+int i = /*/ */ 1;
+
+/* abc
+
+next comment ends with normal escaped newline:
+*/
+
+/* expected-warning {{escaped newline}} expected-warning {{backslash and newline}} *\
+/
+
+int bar
+
+/* xyz
+
+next comment ends with a trigraph escaped newline: */
+
+/* expected-warning {{escaped newline between}} expected-warning {{backslash and newline separated by space}} expected-warning {{trigraph ends block comment}} *??/
+/
+
+foo /* expected-error {{invalid token after top level declarator}} */
+
+
+// rdar://6060752 - We should not get warnings about trigraphs in comments:
+// '????'
+/* ???? */
+
+
+
+
diff --git a/test/Lexer/c90.c b/test/Lexer/c90.c
new file mode 100644
index 0000000..d743d68
--- /dev/null
+++ b/test/Lexer/c90.c
@@ -0,0 +1,13 @@
+/* RUN: clang-cc -std=c90 -fsyntax-only %s -verify -pedantic-errors
+ */
+
+enum { cast_hex = (long) (
+ 0x0p-1 /* expected-error {{hexadecimal floating constants are a C99 feature}} */
+ ) };
+
+/* PR2477 */
+int test1(int a,int b) {return a//* This is a divide followed by block comment in c89 mode */
+b;}
+
+// comment accepted as extension /* expected-error {{// comments are not allowed in this language}}
+
diff --git a/test/Lexer/comment-escape.c b/test/Lexer/comment-escape.c
new file mode 100644
index 0000000..c568cd6
--- /dev/null
+++ b/test/Lexer/comment-escape.c
@@ -0,0 +1,6 @@
+// RUN: clang -fsyntax-only %s
+// rdar://6757323
+// foo \
+
+#define blork 32
+
diff --git a/test/Lexer/constants.c b/test/Lexer/constants.c
new file mode 100644
index 0000000..fcb6de9
--- /dev/null
+++ b/test/Lexer/constants.c
@@ -0,0 +1,35 @@
+// RUN: clang-cc -fsyntax-only -verify -pedantic -trigraphs %s
+
+int x = 000000080; // expected-error {{invalid digit}}
+
+int y = 0000\
+00080; // expected-error {{invalid digit}}
+
+
+
+float X = 1.17549435e-38F;
+float Y = 08.123456;
+
+// PR2252
+#if -0x8000000000000000 // should not warn.
+#endif
+
+
+char c[] = {
+ 'df', // expected-warning {{multi-character character constant}}
+ '\t',
+ '\\
+t',
+ '??!', // expected-warning {{trigraph converted to '|' character}}
+ 'abcd' // expected-warning {{multi-character character constant}}
+};
+
+
+#pragma clang diagnostic ignored "-Wmultichar"
+
+char d = 'df'; // no warning.
+char e = 'abcd'; // still warn: expected-warning {{multi-character character constant}}
+
+#pragma clang diagnostic ignored "-Wfour-char-constants"
+
+char f = 'abcd'; // ignored.
diff --git a/test/Lexer/counter.c b/test/Lexer/counter.c
new file mode 100644
index 0000000..9b2c2c7
--- /dev/null
+++ b/test/Lexer/counter.c
@@ -0,0 +1,16 @@
+// __COUNTER__ support: rdar://4329310
+// RUN: clang -E %s > %t &&
+
+#define PASTE2(x,y) x##y
+#define PASTE1(x,y) PASTE2(x,y)
+#define UNIQUE(x) PASTE1(x,__COUNTER__)
+
+// RUN: grep "A: 0" %t &&
+A: __COUNTER__
+
+// RUN: grep "B: foo1" %t &&
+B: UNIQUE(foo);
+// RUN: grep "C: foo2" %t &&
+C: UNIQUE(foo);
+// RUN: grep "D: 3" %t
+D: __COUNTER__
diff --git a/test/Lexer/cxx0x_keyword.cpp b/test/Lexer/cxx0x_keyword.cpp
new file mode 100644
index 0000000..412c25e
--- /dev/null
+++ b/test/Lexer/cxx0x_keyword.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s 2>&1
+int static_assert; /* expected-error {{expected unqualified-id}} */
diff --git a/test/Lexer/cxx0x_keyword_as_cxx98.cpp b/test/Lexer/cxx0x_keyword_as_cxx98.cpp
new file mode 100644
index 0000000..9f8aea1
--- /dev/null
+++ b/test/Lexer/cxx0x_keyword_as_cxx98.cpp
@@ -0,0 +1,2 @@
+// RUN: clang-cc %s -fsyntax-only
+int static_assert;
diff --git a/test/Lexer/digraph.c b/test/Lexer/digraph.c
new file mode 100644
index 0000000..4d494ca
--- /dev/null
+++ b/test/Lexer/digraph.c
@@ -0,0 +1,15 @@
+// RUN: clang-cc -fsyntax-only -verify < %s
+
+%:include <stdio.h>
+
+ %:ifndef BUFSIZE
+ %:define BUFSIZE 512
+ %:endif
+
+ void copy(char d<::>, const char s<::>, int len)
+ <%
+ while (len-- >= 0)
+ <%
+ d<:len:> = s<:len:>;
+ %>
+ %>
diff --git a/test/Lexer/dollar-idents.c b/test/Lexer/dollar-idents.c
new file mode 100644
index 0000000..7635ea1
--- /dev/null
+++ b/test/Lexer/dollar-idents.c
@@ -0,0 +1,7 @@
+// RUN: clang-cc -dump-tokens %s 2> %t &&
+// RUN: grep "identifier '\$A'" %t
+// RUN: clang-cc -dump-tokens -x assembler-with-cpp %s 2> %t &&
+// RUN: grep "identifier 'A'" %t
+// PR3808
+
+$A
diff --git a/test/Lexer/escape_newline.c b/test/Lexer/escape_newline.c
new file mode 100644
index 0000000..ce120ed
--- /dev/null
+++ b/test/Lexer/escape_newline.c
@@ -0,0 +1,7 @@
+// RUN: clang-cc -E -trigraphs %s | grep -- ' ->' &&
+// RUN: clang-cc -E -trigraphs %s 2>&1 | grep 'backslash and newline separated by space' &&
+// RUN: clang-cc -E -trigraphs %s 2>&1 | grep 'trigraph converted'
+
+// This is an ugly way to spell a -> token.
+ -??/
+>
diff --git a/test/Lexer/multiple-include.c b/test/Lexer/multiple-include.c
new file mode 100644
index 0000000..e5fd529
--- /dev/null
+++ b/test/Lexer/multiple-include.c
@@ -0,0 +1,27 @@
+// RUN: clang-cc %s -fsyntax-only
+
+#ifndef XVID_AUTO_INCLUDE
+
+#define XVID_AUTO_INCLUDE
+#define FUNC_H H_Pass_16_C
+#include "multiple-include.c"
+
+#define FUNC_H H_Pass_8_C
+
+#include "multiple-include.c"
+#undef XVID_AUTO_INCLUDE
+
+typedef void ff();
+typedef struct { ff *a;} S;
+
+S s = { H_Pass_8_C };
+
+#endif
+
+#if defined(XVID_AUTO_INCLUDE) && defined(REFERENCE_CODE)
+#elif defined(XVID_AUTO_INCLUDE) && !defined(REFERENCE_CODE)
+
+static void FUNC_H(){};
+#undef FUNC_H
+
+#endif
diff --git a/test/Lexer/numeric-literal-trash.c b/test/Lexer/numeric-literal-trash.c
new file mode 100644
index 0000000..047e0b8
--- /dev/null
+++ b/test/Lexer/numeric-literal-trash.c
@@ -0,0 +1,13 @@
+/* RUN: clang-cc -fsyntax-only -verify %s
+ */
+# define XRECORD(x, c_name) e##c (x, __LINE__)
+
+
+
+
+
+
+ void x() {
+
+XRECORD (XRECORD (1, 1), 1);
+ }
diff --git a/test/Lexer/pragma-mark.c b/test/Lexer/pragma-mark.c
new file mode 100644
index 0000000..f4204aa
--- /dev/null
+++ b/test/Lexer/pragma-mark.c
@@ -0,0 +1,11 @@
+// RUN: clang-cc %s -fsyntax-only -verify
+
+// Lexer diagnostics shouldn't be included in #pragma mark.
+#pragma mark Mike's world
+_Pragma("mark foo ' bar")
+
+#define X(S) _Pragma(S)
+X("mark foo ' bar")
+
+int i;
+
diff --git a/test/Lexer/rdr-6096838-2.c b/test/Lexer/rdr-6096838-2.c
new file mode 100644
index 0000000..b135dc1
--- /dev/null
+++ b/test/Lexer/rdr-6096838-2.c
@@ -0,0 +1,5 @@
+/* RUN: clang-cc -pedantic -std=gnu89 -fsyntax-only -verify %s
+ rdar://6096838
+ */
+
+long double d = 0x0.0000003ffffffff00000p-16357L; /* expected-warning {{ hexadecimal floating constants are a C99 feature }} */
diff --git a/test/Lexer/rdr-6096838.c b/test/Lexer/rdr-6096838.c
new file mode 100644
index 0000000..60e5244
--- /dev/null
+++ b/test/Lexer/rdr-6096838.c
@@ -0,0 +1,6 @@
+/* RUN: clang-cc -fsyntax-only -verify %s &&
+ * RUN: clang-cc -std=gnu89 -fsyntax-only -verify %s
+ rdar://6096838
+ */
+
+long double d = 0x0.0000003ffffffff00000p-16357L;
diff --git a/test/Lexer/token-concat.c b/test/Lexer/token-concat.c
new file mode 100644
index 0000000..4e27d5d
--- /dev/null
+++ b/test/Lexer/token-concat.c
@@ -0,0 +1,4 @@
+// RUN: clang-cc -E -x c -o %t %s &&
+// RUN: grep 'IDENT.2' %t
+
+IDENT.2
diff --git a/test/Lexer/unknown-char.c b/test/Lexer/unknown-char.c
new file mode 100644
index 0000000..acbf4f0
--- /dev/null
+++ b/test/Lexer/unknown-char.c
@@ -0,0 +1,2 @@
+// RUN: clang-cc -E %s 2>&1 | not grep error
+ ` ` ` `
OpenPOWER on IntegriCloud