Add missing mappings in pph.map. These new mappings result in changes to assembly difference expectations.
Remove namespace issues from x1template test. Copy that test to a new test x1namespace. Add a new test x1dynarray, which is executable, when existing failures get fixed. Index: gcc/testsuite/ChangeLog.pph 2011-06-27 Lawrence Crowl <cr...@google.com> * g++.dg/pph/pph.map: Add missing PPH mappings. * g++.dg/pph/c1funcstatic.cc: Add expected asm diff. * g++.dg/pph/c1eabi1.cc: Add xfail-if; remove expected asm diff. * g++.dg/pph/c2builtin2.cc: Add expected asm diff. * g++.dg/pph/x1funcstatic.cc: Add expected asm diff. * g++.dg/pph/x1template.h: Remove use of namespace. * g++.dg/pph/x1template.cc: Remove use of namespace; now passing. * g++.dg/pph/x1namespace.h: New, copy of old x1template.h. * g++.dg/pph/x1namespace.cc: New, copy of old x1template.cc. * g++.dg/pph/x1dynarray1.h: New executable program, but it fails. * g++.dg/pph/x1dynarray1.cc: New executable program, but it fails. Index: gcc/testsuite/g++.dg/pph/c1funcstatic.cc =================================================================== --- gcc/testsuite/g++.dg/pph/c1funcstatic.cc (revision 175566) +++ gcc/testsuite/g++.dg/pph/c1funcstatic.cc (working copy) @@ -1,2 +1,3 @@ +// pph asm xdiff #include "c1funcstatic.h" int g() { return f(); } Index: gcc/testsuite/g++.dg/pph/x1namespace.h =================================================================== --- gcc/testsuite/g++.dg/pph/x1namespace.h (revision 0) +++ gcc/testsuite/g++.dg/pph/x1namespace.h (revision 0) @@ -0,0 +1,22 @@ +#ifndef X1NAMESPACE_H +#define X1NAMESPACE_H +namespace A { +extern int x; +struct B; +template< typename T > +struct C { + T* b; + int method(); + int another() + { return *b; } +}; +template< typename T > +int C< T >::method() +{ return x; } +} // namespace A +struct D : A::C< int > { + int method(); + int another() + { return *b; } +}; +#endif Index: gcc/testsuite/g++.dg/pph/x1template.h =================================================================== --- gcc/testsuite/g++.dg/pph/x1template.h (revision 175566) +++ gcc/testsuite/g++.dg/pph/x1template.h (working copy) @@ -1,6 +1,5 @@ #ifndef X1TEMPLATE_H #define X1TEMPLATE_H -namespace A { extern int x; struct B; template< typename T > @@ -13,8 +12,7 @@ struct C { template< typename T > int C< T >::method() { return x; } -} // namespace A -struct D : A::C< int > { +struct D : C< int > { int method(); int another() { return *b; } Index: gcc/testsuite/g++.dg/pph/c1eabi1.cc =================================================================== --- gcc/testsuite/g++.dg/pph/c1eabi1.cc (revision 175566) +++ gcc/testsuite/g++.dg/pph/c1eabi1.cc (working copy) @@ -1,5 +1,5 @@ // { dg-timeout 2 { target *-*-* } } +// { dg-xfail-if "INFINITE" { "*-*-*" } { "-fpph-map=pph.map" } } // { dg-options "-w -fpermissive" } -// pph asm xdiff #include "c1eabi1.h" Index: gcc/testsuite/g++.dg/pph/c2builtin2.cc =================================================================== --- gcc/testsuite/g++.dg/pph/c2builtin2.cc (revision 175566) +++ gcc/testsuite/g++.dg/pph/c2builtin2.cc (working copy) @@ -1,3 +1,4 @@ +// pph asm xdiff #include "a2builtin4.h" #include "c2builtin5.h" #include "c2builtin6.h" Index: gcc/testsuite/g++.dg/pph/pph.map =================================================================== --- gcc/testsuite/g++.dg/pph/pph.map (revision 175566) +++ gcc/testsuite/g++.dg/pph/pph.map (working copy) @@ -6,9 +6,11 @@ c1builtin-integral-1.h c1builtin-integra c1builtin-object-size-2.h c1builtin-object-size-2.pph c1chained1.h c1chained1.pph c1chained2.h c1chained2.pph +c1eabi1.h c1eabi1.pph c1empty.h c1empty.pph c1field.h c1field.pph c1funcmac.h c1funcmac.pph +c1funcstatic.h c1funcstatic.pph c1functions.h c1functions.pph c1guarded1.h c1guarded1.pph c1guarded2.h c1guarded2.pph @@ -28,6 +30,8 @@ c1variables.h c1variables.pph c2builtin1.h c2builtin1.pph c2builtin2.h c2builtin2.pph c2builtin3.h c2builtin3.pph +c2builtin5.h c2builtin5.pph +c2builtin6.h c2builtin6.pph c2dupguard1.h c2dupguard1.pph c2dupguard2.h c2dupguard2.pph c2paste.h c2paste.pph @@ -38,10 +42,12 @@ stdlib.h stdlib.pph string.h string.pph sys/types.h types.pph x1autometh.h x1autometh.pph +x1dynarray1.h x1dynarray1.pph x1funcstatic.h x1funcstatic.pph x1functions.h x1functions.pph x1globalref.h x1globalref.pph x1hardlookup.h x1hardlookup.pph +x1namespace.h x1namespace.pph x1special.h x1special.pph x1struct0.h x1struct0.pph x1struct1.h x1struct1.pph @@ -53,6 +59,6 @@ x1tmplfunc.h x1tmplfunc.pph x1typerefs.h x1typerefs.pph x1variables.h x1variables.pph x2nontrivinit.h x2nontrivinit.pph -y2overload1.h y2overload1.pph -y2overload2.h y2overload2.pph -y2overload3.h y2overload3.pph +x2overload1.h x2overload1.pph +x2overload2.h x2overload2.pph +x2overload3.h x2overload3.pph Index: gcc/testsuite/g++.dg/pph/x1dynarray1.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x1dynarray1.cc (revision 0) +++ gcc/testsuite/g++.dg/pph/x1dynarray1.cc (revision 0) @@ -0,0 +1,34 @@ +// { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } } +// { dg-bogus "x1dynarray1.cc:1:0: internal compiler error: in pph_in_lang_specific, at cp/pph-streamer-in.c:887" "" { xfail *-*-* } 0 } + +#include "x1dynarray1.h" +#include <iostream> +#include <algorithm> + +void lowrap( std::dynarray< int > & target, + const std::dynarray< int > & source ) +{ + std::dynarray< int > sorted( source ); + std::sort( sorted.begin(), sorted.end() ); + const int* srt = &sorted.front(); + std::dynarray< int >::iterator tgt( target.begin() ); + for ( ; tgt != target.end(); tgt++ ) { + *tgt = *srt; + if ( srt == &sorted.back() ) + srt = &sorted.front(); + else + srt++; + } +} + +int main() { + std::dynarray< int > alpha(8); + std::dynarray< int > gamma(3); + for ( std::dynarray< int >::size_type i = 0; i < gamma.size(); i++ ) + gamma[i] = 4 - i; + lowrap( alpha, gamma ); + int sum = 0; + for ( std::dynarray< int >::size_type i = 0; i < alpha.size(); i++ ) + sum += alpha.at(i); + return sum - 23; +} Index: gcc/testsuite/g++.dg/pph/x1template.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x1template.cc (revision 175566) +++ gcc/testsuite/g++.dg/pph/x1template.cc (working copy) @@ -1,12 +1,7 @@ -// { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } } -// { dg-bogus "x1template.h:18:13: internal compiler error: in resume_scope" "" { xfail *-*-* } 0 } -// { dg-prune-output "In file included from " } - +// pph asm xdiff #include "x1template.h" -namespace A { int x = 3; -} // namespace A int y = 4; Index: gcc/testsuite/g++.dg/pph/x1dynarray1.h =================================================================== --- gcc/testsuite/g++.dg/pph/x1dynarray1.h (revision 0) +++ gcc/testsuite/g++.dg/pph/x1dynarray1.h (revision 0) @@ -0,0 +1,93 @@ +#ifndef X1DYNARRAY1_H +#define X1DYNARRAY1_H + +#include <memory> + +#define DefaultConstructible typename +#define CPP0X( ignore ) + +namespace std { + +template< DefaultConstructible T > +struct dynarray +{ + // types: + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef T* iterator; + typedef const T* const_iterator; + typedef unsigned long size_type; + typedef long difference_type; + + // fields: +private: + T* store; + size_type count; + + // helper functions: + void check(size_type n) + { if ( n >= count ) throw n; } + T* alloc(size_type n) + { return reinterpret_cast<T*>( new char[ n*sizeof(T) ] ); } + +public: + // construct and destruct: + dynarray() CPP0X( = delete ) ; + const dynarray operator=(const dynarray&) CPP0X( = delete ) ; + + explicit dynarray(size_type c) + : store( alloc( c ) ), count( c ) + { size_type i; + try { + for ( size_type i = 0; i < count; ++i ) + new (store+i) T; + } catch ( ... ) { + for ( ; i > 0; --i ) + (store+(i-1))->~T(); + throw; + } } + + dynarray(const dynarray& d) + : store( alloc( d.count ) ), count( d.count ) + { try { uninitialized_copy( d.begin(), d.end(), begin() ); } + catch ( ... ) { delete store; throw; } } + + ~dynarray() + { for ( size_type i = 0; i < count; ++i ) + (store+i)->~T(); + delete[] store; } + + // iterators: + iterator begin() { return store; } + const_iterator begin() const { return store; } + const_iterator cbegin() const { return store; } + iterator end() { return store + count; } + const_iterator end() const { return store + count; } + const_iterator cend() const { return store + count; } + + // capacity: + size_type size() const { return count; } + size_type max_size() const { return count; } + bool empty() const { return false; } + + // element access: + reference operator[](size_type n) { return store[n]; } + const_reference operator[](size_type n) const { return store[n]; } + + reference front() { return store[0]; } + const_reference front() const { return store[0]; } + reference back() { return store[count-1]; } + const_reference back() const { return store[count-1]; } + + const_reference at(size_type n) const { check(n); return store[n]; } + reference at(size_type n) { check(n); return store[n]; } + + // data access: + T* data() { return store; } + const T* data() const { return store; } +}; + +} // namespace std + +#endif Index: gcc/testsuite/g++.dg/pph/x1namespace.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x1namespace.cc (revision 0) +++ gcc/testsuite/g++.dg/pph/x1namespace.cc (revision 0) @@ -0,0 +1,17 @@ +// { dg-xfail-if "ICE" { "*-*-*" } { "-fpph-map=pph.map" } } +// { dg-bogus "x1namespace.h:18:13: internal compiler error: in resume_scope" "" { xfail *-*-* } 0 } +// { dg-prune-output "In file included from " } + +#include "x1namespace.h" + +namespace A { +int x = 3; +} // namespace A + +int y = 4; + +int D::method() +{ return y; } + +int main() +{ } Index: gcc/testsuite/g++.dg/pph/x1funcstatic.cc =================================================================== --- gcc/testsuite/g++.dg/pph/x1funcstatic.cc (revision 175566) +++ gcc/testsuite/g++.dg/pph/x1funcstatic.cc (working copy) @@ -1,2 +1,3 @@ +// pph asm xdiff #include "c1funcstatic.h" int a = f(); -- This patch is available for review at http://codereview.appspot.com/4636066