vsapsai wrote:

> Not sure I'm following the response here - but I guess what I'm trying to 
> say, with more words, is that my understanding was that C doesn't have an 
> ODR, and you can have different definitions of a type, with the same name, in 
> C and that's OK.

In different translation units you can still use different types with the same 
name. And you can use enum constant with the same name but different values. It 
is still OK from the compiler's perspective.

> And it sounds like this change makes that not OK in some way? (either by 
> diagnosing/erroring on such divergent types, or assuming they won't diverge 
> and carrying on silently)

The change is for Clang modules only. In the non-modular world including the 
same file twice (no header guards, no pragma once) would result in a type 
redefinition. But with modules it is more likely to find the same type 
definition in multiple modules. To make the compiler more practical we don't 
reject such situations. Though we detect when the types aren't identical and 
don't try to use them interchangeably. The change extends the existing behavior 
for structs/unions to enums.

If you have use cases when different enums should be used interchangeably, I 
can see how to accommodate such use cases.

https://github.com/llvm/llvm-project/pull/90298
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to