[cfe-dev] C++ typedef merging

Cédric Venet cedric.venet at student.ecp.fr
Sat Dec 1 10:02:37 PST 2007


Hi,

Small patch for the merging of typedef as defined in C++ std. So this become
valid in c++ mode:

===============
typedef int I;
typedef int J;
typedef J L;
typedef int I;
typedef L I;
typedef I I;
===============

However this code should produce an error (and don't):

===============
struct complex { /* ... */ };
typedef int complex; // error: redefinition
===============

but since at the time, tag name are in a different identifier namespace as
typedef even in C++, the function of merging is note called.

I don't have the C standard and didn't find the equivalent of

  /// IdentifierNamespace - According to C99 6.2.3, there are four
namespaces,
  /// labels, tags, members and ordinary identifiers.

In the C++ std. I suppose it has been remplaced by 3.4 name lookup
[basic.lookup]:

The name lookup rules apply uniformly to all names (including typedef-names
(7.1.3), namespace-names
(7.3) and class-names (9.1)) wherever the grammar allows such names in the
context discussed by a particular rule.

-- 
Cédric Venet


-------------- next part --------------
A non-text attachment was scrubbed...
Name: CppMergedTypedef.patch
Type: application/octet-stream
Size: 1842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20071201/0f8f934a/attachment.obj>


More information about the cfe-dev mailing list