| 1 |
// RUN: %clang_cc1 -std=c++98 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -std=c++11 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s |
| 3 |
// RUN: %clang_cc1 -std=c++14 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s |
| 4 |
// RUN: %clang_cc1 -std=c++17 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s |
| 5 |
// RUN: %clang_cc1 -std=c++20 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s |
| 6 |
// RUN: %clang_cc1 -std=c++23 %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s |
| 7 |
// RUN: %clang_cc1 -std=c++2c %s -verify=expected -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump | FileCheck %s |
| 8 |
|
| 9 |
// expected-no-diagnostics |
| 10 |
|
| 11 |
namespace cwg1818 { // cwg1818: 3.4 |
| 12 |
extern "C" void f() { |
| 13 |
// This declaration binds name 'g' in the scope of function 'f', |
| 14 |
// but its target scope corresponds to namespace 'cwg1818' (_N4988_.[dcl.meaning]/3.5). |
| 15 |
// Linkage specification of 'f' applies to 'g' per _N4988_.[dcl.link]/5. |
| 16 |
void g(); |
| 17 |
} |
| 18 |
// Target scope of this declaration is naturally the one |
| 19 |
// that corresponds to namespace 'cwg1818', |
| 20 |
// which makes it declare the same entity |
| 21 |
// as the previous declaration per _N4988_.[basic.link]/8, |
| 22 |
// turning it into a redeclaration per _N4988_.[basic.def]/1. |
| 23 |
// Then _N4988_.[dcl.link]/6 applies, making it inherit |
| 24 |
// the (ะก) language linkage of the previous declaration. |
| 25 |
void g(); |
| 26 |
} // namespace cwg1818 |
| 27 |
|
| 28 |
// Check that the former 'g' has C language linkage, |
| 29 |
// then that the latter 'g' is considered to be a redeclaration of it, |
| 30 |
// which would make the latter 'g' inherit C language linkage from the former 'g'. |
| 31 |
|
| 32 |
// CHECK: LinkageSpecDecl [[LINKAGE_DECL:0x[0-9a-f]+]] {{.*}} C |
| 33 |
// CHECK: FunctionDecl [[FIRST_DECL:0x[0-9a-f]+]] parent [[LINKAGE_DECL]] {{.*}} g 'void ()' |
| 34 |
// CHECK: FunctionDecl {{.*}} prev [[FIRST_DECL]] {{.*}} g 'void ()' |