andreybokhanko marked an inline comment as done. ================ Comment at: lib/AST/MicrosoftMangle.cpp:1583-1584 @@ -1579,2 +1582,4 @@ case QMM_Result: + // Presence of __unaligned qualifier shouldn't affect mangling here. + Quals.removeUnaligned(); if ((!IsPointer && Quals) || isa<TagType>(T)) { ---------------- majnemer wrote: > majnemer wrote: > > rnk wrote: > > > majnemer wrote: > > > > andreybokhanko wrote: > > > > > majnemer wrote: > > > > > > andreybokhanko wrote: > > > > > > > Done. Test added. > > > > > > Hmm, can you give a concrete example why we need this line? > > > > > Sure. An example is: > > > > > > > > > > __unaligned int unaligned_foo3() { return 0; } > > > > > > > > > > MS mangles it as > > > > > > > > > > ?unaligned_foo3@@YAHXZ > > > > > > > > > > However, if __unaligned is taken into account, "if ((!IsPointer && > > > > > Quals) || isa<TagType>(T))" computes to true and clang adds "?A", > > > > > resulting to > > > > > > > > > > ?unaligned_foo3@@YA?AHXZ > > > > > > > > > > Yours, > > > > > Andrey > > > > > > > > > Wait, I thought __unaligned can only apply to pointer types. Is this > > > > not so?! > > > > Does `__unaligned int x;` really keep it's `__unaligned` qualifier? > > > Yeah it does: > > > $ cat t.cpp > > > __unaligned int x; > > > $ cl -nologo -c t.cpp && dumpbin /symbols t.obj | grep ?x > > > t.cpp > > > 008 00000000 SECT3 notype External | ?x@@3HFA (int > > > __unaligned x) > > Woah. So if you do: > > > > > __unaligned int unaligned_foo3() { return 0; } > > > auto z = foo3(); > > > > How is `z` mangled? > `z` is mangled without the qualifiers. In fact: > > ``` > __unaligned int unaligned_foo3() { return 0; } > __unaligned int z; > auto z = unaligned_foo3(); > ``` > > Is an error: > > > > x.cpp(3): error C2373: 'z': redefinition; different type modifiers > > x.cpp(2): note: see declaration of 'z' > > Do we have comparable behavior? Not exactly the same, but comparable, indeed:
``` $ clang -cc1 ~/test.cpp -std=c++11 -triple i686-pc-win32 -fms-extensions /nfs/ims/home/asbokhan/test.cpp:3:6: error: redefinition of 'z' auto z = unaligned_foo3(); ^ /nfs/ims/home/asbokhan/test.cpp:2:17: note: previous definition is here __unaligned int z; ^ 1 error generated. ``` This has nothing to do with __unaligned, though, as both MS compiler and us don't allow redefinitions. If a redefinition has a different __unaligned modifier, MS also notes this (with "; different type modifiers" suffix in the message), but it doesn't serve any practical purpose, as changing modifier won't make the code compilable. Yours, Andrey http://reviews.llvm.org/D19654 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits