summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp')
-rw-r--r--gcc/testsuite/g++.dg/cpp/_Pragma1.C10
-rw-r--r--gcc/testsuite/g++.dg/cpp/c++98-pedantic.C10
-rw-r--r--gcc/testsuite/g++.dg/cpp/c++98.C10
-rw-r--r--gcc/testsuite/g++.dg/cpp/c++_cmd_1.C12
-rw-r--r--gcc/testsuite/g++.dg/cpp/c++_cmd_1.h6
-rw-r--r--gcc/testsuite/g++.dg/cpp/pedantic-errors.C5
-rw-r--r--gcc/testsuite/g++.dg/cpp/pragma-float-const-decimal64-1.C5
-rw-r--r--gcc/testsuite/g++.dg/cpp/string-1.C9
-rw-r--r--gcc/testsuite/g++.dg/cpp/string-2.C6
-rw-r--r--gcc/testsuite/g++.dg/cpp/stringop-1.C29
-rw-r--r--gcc/testsuite/g++.dg/cpp/truefalse.C17
-rw-r--r--gcc/testsuite/g++.dg/cpp/ucn-1.C13
-rw-r--r--gcc/testsuite/g++.dg/cpp/ucnid-1.C17
-rw-r--r--gcc/testsuite/g++.dg/cpp/weak.C5
14 files changed, 154 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp/_Pragma1.C b/gcc/testsuite/g++.dg/cpp/_Pragma1.C
new file mode 100644
index 000000000..2a4086b81
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/_Pragma1.C
@@ -0,0 +1,10 @@
+// PR c++/27748
+// This is supposed to succeed only if
+// the target doesn't define HANDLE_PRAGMA_PACK_WITH_EXPANSION.
+// { dg-do compile { target { ! { *-*-solaris2* } } } }
+
+#define push bar
+#define foo _Pragma ("pack(push)")
+foo
+int i;
+#pragma pack(pop)
diff --git a/gcc/testsuite/g++.dg/cpp/c++98-pedantic.C b/gcc/testsuite/g++.dg/cpp/c++98-pedantic.C
new file mode 100644
index 000000000..61e13c5d1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/c++98-pedantic.C
@@ -0,0 +1,10 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-std=c++98 -pedantic" } */
+
+/* This file is for testing the preprocessor in -std=c++98 -pedantic mode.
+ Neil Booth, 2 Dec 2000. */
+
+#if 1LL /* { dg-warning "long long" } */
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp/c++98.C b/gcc/testsuite/g++.dg/cpp/c++98.C
new file mode 100644
index 000000000..0ec4f359f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/c++98.C
@@ -0,0 +1,10 @@
+/* Copyright (C) 2000 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-std=c++98" } */
+
+/* This file is for testing the preprocessor in -std=c++98 mode.
+ Neil Booth, 2 Dec 2000. */
+
+#if 1LL
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp/c++_cmd_1.C b/gcc/testsuite/g++.dg/cpp/c++_cmd_1.C
new file mode 100644
index 000000000..e4e048293
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/c++_cmd_1.C
@@ -0,0 +1,12 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-c -include ${srcdir}/g++.dg/cpp/c++_cmd_1.h" } */
+
+/* Contributed by Devang Patel <dpatel@apple.com> */
+
+int main ()
+{
+ return 0;
+}
+
diff --git a/gcc/testsuite/g++.dg/cpp/c++_cmd_1.h b/gcc/testsuite/g++.dg/cpp/c++_cmd_1.h
new file mode 100644
index 000000000..06f4941bc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/c++_cmd_1.h
@@ -0,0 +1,6 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc. */
+
+/* Contributed by Devang Patel <dpatel@apple.com> */
+
+/* Header file for c++_cmd_1.C */
+
diff --git a/gcc/testsuite/g++.dg/cpp/pedantic-errors.C b/gcc/testsuite/g++.dg/cpp/pedantic-errors.C
new file mode 100644
index 000000000..0c6045af8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/pedantic-errors.C
@@ -0,0 +1,5 @@
+/* { dg-do preprocess } */
+/* { dg-options "-std=c++98 -pedantic-errors" } */
+
+#if 1
+#endif 1 /* { dg-error "extra tokens at end of #endif directive" } */
diff --git a/gcc/testsuite/g++.dg/cpp/pragma-float-const-decimal64-1.C b/gcc/testsuite/g++.dg/cpp/pragma-float-const-decimal64-1.C
new file mode 100644
index 000000000..31e1ad6d5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/pragma-float-const-decimal64-1.C
@@ -0,0 +1,5 @@
+// { dg-do compile }
+// { dg-options "-Wunknown-pragmas" }
+
+#pragma STDC FLOAT_CONST_DECIMAL64 ON // { dg-warning "not supported for C\\\+\\\+" }
+double d = 1.0;
diff --git a/gcc/testsuite/g++.dg/cpp/string-1.C b/gcc/testsuite/g++.dg/cpp/string-1.C
new file mode 100644
index 000000000..da3133071
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/string-1.C
@@ -0,0 +1,9 @@
+// Test location of diagnostics for interpreting strings. Bug 17964.
+// Origin: Joseph Myers <joseph@codesourcery.com>
+// { dg-do compile }
+
+const char *s = "\q"; // { dg-error "unknown escape sequence" }
+
+const char *t = "\ "; // { dg-error "unknown escape sequence" }
+
+const char *u = "";
diff --git a/gcc/testsuite/g++.dg/cpp/string-2.C b/gcc/testsuite/g++.dg/cpp/string-2.C
new file mode 100644
index 000000000..f71486231
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/string-2.C
@@ -0,0 +1,6 @@
+// Test diagnostics for interpreting strings: This is a pedwarn.
+// Origin: Joseph Myers <joseph@codesourcery.com>
+// { dg-do compile }
+// { dg-options "" }
+
+const char *s = "\q"; // { dg-warning "unknown escape sequence" }
diff --git a/gcc/testsuite/g++.dg/cpp/stringop-1.C b/gcc/testsuite/g++.dg/cpp/stringop-1.C
new file mode 100644
index 000000000..071a1009c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/stringop-1.C
@@ -0,0 +1,29 @@
+/* Test for buffer overrun stringizing named operators longer than 4
+ characters. */
+/* { dg-do compile } */
+
+#define str(x) #x
+#define var(v,a,b,c,d) static const char v##a##b##c##d[] = str(xor_eq)
+#define var1(v,a,b,c) \
+ var(v,a,b,c,0); var(v,a,b,c,1); var(v,a,b,c,2); var(v,a,b,c,3); \
+ var(v,a,b,c,4); var(v,a,b,c,5); var(v,a,b,c,6); var(v,a,b,c,7); \
+ var(v,a,b,c,8); var(v,a,b,c,9)
+#define var2(v,a,b) \
+ var1(v,a,b,0); var1(v,a,b,1); var1(v,a,b,2); var1(v,a,b,3); \
+ var1(v,a,b,4); var1(v,a,b,5); var1(v,a,b,6); var1(v,a,b,7); \
+ var1(v,a,b,8); var1(v,a,b,9)
+#define var3(v,a) \
+ var2(v,a,0); var2(v,a,1); var2(v,a,2); var2(v,a,3); \
+ var2(v,a,4); var2(v,a,5); var2(v,a,6); var2(v,a,7); \
+ var2(v,a,8); var2(v,a,9)
+
+var3(v,0);
+var3(v,1);
+var3(v,2);
+var3(v,3);
+var3(v,4);
+var3(v,5);
+var3(v,6);
+var3(v,7);
+var3(v,8);
+var3(v,9);
diff --git a/gcc/testsuite/g++.dg/cpp/truefalse.C b/gcc/testsuite/g++.dg/cpp/truefalse.C
new file mode 100644
index 000000000..d852d4e2f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/truefalse.C
@@ -0,0 +1,17 @@
+/* Copyright (C) 2003 Free Software Foundation, Inc. */
+
+/* Source: Neil Booth, 18 Apr 2003. */
+
+/* { dg-do preprocess } */
+/* { dg-options "-ansi -pedantic -Wundef" } */
+
+/* Check that for C++ we handle true and false correctly, and do not
+ treat them as undefined identifiers. */
+
+#if true /* { dg-bogus "is not defined" } */
+#error foo /* { dg-error "foo" } */
+#endif
+
+#if false /* { dg-bogus "is not defined" } */
+#error foo /* { dg-bogus "foo" } */
+#endif
diff --git a/gcc/testsuite/g++.dg/cpp/ucn-1.C b/gcc/testsuite/g++.dg/cpp/ucn-1.C
new file mode 100644
index 000000000..354e1d976
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/ucn-1.C
@@ -0,0 +1,13 @@
+// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2170.html
+// { dg-options "-std=c++0x -fextended-identifiers" }
+
+int main()
+{
+ "\u0041"; // 'A' UCN is OK in string literal
+ '\u0041'; // also OK in character literal
+
+ int c\u0041c; // { dg-error "not valid in an identifier" }
+ int c\u0024c; // $ is OK; not part of basic source char set
+
+ U"\uD800"; // { dg-error "not a valid universal character" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp/ucnid-1.C b/gcc/testsuite/g++.dg/cpp/ucnid-1.C
new file mode 100644
index 000000000..7a8f72a5d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/ucnid-1.C
@@ -0,0 +1,17 @@
+/* { dg-do preprocess } */
+/* { dg-options "-std=gnu++98 -pedantic -fextended-identifiers" } */
+
+\u00AA /* { dg-error "not valid in an identifier" } */
+\u00AB /* { dg-error "not valid in an identifier" } */
+\u00B6 /* { dg-error "not valid in an identifier" } */
+\u00BA /* { dg-error "not valid in an identifier" } */
+\u00C0
+\u00D6
+\u0384
+
+\u0669 /* { dg-error "not valid in an identifier" } */
+A\u0669 /* { dg-error "not valid in an identifier" } */
+0\u00BA /* { dg-error "not valid in an identifier" } */
+0\u0669 /* { dg-error "not valid in an identifier" } */
+\u0E59
+A\u0E59
diff --git a/gcc/testsuite/g++.dg/cpp/weak.C b/gcc/testsuite/g++.dg/cpp/weak.C
new file mode 100644
index 000000000..6c51e1985
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp/weak.C
@@ -0,0 +1,5 @@
+// { dg-options "-fno-weak" }
+
+#if __GXX_WEAK__
+#error "__GXX_WEAK__ defined when -fno-weak in use"
+#endif