head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.4
	netbsd-11-0-RC3:1.1.1.4
	netbsd-11-0-RC2:1.1.1.4
	netbsd-11-0-RC1:1.1.1.4
	perseant-exfatfs-base-20250801:1.1.1.4
	netbsd-11:1.1.1.4.0.10
	netbsd-11-base:1.1.1.4
	netbsd-10-1-RELEASE:1.1.1.4
	perseant-exfatfs-base-20240630:1.1.1.4
	perseant-exfatfs:1.1.1.4.0.8
	perseant-exfatfs-base:1.1.1.4
	netbsd-8-3-RELEASE:1.1.1.2
	netbsd-9-4-RELEASE:1.1.1.3
	netbsd-10-0-RELEASE:1.1.1.4
	netbsd-10-0-RC6:1.1.1.4
	netbsd-10-0-RC5:1.1.1.4
	netbsd-10-0-RC4:1.1.1.4
	netbsd-10-0-RC3:1.1.1.4
	netbsd-10-0-RC2:1.1.1.4
	netbsd-10-0-RC1:1.1.1.4
	netbsd-10:1.1.1.4.0.6
	netbsd-10-base:1.1.1.4
	netbsd-9-3-RELEASE:1.1.1.3
	cjep_sun2x:1.1.1.4.0.4
	cjep_sun2x-base:1.1.1.4
	cjep_staticlib_x-base1:1.1.1.4
	netbsd-9-2-RELEASE:1.1.1.3
	cjep_staticlib_x:1.1.1.4.0.2
	cjep_staticlib_x-base:1.1.1.4
	netbsd-9-1-RELEASE:1.1.1.3
	phil-wifi-20200421:1.1.1.4
	phil-wifi-20200411:1.1.1.4
	phil-wifi-20200406:1.1.1.4
	netbsd-8-2-RELEASE:1.1.1.2
	netbsd-9-0-RELEASE:1.1.1.3
	netbsd-9-0-RC2:1.1.1.3
	netbsd-9-0-RC1:1.1.1.3
	netbsd-9:1.1.1.3.0.2
	netbsd-9-base:1.1.1.3
	phil-wifi-20190609:1.1.1.3
	netbsd-8-1-RELEASE:1.1.1.2
	netbsd-8-1-RC1:1.1.1.2
	pgoyette-compat-merge-20190127:1.1.1.2.12.1
	pgoyette-compat-20190127:1.1.1.3
	pgoyette-compat-20190118:1.1.1.3
	pgoyette-compat-1226:1.1.1.3
	pgoyette-compat-1126:1.1.1.3
	pgoyette-compat-1020:1.1.1.3
	pgoyette-compat-0930:1.1.1.3
	pgoyette-compat-0906:1.1.1.3
	pgoyette-compat-0728:1.1.1.3
	clang-337282:1.1.1.3
	netbsd-8-0-RELEASE:1.1.1.2
	phil-wifi:1.1.1.2.0.14
	phil-wifi-base:1.1.1.2
	pgoyette-compat-0625:1.1.1.2
	netbsd-8-0-RC2:1.1.1.2
	pgoyette-compat-0521:1.1.1.2
	pgoyette-compat-0502:1.1.1.2
	pgoyette-compat-0422:1.1.1.2
	netbsd-8-0-RC1:1.1.1.2
	pgoyette-compat-0415:1.1.1.2
	pgoyette-compat-0407:1.1.1.2
	pgoyette-compat-0330:1.1.1.2
	pgoyette-compat-0322:1.1.1.2
	pgoyette-compat-0315:1.1.1.2
	pgoyette-compat:1.1.1.2.0.12
	pgoyette-compat-base:1.1.1.2
	clang-319952:1.1.1.2
	matt-nb8-mediatek:1.1.1.2.0.10
	matt-nb8-mediatek-base:1.1.1.2
	clang-309604:1.1.1.2
	perseant-stdc-iso10646:1.1.1.2.0.8
	perseant-stdc-iso10646-base:1.1.1.2
	netbsd-8:1.1.1.2.0.6
	netbsd-8-base:1.1.1.2
	prg-localcount2-base3:1.1.1.2
	prg-localcount2-base2:1.1.1.2
	prg-localcount2-base1:1.1.1.2
	prg-localcount2:1.1.1.2.0.4
	prg-localcount2-base:1.1.1.2
	pgoyette-localcount-20170426:1.1.1.2
	bouyer-socketcan-base1:1.1.1.2
	pgoyette-localcount-20170320:1.1.1.2
	clang-294123:1.1.1.2
	bouyer-socketcan:1.1.1.2.0.2
	bouyer-socketcan-base:1.1.1.2
	clang-291444:1.1.1.2
	pgoyette-localcount-20170107:1.1.1.1
	pgoyette-localcount-20161104:1.1.1.1
	localcount-20160914:1.1.1.1
	clang-280599:1.1.1.1
	pgoyette-localcount-20160806:1.1.1.1
	pgoyette-localcount-20160726:1.1.1.1
	pgoyette-localcount:1.1.1.1.0.2
	pgoyette-localcount-base:1.1.1.1
	clang-261930:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@// @;


1.1
date	2016.02.27.22.10.14;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	tIimz3oDlh1NpBWy;

1.1.1.1
date	2016.02.27.22.10.14;	author joerg;	state Exp;
branches
	1.1.1.1.2.1;
next	1.1.1.2;
commitid	tIimz3oDlh1NpBWy;

1.1.1.2
date	2017.01.11.10.37.43;	author joerg;	state Exp;
branches
	1.1.1.2.12.1
	1.1.1.2.14.1;
next	1.1.1.3;
commitid	CNnUNfII1jgNmxBz;

1.1.1.3
date	2018.07.17.18.31.35;	author joerg;	state Exp;
branches;
next	1.1.1.4;
commitid	wDzL46ALjrCZgwKA;

1.1.1.4
date	2019.11.13.22.22.55;	author joerg;	state dead;
branches;
next	;
commitid	QD8YATxuNG34YJKB;

1.1.1.1.2.1
date	2017.03.20.06.53.33;	author pgoyette;	state Exp;
branches;
next	;
commitid	jjw7cAwgyKq7RfKz;

1.1.1.2.12.1
date	2018.07.28.04.34.12;	author pgoyette;	state Exp;
branches;
next	;
commitid	1UP1xAIUxv1ZgRLA;

1.1.1.2.14.1
date	2019.06.10.21.46.35;	author christos;	state Exp;
branches;
next	1.1.1.2.14.2;
commitid	jtc8rnCzWiEEHGqB;

1.1.1.2.14.2
date	2020.04.13.07.50.22;	author martin;	state dead;
branches;
next	;
commitid	X01YhRUPVUDaec4C;


desc
@@


1.1
log
@Initial revision
@
text
@// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++98
typedef unsigned long long uint64_t;
typedef unsigned long long uint32_t;

uint64_t f0(uint64_t);
uint64_t f1(uint64_t, uint32_t);
uint64_t f2(uint64_t, ...);

static const uint64_t overflow = 1 * 4608 * 1024 * 1024; // expected-warning {{overflow in expression; result is 536870912 with type 'int'}}

uint64_t check_integer_overflows(int i) { //expected-note {{declared here}}
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  uint64_t overflow = 4608 * 1024 * 1024,
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
           overflow2 = (uint64_t)(4608 * 1024 * 1024),
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
           overflow3 = (uint64_t)(4608 * 1024 * 1024 * i),
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
           overflow4 =  (1ULL * ((4608) * ((1024) * (1024))) + 2ULL),
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
           overflow5 = static_cast<uint64_t>(4608 * 1024 * 1024),
// expected-warning@@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
           multi_overflow = (uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  overflow += overflow2 = overflow3 = (uint64_t)(4608 * 1024 * 1024);
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  overflow += overflow2 = overflow3 = 4608 * 1024 * 1024;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  overflow += overflow2 = overflow3 = static_cast<uint64_t>(4608 * 1024 * 1024);

  uint64_t not_overflow = 4608 * 1024 * 1024ULL;
  uint64_t not_overflow2 = (1ULL * ((uint64_t)(4608) * (1024 * 1024)) + 2ULL);

// expected-warning@@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
  overflow = 4608 * 1024 * 1024 ?  4608 * 1024 * 1024 : 0;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  overflow =  0 ? 0 : 4608 * 1024 * 1024;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  if (4608 * 1024 * 1024)
    return 0;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  if ((uint64_t)(4608 * 1024 * 1024))
    return 1;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  if (static_cast<uint64_t>(4608 * 1024 * 1024))
    return 1;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  if ((uint64_t)(4608 * 1024 * 1024))
    return 2;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  if ((uint64_t)(4608 * 1024 * 1024 * i))
    return 3;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  if ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL))
    return 4;

// expected-warning@@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
  if ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)))
    return 5;

  switch (i) {
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  case 4608 * 1024 * 1024:
    return 6;
// expected-warning@@+1 {{overflow in expression; result is 537919488 with type 'int'}}
  case (uint64_t)(4609 * 1024 * 1024):
    return 7;
// expected-warning@@+1 {{overflow in expression; result is 537919488 with type 'int'}}
  case 1 + static_cast<uint64_t>(4609 * 1024 * 1024):
    return 7;
// expected-error@@+2 {{expression is not an integral constant expression}}
// expected-note@@+1 {{read of non-const variable 'i' is not allowed in a constant expression}}
  case ((uint64_t)(4608 * 1024 * 1024 * i)):
    return 8;
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  case ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL)):
    return 9;
// expected-warning@@+2 2{{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@@+1 {{overflow converting case value to switch condition type (288230376151711744 to 0)}}
  case ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024))):
    return 10;
  }

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  while (4608 * 1024 * 1024);

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  while ((uint64_t)(4608 * 1024 * 1024));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  while (static_cast<uint64_t>(4608 * 1024 * 1024));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  while ((uint64_t)(4608 * 1024 * 1024));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  while ((uint64_t)(4608 * 1024 * 1024 * i));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  while ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL));

