Debian Codegraph @

clang/test/Sema/warn-tentative-defn-compat.c

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wtentative-definition-compat %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -Wc++-compat %s
3 // RUN: %clang_cc1 -fsyntax-only -verify=good %s
4 // RUN: %clang_cc1 -fsyntax-only -verify=cxx -x c++ %s
5 // good-no-diagnostics
6
7 int i; // expected-note {{previous declaration is here}} \
8 cxx-note {{previous definition is here}}
9 int i; // expected-warning {{duplicate declaration of 'i' is invalid in C++}} \
10 cxx-error {{redefinition of 'i'}}
11
12 int j = 12; // expected-note {{previous declaration is here}} \
13 cxx-note {{previous definition is here}}
14 int j; // expected-warning {{duplicate declaration of 'j' is invalid in C++}} \
15 cxx-error {{redefinition of 'j'}}
16
17 int k; // expected-note {{previous declaration is here}} \
18 cxx-note {{previous definition is here}}
19 int k = 12; // expected-warning {{duplicate declaration of 'k' is invalid in C++}} \
20 cxx-error {{redefinition of 'k'}}
21
22 // Cannot have two declarations with initializers, that is a redefinition in
23 // both C and C++. However, C++ does have a different definition of what makes
24 // a declaration a definition.
25 extern const int a;
26 const int a = 12; // Okay in C and C++