Author: rsmith Date: Fri Jul 15 15:53:25 2016 New Revision: 275612 URL: http://llvm.org/viewvc/llvm-project?rev=275612&view=rev Log: Push alias-declarations and alias-template declarations into scope even if they're redeclarations. This is necessary in order for name lookup to correctly find the most recent declaration of the name (which affects default template argument lookup and cross-module merging, among other things).
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp cfe/trunk/test/CXX/drs/dr6xx.cpp cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp cfe/trunk/test/Modules/submodules-merge-defs.cpp cfe/trunk/test/SemaCXX/alias-template.cpp cfe/trunk/test/SemaTemplate/alias-templates.cpp Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=275612&r1=275611&r2=275612&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jul 15 15:53:25 2016 @@ -8885,9 +8885,7 @@ Decl *Sema::ActOnAliasDeclaration(Scope NewND = NewTD; } - if (!Redeclaration) - PushOnScopeChains(NewND, S); - + PushOnScopeChains(NewND, S); ActOnDocumentableDecl(NewND); return NewND; } Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp?rev=275612&r1=275611&r2=275612&view=diff ============================================================================== --- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp (original) +++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp Fri Jul 15 15:53:25 2016 @@ -38,8 +38,8 @@ namespace VariableLengthArrays { using T = int[n]; // expected-error {{variable length array declaration not allowed at file scope}} const int m = 42; - using U = int[m]; // expected-note {{previous definition}} - using U = int[42]; // ok + using U = int[m]; + using U = int[42]; // expected-note {{previous definition}} using U = int; // expected-error {{type alias redefinition with different types ('int' vs 'int [42]')}} void f() { Modified: cfe/trunk/test/CXX/drs/dr6xx.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr6xx.cpp?rev=275612&r1=275611&r2=275612&view=diff ============================================================================== --- cfe/trunk/test/CXX/drs/dr6xx.cpp (original) +++ cfe/trunk/test/CXX/drs/dr6xx.cpp Fri Jul 15 15:53:25 2016 @@ -146,9 +146,9 @@ namespace dr616 { // dr616: no #if __cplusplus >= 201103L struct S { int n; } s; // FIXME: These should all be 'int &&' - using T = decltype(S().n); // expected-note 2{{previous}} + using T = decltype(S().n); using T = decltype(static_cast<S&&>(s).n); - using T = decltype(S().*&S::n); + using T = decltype(S().*&S::n); // expected-note 2{{previous}} using T = decltype(static_cast<S&&>(s).*&S::n); // expected-error {{different type}} using T = int&&; // expected-error {{different type}} #endif Modified: cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp?rev=275612&r1=275611&r2=275612&view=diff ============================================================================== --- cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp (original) +++ cfe/trunk/test/CXX/temp/temp.param/p15-cxx0x.cpp Fri Jul 15 15:53:25 2016 @@ -102,10 +102,10 @@ using D1 = drop<3, int, char, double, lo using D1 = types<long>; using T2 = take<4, int, char, double, long>::type; // expected-note {{previous}} -using T2 = types<int, char, double, long>; // FIXME: Desguar the types on the RHS in this diagnostic. // desired-error {{'types<void, void, void, void>' vs 'types<int, char, double, long>'}} using T2 = types<void, void, void, void>; // expected-error {{'types<void, void, void, void>' vs 'types<typename inner<_>::type, typename inner<_>::type, typename inner<_>::type, typename inner<_>::type>'}} +using T2 = types<int, char, double, long>; using D2 = drop<4, int, char, double, long>::type; using D2 = types<>; Modified: cfe/trunk/test/Modules/submodules-merge-defs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodules-merge-defs.cpp?rev=275612&r1=275611&r2=275612&view=diff ============================================================================== --- cfe/trunk/test/Modules/submodules-merge-defs.cpp (original) +++ cfe/trunk/test/Modules/submodules-merge-defs.cpp Fri Jul 15 15:53:25 2016 @@ -58,6 +58,11 @@ G::A pre_ga // expected-error +{{must be decltype(G::h) pre_gh = G::h; // expected-error +{{must be imported}} // expected-note@defs.h:51 +{{here}} +int pre_h = H(); // expected-error +{{must be imported}} +// expected-note@defs.h:56 +{{here}} +using pre_i = I<>; // expected-error +{{must be imported}} +// expected-note@defs.h:57 +{{here}} + J<> pre_j; // expected-error {{declaration of 'J' must be imported}} #ifdef IMPORT_USE_2 // expected-error-re@-2 {{default argument of 'J' must be imported from one of {{.*}}stuff.use{{.*}}stuff.use-2}} @@ -99,6 +104,8 @@ int post_ff = F<char>().f(); int post_fg = F<char>().g<int>(); G::A post_ga = G::a; decltype(G::h) post_gh = G::h; +int post_h = H(); +using post_i = I<>; J<> post_j; template<typename T, int N, template<typename> class K> struct J; J<> post_j2; Modified: cfe/trunk/test/SemaCXX/alias-template.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/alias-template.cpp?rev=275612&r1=275611&r2=275612&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/alias-template.cpp (original) +++ cfe/trunk/test/SemaCXX/alias-template.cpp Fri Jul 15 15:53:25 2016 @@ -35,8 +35,8 @@ namespace VariableLengthArrays { template<typename Z> using T = int[n]; // expected-error {{variable length array declaration not allowed at file scope}} const int m = 42; - template<typename Z> using U = int[m]; // expected-note {{previous definition}} - template<typename Z> using U = int[42]; // ok + template<typename Z> using U = int[m]; + template<typename Z> using U = int[42]; // expected-note {{previous definition}} template<typename Z> using U = int; // expected-error {{type alias template redefinition with different types ('int' vs 'int [42]')}} } Modified: cfe/trunk/test/SemaTemplate/alias-templates.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/alias-templates.cpp?rev=275612&r1=275611&r2=275612&view=diff ============================================================================== --- cfe/trunk/test/SemaTemplate/alias-templates.cpp (original) +++ cfe/trunk/test/SemaTemplate/alias-templates.cpp Fri Jul 15 15:53:25 2016 @@ -221,3 +221,9 @@ namespace PR14858 { template<typename ...T, typename ...U> void h(X<T...> &) {} template<typename ...T, typename ...U> void h(X<U...> &) {} // ok, different } + +namespace redecl { + template<typename> using A = int; + template<typename = void> using A = int; + A<> a; // ok +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits