-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Crash on invalid in Microsoft anonymous struct extension #12219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
assigned to @majnemer |
Here is a related test case which crashes with -fms-extensions. I am not sure what the treatment should be. Two possibilities:
struct anon_fault { int main() |
Forgot to add crash report: clang -fms-extensions t.c t.c:2:2: warning: anonymous structs are a Microsoft extension [-Wmicrosoft] |
I've fixed this locally. I went with the following approach:
This mirrors what we do in more common cases. We mark records invalid if they contain duplicate fields, this is essentially what InjectAnonymousStructOrUnionMembers is checking for. We also mark records invalid if they contain fields which are incomplete, this is what RequireCompleteType is checking for. |
Fixed in r218006. |
mentioned in issue llvm/llvm-bugzilla-archive#12477 |
Extended Description
The following invalid program crashes clang:
jason$ cat test.c
typedef struct { UNKNOWN c; } A;
typedef struct { A; } B;
jason$ clang -target i386-pc-win32 test.c
test.c:1:18: error: unknown type name 'UNKNOWN'
typedef struct { UNKNOWN c; } A;
^
test.c:2:18: warning: anonymous structs are a Microsoft extension [-Wmicrosoft]
typedef struct { A; } B;
^
Stack dump:
0. Program arguments: /Users/jason/Sources/llvm/build/release/bin/clang-3.1 -cc1 -triple i386-pc-win32 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu pentium4 -momit-leaf-frame-pointer -resource-dir /Users/jason/Sources/llvm/build/release/bin/../lib/clang/3.1 -fmodule-cache-path /var/folders/lf/36_5tdts1953gfg4mjwfmq8h0000gn/T/clang-module-cache -internal-isystem /Users/jason/Sources/llvm/build/release/bin/../lib/clang/3.1/include -internal-isystem C:/Program Files/Microsoft Visual Studio 10.0/VC/include -internal-isystem C:/Program Files/Microsoft Visual Studio 9.0/VC/include -internal-isystem C:/Program Files/Microsoft Visual Studio 9.0/VC/PlatformSDK/Include -internal-isystem C:/Program Files/Microsoft Visual Studio 8/VC/include -internal-isystem C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include -fdebug-compilation-dir /Users/jason/Desktop/test -ferror-limit 19 -fmessage-length 173 -mstackrealign -fms-extensions -fms-compatibility -fmsc-version=1300 -fdelayed-template-parsing -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/lf/36_5tdts1953gfg4mjwfmq8h0000gn/T/test-Ct8Uam.o -x c test.c
clang-3: error: unable to execute command: Segmentation fault: 11
clang-3: error: clang frontend command failed due to signal (use -v to see invocation)
clang-3: note: diagnostic msg: Please submit a bug report to http://llvm.org/bugs/ and include command line arguments and all diagnostic information.
clang-3: note: diagnostic msg: Preprocessed source(s) and associated run script(s) are located at:
clang-3: note: diagnostic msg: /var/folders/lf/36_5tdts1953gfg4mjwfmq8h0000gn/T/test-B8wNe4.i
clang-3: note: diagnostic msg: /var/folders/lf/36_5tdts1953gfg4mjwfmq8h0000gn/T/test-B8wNe4.sh
The text was updated successfully, but these errors were encountered: