1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -pedantic %s 2f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: ABC' 3f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF' 4f4a2713aSLionel Sambuc 5f4a2713aSLionel Sambuc #line 'a' // expected-error {{#line directive requires a positive integer argument}} 6f4a2713aSLionel Sambuc #line 0 // expected-warning {{#line directive with zero argument is a GNU extension}} 7f4a2713aSLionel Sambuc #line 00 // expected-warning {{#line directive with zero argument is a GNU extension}} 8f4a2713aSLionel Sambuc #line 2147483648 // expected-warning {{C requires #line number to be less than 2147483648, allowed as extension}} 9f4a2713aSLionel Sambuc #line 42 // ok 10f4a2713aSLionel Sambuc #line 42 'a' // expected-error {{invalid filename for #line directive}} 11f4a2713aSLionel Sambuc #line 42 "foo/bar/baz.h" // ok 12f4a2713aSLionel Sambuc 13f4a2713aSLionel Sambuc 14f4a2713aSLionel Sambuc // #line directives expand macros. 15f4a2713aSLionel Sambuc #define A 42 "foo" 16f4a2713aSLionel Sambuc #line A 17f4a2713aSLionel Sambuc 18f4a2713aSLionel Sambuc # 42 19f4a2713aSLionel Sambuc # 42 "foo" 20f4a2713aSLionel Sambuc # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}} 21f4a2713aSLionel Sambuc # 42 "foo" 1 3 // enter 22f4a2713aSLionel Sambuc # 42 "foo" 2 3 // exit 23f4a2713aSLionel Sambuc # 42 "foo" 2 3 4 // expected-error {{invalid line marker flag '2': cannot pop empty include stack}} 24f4a2713aSLionel Sambuc # 42 "foo" 3 4 25f4a2713aSLionel Sambuc 26f4a2713aSLionel Sambuc # 'a' // expected-error {{invalid preprocessing directive}} 27f4a2713aSLionel Sambuc # 42 'f' // expected-error {{invalid filename for line marker directive}} 28f4a2713aSLionel Sambuc # 42 1 3 // expected-error {{invalid filename for line marker directive}} 29f4a2713aSLionel Sambuc # 42 "foo" 3 1 // expected-error {{invalid flag line marker directive}} 30f4a2713aSLionel Sambuc # 42 "foo" 42 // expected-error {{invalid flag line marker directive}} 31f4a2713aSLionel Sambuc # 42 "foo" 1 2 // expected-error {{invalid flag line marker directive}} 32f4a2713aSLionel Sambuc # 42a33 // expected-error {{GNU line marker directive requires a simple digit sequence}} 33f4a2713aSLionel Sambuc 34f4a2713aSLionel Sambuc // These are checked by the RUN line. 35f4a2713aSLionel Sambuc #line 92 "blonk.c" 36f4a2713aSLionel Sambuc #error ABC 37f4a2713aSLionel Sambuc #error DEF 38f4a2713aSLionel Sambuc // expected-error@-2 {{ABC}} 39f4a2713aSLionel Sambuc #line 150 40f4a2713aSLionel Sambuc // expected-error@-3 {{DEF}} 41f4a2713aSLionel Sambuc 42f4a2713aSLionel Sambuc 43f4a2713aSLionel Sambuc // Verify that linemarker diddling of the system header flag works. 44f4a2713aSLionel Sambuc 45f4a2713aSLionel Sambuc # 192 "glomp.h" // not a system header. 46f4a2713aSLionel Sambuc typedef int x; // expected-note {{previous definition is here}} 47f4a2713aSLionel Sambuc typedef int x; // expected-warning {{redefinition of typedef 'x' is a C11 feature}} 48f4a2713aSLionel Sambuc 49f4a2713aSLionel Sambuc # 192 "glomp.h" 3 // System header. 50f4a2713aSLionel Sambuc typedef int y; // ok 51f4a2713aSLionel Sambuc typedef int y; // ok 52f4a2713aSLionel Sambuc 53f4a2713aSLionel Sambuc typedef int q; // q is in system header. 54f4a2713aSLionel Sambuc 55f4a2713aSLionel Sambuc #line 42 "blonk.h" // doesn't change system headerness. 56f4a2713aSLionel Sambuc 57f4a2713aSLionel Sambuc typedef int z; // ok 58f4a2713aSLionel Sambuc typedef int z; // ok 59f4a2713aSLionel Sambuc 60f4a2713aSLionel Sambuc # 97 // doesn't change system headerness. 61f4a2713aSLionel Sambuc 62f4a2713aSLionel Sambuc typedef int z1; // ok 63f4a2713aSLionel Sambuc typedef int z1; // ok 64f4a2713aSLionel Sambuc 65f4a2713aSLionel Sambuc # 42 "blonk.h" // DOES change system headerness. 66f4a2713aSLionel Sambuc 67f4a2713aSLionel Sambuc typedef int w; // expected-note {{previous definition is here}} 68f4a2713aSLionel Sambuc typedef int w; // expected-warning {{redefinition of typedef 'w' is a C11 feature}} 69f4a2713aSLionel Sambuc 70f4a2713aSLionel Sambuc typedef int q; // original definition in system header, should not diagnose. 71f4a2713aSLionel Sambuc 72f4a2713aSLionel Sambuc // This should not produce an "extra tokens at end of #line directive" warning, 73f4a2713aSLionel Sambuc // because #line is allowed to contain expanded tokens. 74f4a2713aSLionel Sambuc #define EMPTY() 75f4a2713aSLionel Sambuc #line 2 "foo.c" EMPTY( ) 76f4a2713aSLionel Sambuc #line 2 "foo.c" NONEMPTY( ) // expected-warning{{extra tokens at end of #line directive}} 77f4a2713aSLionel Sambuc 78f4a2713aSLionel Sambuc // PR3940 79f4a2713aSLionel Sambuc #line 0xf // expected-error {{#line directive requires a simple digit sequence}} 80f4a2713aSLionel Sambuc #line 42U // expected-error {{#line directive requires a simple digit sequence}} 81f4a2713aSLionel Sambuc 82f4a2713aSLionel Sambuc 83f4a2713aSLionel Sambuc // Line markers are digit strings interpreted as decimal numbers, this is 84f4a2713aSLionel Sambuc // 10, not 8. 85f4a2713aSLionel Sambuc #line 010 // expected-warning {{#line directive interprets number as decimal, not octal}} 86f4a2713aSLionel Sambuc extern int array[__LINE__ == 10 ? 1:-1]; 87f4a2713aSLionel Sambuc 88f4a2713aSLionel Sambuc # 020 // expected-warning {{GNU line marker directive interprets number as decimal, not octal}} 89f4a2713aSLionel Sambuc extern int array_gnuline[__LINE__ == 20 ? 1:-1]; 90f4a2713aSLionel Sambuc 91f4a2713aSLionel Sambuc /* PR3917 */ 92f4a2713aSLionel Sambuc #line 41 93f4a2713aSLionel Sambuc extern char array2[\ 94f4a2713aSLionel Sambuc _\ 95f4a2713aSLionel Sambuc _LINE__ == 42 ? 1: -1]; /* line marker is location of first _ */ 96f4a2713aSLionel Sambuc 97f4a2713aSLionel Sambuc # 51 98f4a2713aSLionel Sambuc extern char array2_gnuline[\ 99f4a2713aSLionel Sambuc _\ 100f4a2713aSLionel Sambuc _LINE__ == 52 ? 1: -1]; /* line marker is location of first _ */ 101f4a2713aSLionel Sambuc 102f4a2713aSLionel Sambuc // rdar://11550996 103f4a2713aSLionel Sambuc #line 0 "line-directive.c" // expected-warning {{#line directive with zero argument is a GNU extension}} 104f4a2713aSLionel Sambuc undefined t; // expected-error {{unknown type name 'undefined'}} 105f4a2713aSLionel Sambuc 106f4a2713aSLionel Sambuc 107