| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
// C++ [basic.def.odr]p1: |
| 4 |
// No translation unit shall contain more than one definition of any |
| 5 |
// variable, [...]. |
| 6 |
|
| 7 |
// Bad: in C++, these are both definitions. None of that C99 tentative stuff. |
| 8 |
int i; // expected-note {{previous}} |
| 9 |
int i; // expected-error {{redefinition}} |
| 10 |
|
| 11 |
// OK: decl + def |
| 12 |
extern int j; |
| 13 |
int j; |
| 14 |
|
| 15 |
// OK: def + decl |
| 16 |
int k; |
| 17 |
extern int k; |
| 18 |
|
| 19 |
// Bad. The important thing here is that we don't emit the diagnostic twice. |
| 20 |
int l = 1; // expected-note {{previous}} |
| 21 |
int l = 2; // expected-error {{redefinition}} |