Skip to content

Commit e88f537

Browse files
committed
remove redundant check
1 parent 3cc63e9 commit e88f537

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

clang/lib/Lex/LiteralSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
989989
break;
990990
HasSize = true;
991991

992-
if ((Target.hasBFloat16Type()) && s + 3 < ThisTokEnd &&
992+
if (s + 3 < ThisTokEnd &&
993993
((s[0] == 'b' && s[1] == 'f') || (s[0] == 'B' && s[1] == 'F')) &&
994994
s[2] == '1' && s[3] == '6') {
995995
s += 3; // success, eat up 3 characters.

clang/test/Lexer/bfloat-literal.cpp

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
1+
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -triple x86_64 -DSUPPORTED %s
2+
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -triple armv7 %s
3+
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -triple armv7 -target-feature +bf16 -DSUPPORTED %s
4+
5+
#ifdef SUPPORTED
6+
27
__bf16 a = 1.b; // expected-error{{invalid suffix 'b' on floating constant}}
38
__bf16 b = 1.bf; // expected-error{{invalid suffix 'bf' on floating constant}}
49
__bf16 c = 1.bf166; // expected-error{{invalid suffix 'bf166' on floating constant}}
@@ -28,3 +33,39 @@ __bf16 t = 1BF16; // expected-error{{invalid digit 'B' in decimal constant}}
2833
__bf16 u = 1.bf16F16; // expected-error{{invalid suffix 'bf16F16' on floating constant}}
2934
__bf16 v = 1.BF16f16; // expected-error{{invalid suffix 'BF16f16' on floating constant}}
3035
__bf16 w = 1.F16bf16; // expected-error{{invalid suffix 'F16bf16' on floating constant}}
36+
37+
#endif
38+
39+
#ifndef SUPPORTED
40+
41+
__bf16 a = 1.b; // expected-error{{__bf16 is not supported on this target}}
42+
__bf16 b = 1.bf; // expected-error{{__bf16 is not supported on this target}}
43+
__bf16 c = 1.bf166; // expected-error{{__bf16 is not supported on this target}}
44+
__bf16 d = 1.bf1; // expected-error{{__bf16 is not supported on this target}}
45+
46+
__bf16 e = 1.B; // expected-error{{__bf16 is not supported on this target}}
47+
__bf16 f = 1.BF; // expected-error{{__bf16 is not supported on this target}}
48+
__bf16 g = 1.BF166; // expected-error{{__bf16 is not supported on this target}}
49+
__bf16 h = 1.BF1; // expected-error{{__bf16 is not supported on this target}}
50+
51+
__bf16 i = 1.bf16; // expect-success
52+
__bf16 j = 1.BF16; // expect-success
53+
54+
__bf16 k = 1B; // expected-error{{invalid digit 'B' in decimal constant}}
55+
__bf16 l = 1BF; // expected-error{{invalid digit 'B' in decimal constant}}
56+
__bf16 m = 1BF166; // expected-error{{invalid digit 'B' in decimal constant}}
57+
__bf16 n = 1BF1; // expected-error{{invalid digit 'B' in decimal constant}}
58+
59+
__bf16 o = 1b; // expected-error{{invalid digit 'b' in decimal constant}}
60+
__bf16 p = 1bf; // expected-error{{invalid digit 'b' in decimal constant}}
61+
__bf16 q = 1bf166; // expected-error{{invalid digit 'b' in decimal constant}}
62+
__bf16 r = 1bf1; // expected-error{{invalid digit 'b' in decimal constant}}
63+
64+
__bf16 s = 1bf16; // expected-error{{invalid digit 'b' in decimal constant}}
65+
__bf16 t = 1BF16; // expected-error{{invalid digit 'B' in decimal constant}}
66+
67+
__bf16 u = 1.bf16F16; // expected-error{{invalid suffix 'bf16F16' on floating constant}}
68+
__bf16 v = 1.BF16f16; // expected-error{{invalid suffix 'BF16f16' on floating constant}}
69+
__bf16 w = 1.F16bf16; // expected-error{{invalid suffix 'F16bf16' on floating constant}}
70+
71+
#endif

0 commit comments

Comments
 (0)