Issue 144052
Summary switch statements expanded from macro are missing source locations
Labels clang:frontend, clang:diagnostics
Assignees
Reporter tbaederr
    See https://godbolt.org/z/rjzdsKqqh

```c++
#define S(a) switch(a){ default }


#define D default
#define C(x) case x

int foo(int a) {

 switch(a) {
         default
    }

    S(a);

    switch(a) {
 D
    }

    switch(a) {
        C(10)
    }

}
```


```console 
<source>:13:17: error: expected ':' after 'default'
   13 | default
      |                 ^
      |                 :
error: expected ':' after 'default'
<source>:19:11: error: expected ':' after 'default'
   19 |          D
      |           ^
      | :
<source>:23:14: error: expected ':' after 'case'
   23 |         C(10)
 |              ^
      |              colon
4 errors generated.
```
the second emitted error does not have a valid source location.

Seems like this only happens if the entire switch is expanded from a macro.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to