// expected-warning@@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
  while ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  do { } while (4608 * 1024 * 1024);

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  do { } while ((uint64_t)(4608 * 1024 * 1024));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  do { } while (static_cast<uint64_t>(4608 * 1024 * 1024));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  do { } while ((uint64_t)(4608 * 1024 * 1024));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  do { } while ((uint64_t)(4608 * 1024 * 1024 * i));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  do { } while ((1ULL * ((4608) * ((1024) * (1024))) + 2ULL));

// expected-warning@@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
  do { } while ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));

// expected-warning@@+3 {{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@@+3 {{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@@+3 {{overflow in expression; result is 536870912 with type 'int'}}
  for (uint64_t i = 4608 * 1024 * 1024;
       (uint64_t)(4608 * 1024 * 1024);
       i += (uint64_t)(4608 * 1024 * 1024 * i));

// expected-warning@@+3 {{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@@+3 2{{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@@+3 2{{overflow in expression; result is 536870912 with type 'int'}}
  for (uint64_t i = (1ULL * ((4608) * ((1024) * (1024))) + 2ULL);
       ((uint64_t)((uint64_t)(4608 * 1024 * 1024) * (uint64_t)(4608 * 1024 * 1024)));
       i = ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024))));

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  _Complex long long x = 4608 * 1024 * 1024;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  (__real__ x) = 4608 * 1024 * 1024;

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  (__imag__ x) = 4608 * 1024 * 1024;

// expected-warning@@+4 {{overflow in expression; result is 536870912 with type 'int'}}
// expected-warning@@+3 {{array index 536870912 is past the end of the array (which contains 10 elements)}}
// expected-note@@+1 {{array 'a' declared here}}
  uint64_t a[10];
  a[4608 * 1024 * 1024] = 1i;

// expected-warning@@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
  return ((4608 * 1024 * 1024) + ((uint64_t)(4608 * 1024 * 1024)));
}
@


1.1.1.1
log
@Import Clang 3.8.0rc3 r261930.
@
text
@@


1.1.1.1.2.1
log
@Sync with HEAD
@
text
@d1 1
a1 1
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++98 -triple x86_64-pc-linux-gnu
d3 1
a3 6
typedef unsigned int uint32_t;

// Check integer sizes.
int array64[sizeof(uint64_t) == 8 ? 1 : -1];
int array32[sizeof(uint32_t) == 4 ? 1 : -1];
int arrayint[sizeof(int) < sizeof(uint64_t) ? 1 : -1];
@


1.1.1.2
log
@Import Clang pre-4.0.0 r291444.
@
text
@d1 1
a1 1
// RUN: %clang_cc1 %s -verify -fsyntax-only -std=gnu++98 -triple x86_64-pc-linux-gnu
d3 1
a3 6
typedef unsigned int uint32_t;

// Check integer sizes.
int array64[sizeof(uint64_t) == 8 ? 1 : -1];
int array32[sizeof(uint32_t) == 4 ? 1 : -1];
int arrayint[sizeof(int) < sizeof(uint64_t) ? 1 : -1];
@


1.1.1.2.14.1
log
@Sync with HEAD
@
text
@d167 1
a167 1
  a[4608 * 1024 * 1024] = 1;
a171 15

void check_integer_overflows_in_function_calls() {
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  (void)f0(4608 * 1024 * 1024);

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  uint64_t x = f0(4608 * 1024 * 1024);

// expected-warning@@+2 {{overflow in expression; result is 536870912 with type 'int'}}
  uint64_t (*f0_ptr)(uint64_t) = &f0;
  (void)(*f0_ptr)(4608 * 1024 * 1024);

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  (void)f2(0, f0(4608 * 1024 * 1024));
}
@


1.1.1.2.14.2
log
@Mostly merge changes from HEAD upto 20200411
@
text
@@


1.1.1.2.12.1
log
@Sync with HEAD
@
text
@d167 1
a167 1
  a[4608 * 1024 * 1024] = 1;
a171 15

void check_integer_overflows_in_function_calls() {
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  (void)f0(4608 * 1024 * 1024);

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  uint64_t x = f0(4608 * 1024 * 1024);

// expected-warning@@+2 {{overflow in expression; result is 536870912 with type 'int'}}
  uint64_t (*f0_ptr)(uint64_t) = &f0;
  (void)(*f0_ptr)(4608 * 1024 * 1024);

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  (void)f2(0, f0(4608 * 1024 * 1024));
}
@


1.1.1.3
log
@Import clang r337282 from trunk
@
text
@d167 1
a167 1
  a[4608 * 1024 * 1024] = 1;
a171 15

void check_integer_overflows_in_function_calls() {
// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  (void)f0(4608 * 1024 * 1024);

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  uint64_t x = f0(4608 * 1024 * 1024);

// expected-warning@@+2 {{overflow in expression; result is 536870912 with type 'int'}}
  uint64_t (*f0_ptr)(uint64_t) = &f0;
  (void)(*f0_ptr)(4608 * 1024 * 1024);

// expected-warning@@+1 {{overflow in expression; result is 536870912 with type 'int'}}
  (void)f2(0, f0(4608 * 1024 * 1024));
}
@


1.1.1.4
log
@Mark old LLVM instance as dead.
@
text
@@


