aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/basic
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/basic')
-rw-r--r--test/CXX/basic/basic.def.odr/p1-var.cpp21
-rw-r--r--test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp2
2 files changed, 22 insertions, 1 deletions
diff --git a/test/CXX/basic/basic.def.odr/p1-var.cpp b/test/CXX/basic/basic.def.odr/p1-var.cpp
new file mode 100644
index 000000000000..892f546ee545
--- /dev/null
+++ b/test/CXX/basic/basic.def.odr/p1-var.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++ [basic.def.odr]p1:
+// No translation unit shall contain more than one definition of any
+// variable, [...].
+
+// Bad: in C++, these are both definitions. None of that C99 tentative stuff.
+int i; // expected-note {{previous}}
+int i; // expected-error {{redefinition}}
+
+// OK: decl + def
+extern int j;
+int j;
+
+// OK: def + decl
+int k;
+extern int k;
+
+// Bad. The important thing here is that we don't emit the diagnostic twice.
+int l = 1; // expected-note {{previous}}
+int l = 2; // expected-error {{redefinition}}
diff --git a/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp b/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
index 76b6e2b57465..8126d28562ae 100644
--- a/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
+++ b/test/CXX/basic/basic.lookup/basic.lookup.elab/templateid.cpp
@@ -15,4 +15,4 @@ namespace A {
}
class Ident<int> GlobalIdent;
-union Ident<int> GlobalIdent; // expected-error {{ tag type that does not match }}
+union Ident<int> GlobalIdent2; // expected-error {{ tag type that does not match }}