27 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify -Wtentative-definition-compat %s2// RUN: %clang_cc1 -fsyntax-only -verify -Wc++-compat %s3// RUN: %clang_cc1 -fsyntax-only -verify=good %s4// RUN: %clang_cc1 -fsyntax-only -verify=cxx -x c++ %s5// good-no-diagnostics6 7int i; // expected-note {{previous declaration is here}} \8 cxx-note {{previous definition is here}}9int i; // expected-warning {{duplicate declaration of 'i' is invalid in C++}} \10 cxx-error {{redefinition of 'i'}}11 12int j = 12; // expected-note {{previous declaration is here}} \13 cxx-note {{previous definition is here}}14int j; // expected-warning {{duplicate declaration of 'j' is invalid in C++}} \15 cxx-error {{redefinition of 'j'}}16 17int k; // expected-note {{previous declaration is here}} \18 cxx-note {{previous definition is here}}19int 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 in23// both C and C++. However, C++ does have a different definition of what makes24// a declaration a definition.25extern const int a;26const int a = 12; // Okay in C and C++27