constants.c revision d80f786689d608e5c22d6e1045884de7aff76c40
1ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -trigraphs %s 2ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 3ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comint x = 000000080; // expected-error {{invalid digit}} 4ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 5ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comint y = 0000\ 6ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com00080; // expected-error {{invalid digit}} 7ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 8ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 9ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 10ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comfloat X = 1.17549435e-38F; 11ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comfloat Y = 08.123456; 12ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 13ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com// PR2252 14ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com#if -0x8000000000000000 // should not warn. 15ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com#endif 16ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 17ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 18ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comchar c[] = { 195af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com 'df', // expected-warning {{multi-character character constant}} 205af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com '\t', 21ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com '\\ 22ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comt', 235af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com '??!', // expected-warning {{trigraph converted to '|' character}} 245af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com 'abcd' // expected-warning {{multi-character character constant}} 25333edd91cb32d6acfd0307ba2ae8f60baed75ff4arthurhsu@google.com}; 266b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com 27ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com// PR4499 28ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comint m0 = '0'; 29ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comint m1 = '\\\''; // expected-warning {{multi-character character constant}} 30ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comint m2 = '\\\\'; // expected-warning {{multi-character character constant}} 31ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comint m3 = '\\\ 32ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com'; 33ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 34246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com 35ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com#pragma clang diagnostic ignored "-Wmultichar" 36246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com 37ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comchar d = 'df'; // no warning. 386a22b959c06e66a039c630e6ac514234114b46cbarthurhsu@google.comchar e = 'abcd'; // still warn: expected-warning {{multi-character character constant}} 396a22b959c06e66a039c630e6ac514234114b46cbarthurhsu@google.com 40ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com#pragma clang diagnostic ignored "-Wfour-char-constants" 41ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 42246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.comchar f = 'abcd'; // ignored. 43ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 44ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com// rdar://problem/6974641 45ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.comfloat t0[] = { 46b54cce09c1fc2b09e2adae43d7eb017b47b0cccfarthurhsu@google.com 1.9e20f, 47ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 1.9e-20f, 48ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 1.9e50f, // expected-warning {{too large}} 49ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com 1.9e-50f, // expected-warning {{too small}} 50246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com -1.9e20f, 51246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com -1.9e-20f, 52ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com -1.9e50f, // expected-warning {{too large}} 53ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com -1.9e-50f // expected-warning {{too small}} 54ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com}; 556b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.comdouble t1[] = { 566b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com 1.9e50, 576b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com 1.9e-50, 586b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com 1.9e500, // expected-warning {{too large}} 596b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com 1.9e-500, // expected-warning {{too small}} 606b8e073e978eed96605da6f92d6db740a39864baarthurhsu@google.com -1.9e50, 61246300f7fab1f2539c3207ce5ec28cc355465be8arthurhsu@google.com -1.9e-50, 62ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com -1.9e500, // expected-warning {{too large}} 636a22b959c06e66a039c630e6ac514234114b46cbarthurhsu@google.com -1.9e-500 // expected-warning {{too small}} 646a22b959c06e66a039c630e6ac514234114b46cbarthurhsu@google.com}; 65ed8406cf320973d04bbe348c681090b1feba3d68arthurhsu@google.com