From a67c967bb5f330709ee5c8c281243f52de8fbecf Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 17 Oct 2013 17:15:46 +0000 Subject: re PR c++/58596 ([c++11] ICE with decltype in non-static data member initializer) /cp 2013-10-17 Paolo Carlini PR c++/58596 * semantics.c (lambda_expr_this_capture): Handle NSDMIs in the cp_unevaluated_operand case. /testsuite 2013-10-17 Paolo Carlini PR c++/58596 * g++.dg/cpp0x/lambda/lambda-nsdmi5.C: New From-SVN: r203784 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 9 ++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C | 7 +++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 11d4f32ef48..d411523bbc7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-10-17 Paolo Carlini + + PR c++/58596 + * semantics.c (lambda_expr_this_capture): Handle NSDMIs in the + cp_unevaluated_operand case. + 2013-10-16 Paolo Carlini PR c++/58633 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 580c609ac9c..571fc7c6745 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9481,7 +9481,14 @@ lambda_expr_this_capture (tree lambda) /* In unevaluated context this isn't an odr-use, so just return the nearest 'this'. */ if (cp_unevaluated_operand) - return lookup_name (this_identifier); + { + /* In an NSDMI the fake 'this' pointer that we're using for + parsing is in scope_chain. */ + if (LAMBDA_EXPR_EXTRA_SCOPE (lambda) + && TREE_CODE (LAMBDA_EXPR_EXTRA_SCOPE (lambda)) == FIELD_DECL) + return scope_chain->x_current_class_ptr; + return lookup_name (this_identifier); + } /* Try to default capture 'this' if we can. */ if (!this_capture diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 85c2683e31b..3740c532739 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-10-17 Paolo Carlini + + PR c++/58596 + * g++.dg/cpp0x/lambda/lambda-nsdmi5.C: New + 2013-10-16 Paolo Carlini PR c++/58633 diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C new file mode 100644 index 00000000000..1d2778fb5ac --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nsdmi5.C @@ -0,0 +1,7 @@ +// PR c++/58596 +// { dg-do compile { target c++11 } } + +struct A +{ + int i = [] { return decltype(i)(); }(); +}; -- cgit v1.2.3 From a79bd609e87f57caa119c868e080f22d94003f9a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 17 Oct 2013 18:41:40 +0000 Subject: syscall: Add Dup3, {Get,List,Remove,Set}xattr, {Get,Set}priority. From-SVN: r203789 --- libgo/config.h.in | 15 +++++++++++ libgo/configure | 2 +- libgo/configure.ac | 2 +- libgo/go/syscall/libcall_linux.go | 15 +++++++++++ libgo/go/syscall/libcall_posix.go | 6 +++++ libgo/mksysinfo.sh | 4 +++ libgo/runtime/go-nosys.c | 57 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 99 insertions(+), 2 deletions(-) diff --git a/libgo/config.h.in b/libgo/config.h.in index 1057d9e85e4..f6da8b982c4 100644 --- a/libgo/config.h.in +++ b/libgo/config.h.in @@ -39,6 +39,9 @@ /* Define to 1 if you have the `dl_iterate_phdr' function. */ #undef HAVE_DL_ITERATE_PHDR +/* Define to 1 if you have the `dup3' function. */ +#undef HAVE_DUP3 + /* Define to 1 if you have the `epoll_create1' function. */ #undef HAVE_EPOLL_CREATE1 @@ -66,6 +69,9 @@ /* Define if _Unwind_GetIPInfo is available. */ #undef HAVE_GETIPINFO +/* Define to 1 if you have the `getxattr' function. */ +#undef HAVE_GETXATTR + /* Define to 1 if you have the `inotify_add_watch' function. */ #undef HAVE_INOTIFY_ADD_WATCH @@ -111,6 +117,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_RTNETLINK_H +/* Define to 1 if you have the `listxattr' function. */ +#undef HAVE_LISTXATTR + /* Define to 1 if the system has the type `loff_t'. */ #undef HAVE_LOFF_T @@ -171,6 +180,9 @@ /* Define to 1 if you have the `pipe2' function. */ #undef HAVE_PIPE2 +/* Define to 1 if you have the `removexattr' function. */ +#undef HAVE_REMOVEXATTR + /* Define to 1 if you have the `renameat' function. */ #undef HAVE_RENAMEAT @@ -180,6 +192,9 @@ /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV +/* Define to 1 if you have the `setxattr' function. */ +#undef HAVE_SETXATTR + /* Define to 1 if you have the `sinl' function. */ #undef HAVE_SINL diff --git a/libgo/configure b/libgo/configure index e54a2cd1b0c..c416dacc516 100755 --- a/libgo/configure +++ b/libgo/configure @@ -14700,7 +14700,7 @@ else fi -for ac_func in accept4 epoll_create1 faccessat fallocate fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_init1 inotify_rm_watch mkdirat mknodat openat pipe2 renameat sync_file_range splice tee unlinkat unshare utimensat +for ac_func in accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat openat pipe2 removexattr renameat setxattr sync_file_range splice tee unlinkat unshare utimensat do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/libgo/configure.ac b/libgo/configure.ac index 81c0a88b0cd..8ce846d9fbf 100644 --- a/libgo/configure.ac +++ b/libgo/configure.ac @@ -503,7 +503,7 @@ AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv dl_iterate_phdr) AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes) AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes) -AC_CHECK_FUNCS(accept4 epoll_create1 faccessat fallocate fchmodat fchownat futimesat inotify_add_watch inotify_init inotify_init1 inotify_rm_watch mkdirat mknodat openat pipe2 renameat sync_file_range splice tee unlinkat unshare utimensat) +AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat openat pipe2 removexattr renameat setxattr sync_file_range splice tee unlinkat unshare utimensat) AC_TYPE_OFF_T AC_CHECK_TYPES([loff_t]) diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go index 79de2f389e9..60eecd9ef89 100644 --- a/libgo/go/syscall/libcall_linux.go +++ b/libgo/go/syscall/libcall_linux.go @@ -190,6 +190,9 @@ func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { //sys Adjtimex(buf *Timex) (state int, err error) //adjtimex(buf *Timex) _C_int +//sysnb Dup3(oldfd int, newfd int, flags int) (err error) +//dup3(oldfd _C_int, newfd _C_int, flags _C_int) _C_int + //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) //faccessat(dirfd _C_int, pathname *byte, mode _C_int, flags _C_int) _C_int @@ -268,6 +271,9 @@ func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, return origlen - len(buf), count, names } +//sys Getxattr(path string, attr string, dest []byte) (sz int, err error) +//getxattr(path *byte, attr *byte, buf *byte, count Size_t) Ssize_t + //sys InotifyAddWatch(fd int, pathname string, mask uint32) (watchdesc int, err error) //inotify_add_watch(fd _C_int, pathname *byte, mask uint32) _C_int @@ -283,6 +289,9 @@ func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, //sys Klogctl(typ int, buf []byte) (n int, err error) //klogctl(typ _C_int, bufp *byte, len _C_int) _C_int +//sys Listxattr(path string, dest []byte) (sz int, err error) +//listxattr(path *byte, list *byte, size Size_t) Ssize_t + //sys Mkdirat(dirfd int, path string, mode uint32) (err error) //mkdirat(dirfd _C_int, path *byte, mode Mode_t) _C_int @@ -305,6 +314,9 @@ func Pipe2(p []int, flags int) (err error) { //sys PivotRoot(newroot string, putold string) (err error) //pivot_root(newroot *byte, putold *byte) _C_int +//sys Removexattr(path string, attr string) (err error) +//removexattr(path *byte, name *byte) _C_int + //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //renameat(olddirfd _C_int, oldpath *byte, newdirfd _C_int, newpath *byte) _C_int @@ -338,6 +350,9 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sysnb Setresuid(ruid int, eguid int, suid int) (err error) //setresuid(ruid Uid_t, euid Uid_t, suid Uid_t) _C_int +//sys Setxattr(path string, attr string, data []byte, flags int) (err error) +//setxattr(path *byte, name *byte, value *byte, size Size_t, flags _C_int) _C_int + //sys splice(rfd int, roff *_loff_t, wfd int, woff *_loff_t, len int, flags int) (n int64, err error) //splice(rfd _C_int, roff *_loff_t, wfd _C_int, woff *_loff_t, len Size_t, flags _C_uint) Ssize_t func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) { diff --git a/libgo/go/syscall/libcall_posix.go b/libgo/go/syscall/libcall_posix.go index 1e7823b541c..91ff59b6cfa 100644 --- a/libgo/go/syscall/libcall_posix.go +++ b/libgo/go/syscall/libcall_posix.go @@ -238,6 +238,9 @@ func FDZero(set *FdSet) { //sysnb Getppid() (ppid int) //getppid() Pid_t +//sys Getpriority(which int, who int) (prio int, err error) +//getpriority(which _C_int, who _C_int) _C_int + //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) //getrlimit(resource _C_int, rlim *Rlimit) _C_int @@ -307,6 +310,9 @@ func Gettimeofday(tv *Timeval) (err error) { //sysnb Setpgid(pid int, pgid int) (err error) //setpgid(pid Pid_t, pgid Pid_t) _C_int +//sys Setpriority(which int, who int, prio int) (err error) +//setpriority(which _C_int, who _C_int, prio _C_int) _C_int + //sysnb Setreuid(ruid int, euid int) (err error) //setreuid(ruid Uid_t, euid Uid_t) _C_int diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 11bcb257a94..71c328627a6 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -1035,6 +1035,10 @@ grep '^type _utimbuf ' gen-sysinfo.go | \ grep '^const _LOCK_' gen-sysinfo.go | sed -e 's/^\(const \)_\(LOCK_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} +# The PRIO constants. +grep '^const _PRIO_' gen-sysinfo.go | \ + sed -e 's/^\(const \)_\(PRIO_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} + # The GNU/Linux LINUX_REBOOT flags. grep '^const _LINUX_REBOOT_' gen-sysinfo.go | sed -e 's/^\(const \)_\(LINUX_REBOOT_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} diff --git a/libgo/runtime/go-nosys.c b/libgo/runtime/go-nosys.c index 3ab5ea235f2..f389dbe0cbe 100644 --- a/libgo/runtime/go-nosys.c +++ b/libgo/runtime/go-nosys.c @@ -43,6 +43,17 @@ accept4 (int sockfd __attribute__ ((unused)), } #endif +#ifndef HAVE_DUP3 +int +dup3 (int oldfd __attribute__ ((unused)), + int newfd __attribute__ ((unused)), + int flags __attribtue__ ((unused))) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_EPOLL_CREATE1 int epoll_create1 (int flags __attribute__ ((unused))) @@ -112,6 +123,18 @@ futimesat (int dirfd __attribute__ ((unused)), } #endif +#ifndef HAVE_GETXATTR +ssize_t +getxattr (const char *path __attribute__ ((unused)), + const char *name __attribute__ ((unused)), + void *value __attribute__ ((unused)), + size_t size __attribute__ ((unused))) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_INOTIFY_ADD_WATCH int inotify_add_watch (int fd __attribute__ ((unused)), @@ -151,6 +174,17 @@ inotify_rm_watch (int fd __attribute__ ((unused)), } #endif +#ifndef HAVE_LISTXATTR +ssize_t +listxattr (const char *path __attribute__ ((unused)), + char *list __attribute__ ((unused)), + size_t size __attribute__ ((unused))) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_MKDIRAT int mkdirat (int dirfd __attribute__ ((unused)), @@ -196,6 +230,16 @@ pipe2 (int pipefd[2] __attribute__ ((unused)), } #endif +#ifndef HAVE_REMOVEXATTR +int +removexattr (const char *path __attribute__ ((unused)), + const char *name __attribute__ ((unused))) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_RENAMEAT int renameat (int olddirfd __attribute__ ((unused)), @@ -208,6 +252,19 @@ renameat (int olddirfd __attribute__ ((unused)), } #endif +#ifndef HAVE_SETXATTR +int +setxattr (const char *path __attribute__ ((unused)), + const char *name __attribute__ ((unused)), + const void *value __attribute__ ((unused)), + size_t size __attribute__ ((unused)), + int flags __attribute__ ((unused))) +{ + errno = ENOSYS; + return -1; +} +#endif + #ifndef HAVE_SPLICE int splice (int fd __attribute__ ((unused)), -- cgit v1.2.3 From 81235ad94d0c7f8412cf96efafafdd9b2e170b6f Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 17 Oct 2013 20:08:21 +0000 Subject: compiler: Rework handling of imported anonymous builtin types again. From-SVN: r203794 --- gcc/go/gofrontend/types.cc | 74 ++++++++++++++++++++++++---------------------- gcc/go/gofrontend/types.h | 13 +++++++- 2 files changed, 50 insertions(+), 37 deletions(-) diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc index c13bfea438d..59247d6fb05 100644 --- a/gcc/go/gofrontend/types.cc +++ b/gcc/go/gofrontend/types.cc @@ -4209,7 +4209,8 @@ Struct_field::is_field_name(const std::string& name) const // This is a horrible hack caused by the fact that we don't pack // the names of builtin types. FIXME. - if (nt != NULL + if (!this->is_imported_ + && nt != NULL && nt->is_builtin() && nt->name() == Gogo::unpack_hidden_name(name)) return true; @@ -4218,6 +4219,36 @@ Struct_field::is_field_name(const std::string& name) const } } +// Return whether this field is an unexported field named NAME. + +bool +Struct_field::is_unexported_field_name(Gogo* gogo, + const std::string& name) const +{ + const std::string& field_name(this->field_name()); + if (Gogo::is_hidden_name(field_name) + && name == Gogo::unpack_hidden_name(field_name) + && gogo->pack_hidden_name(name, false) != field_name) + return true; + + // Check for the name of a builtin type. This is like the test in + // is_field_name, only there we return false if this->is_imported_, + // and here we return true. + if (this->is_imported_ && this->is_anonymous()) + { + Type* t = this->typed_identifier_.type(); + if (t->points_to() != NULL) + t = t->points_to(); + Named_type* nt = t->named_type(); + if (nt != NULL + && nt->is_builtin() + && nt->name() == Gogo::unpack_hidden_name(name)) + return true; + } + + return false; +} + // Return whether this field is an embedded built-in type. bool @@ -4650,13 +4681,8 @@ Struct_type::is_unexported_local_field(Gogo* gogo, for (Struct_field_list::const_iterator pf = fields->begin(); pf != fields->end(); ++pf) - { - const std::string& field_name(pf->field_name()); - if (Gogo::is_hidden_name(field_name) - && name == Gogo::unpack_hidden_name(field_name) - && gogo->pack_hidden_name(name, false) != field_name) - return true; - } + if (pf->is_unexported_field_name(gogo, name)) + return true; } return false; } @@ -5258,34 +5284,8 @@ Struct_type::do_import(Import* imp) } Type* ftype = imp->read_type(); - // We don't pack the names of builtin types. In - // Struct_field::is_field_name we cope with a hack. Now we - // need another hack so that we don't accidentally think - // that an embedded builtin type is accessible from another - // package (we know that all the builtin types are not - // exported). - // This is called during parsing, before anything is - // lowered, so we have to be careful to avoid dereferencing - // an unknown type name. - if (name.empty()) - { - Type *t = ftype; - if (t->classification() == Type::TYPE_POINTER) - { - // Very ugly. - Pointer_type* ptype = static_cast(t); - t = ptype->points_to(); - } - std::string tname; - if (t->forward_declaration_type() != NULL) - tname = t->forward_declaration_type()->name(); - else if (t->named_type() != NULL) - tname = t->named_type()->name(); - if (!tname.empty() && tname[0] >= 'a' && tname[0] <= 'z') - name = '.' + imp->package()->pkgpath() + '.' + tname; - } - Struct_field sf(Typed_identifier(name, ftype, imp->location())); + sf.set_is_imported(); if (imp->peek_char() == ' ') { @@ -9327,7 +9327,9 @@ Type::bind_field_or_method(Gogo* gogo, const Type* type, Expression* expr, else { bool is_unexported; - if (!Gogo::is_hidden_name(name)) + // The test for 'a' and 'z' is to handle builtin names, + // which are not hidden. + if (!Gogo::is_hidden_name(name) && (name[0] < 'a' || name[0] > 'z')) is_unexported = false; else { diff --git a/gcc/go/gofrontend/types.h b/gcc/go/gofrontend/types.h index 928c593a919..ed01d9cdc38 100644 --- a/gcc/go/gofrontend/types.h +++ b/gcc/go/gofrontend/types.h @@ -1924,7 +1924,7 @@ class Struct_field { public: explicit Struct_field(const Typed_identifier& typed_identifier) - : typed_identifier_(typed_identifier), tag_(NULL) + : typed_identifier_(typed_identifier), tag_(NULL), is_imported_(false) { } // The field name. @@ -1935,6 +1935,10 @@ class Struct_field bool is_field_name(const std::string& name) const; + // Return whether this struct field is an unexported field named NAME. + bool + is_unexported_field_name(Gogo*, const std::string& name) const; + // Return whether this struct field is an embedded built-in type. bool is_embedded_builtin(Gogo*) const; @@ -1972,6 +1976,11 @@ class Struct_field set_tag(const std::string& tag) { this->tag_ = new std::string(tag); } + // Record that this field is defined in an imported struct. + void + set_is_imported() + { this->is_imported_ = true; } + // Set the type. This is only used in error cases. void set_type(Type* type) @@ -1982,6 +1991,8 @@ class Struct_field Typed_identifier typed_identifier_; // The field tag. This is NULL if the field has no tag. std::string* tag_; + // Whether this field is defined in an imported struct. + bool is_imported_; }; // A list of struct fields. -- cgit v1.2.3