File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2621,6 +2621,18 @@ bool Converter::VisitInitListExpr(clang::InitListExpr *expr) {
26212621 return false ;
26222622}
26232623
2624+ bool Converter::VisitCompoundLiteralExpr (clang::CompoundLiteralExpr *expr) {
2625+ auto record = expr->getType ()->getAsRecordDecl ();
2626+ if (!record || !record->hasAttr <clang::TransparentUnionAttr>()) {
2627+ return true ;
2628+ }
2629+ auto init = clang::cast<clang::InitListExpr>(expr->getInitializer ());
2630+ assert (init->getNumInits () == 1 );
2631+ PushExprKind push (*this , ExprKind::RValue);
2632+ Convert (init->getInit (0 ));
2633+ return false ;
2634+ }
2635+
26242636bool Converter::VisitArraySubscriptExpr (clang::ArraySubscriptExpr *expr) {
26252637 auto *base = expr->getBase ();
26262638 if (base->IgnoreCasts ()->getType ()->isPointerType ()) {
Original file line number Diff line number Diff line change @@ -283,6 +283,8 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
283283
284284 virtual bool VisitInitListExpr (clang::InitListExpr *expr);
285285
286+ virtual bool VisitCompoundLiteralExpr (clang::CompoundLiteralExpr *expr);
287+
286288 virtual bool VisitArraySubscriptExpr (clang::ArraySubscriptExpr *expr);
287289
288290 virtual bool VisitCXXNullPtrLiteralExpr (clang::CXXNullPtrLiteralExpr *expr);
Original file line number Diff line number Diff line change 1+ #define _GNU_SOURCE
12#include <sys/types.h>
23#include <sys/socket.h>
34
Original file line number Diff line number Diff line change 1+ extern crate libc;
2+ use libc:: * ;
3+ extern crate libcc2rs;
4+ use libcc2rs:: * ;
5+ use std:: collections:: BTreeMap ;
6+ use std:: io:: { Read , Seek , Write } ;
7+ use std:: os:: fd:: { AsFd , FromRawFd , IntoRawFd } ;
8+ use std:: rc:: Rc ;
9+ pub fn main ( ) {
10+ unsafe {
11+ std:: process:: exit ( main_0 ( ) as i32 ) ;
12+ }
13+ }
14+ unsafe fn main_0 ( ) -> i32 {
15+ let mut fd: i32 = 0 ;
16+ let mut ssloc: sockaddr_storage = std:: mem:: zeroed :: < sockaddr_storage > ( ) ;
17+ let mut slen: u32 = ( :: std:: mem:: size_of :: < sockaddr_storage > ( ) as u64 as u32 ) ;
18+ assert ! (
19+ ( ( ( ( libc:: getsockname(
20+ fd,
21+ ( ( & mut ssloc as * mut sockaddr_storage) as * mut sockaddr) ,
22+ ( & mut slen as * mut u32 )
23+ ) ) == ( -1_i32 ) ) as i32 )
24+ != 0 )
25+ ) ;
26+ assert ! ( ( ( ( ( * libcc2rs:: cpp2rust_errno( ) ) == ( 88 ) ) as i32 ) != 0 ) ) ;
27+ return 0 ;
28+ }
Original file line number Diff line number Diff line change 1+ // no-compile: refcount
2+ #define _GNU_SOURCE
3+ #include <assert.h>
4+ #include <errno.h>
5+ #include <sys/socket.h>
6+ #include <sys/types.h>
7+
8+ int main (void ) {
9+ int fd = 0 ;
10+ struct sockaddr_storage ssloc ;
11+ socklen_t slen = sizeof (ssloc );
12+ assert (getsockname (fd , (struct sockaddr * )& ssloc , & slen ) == -1 );
13+ assert (errno == ENOTSOCK );
14+ return 0 ;
15+ }
You can’t perform that action at this time.
0 commit comments