Some companion plants help prevent pest insects or pathogenic fungi from damaging the crop, through their production of aromatic volatile chemicals, another type of allelopathy. For example, the smell of the foliage of marigolds is claimed to deter aphids from feeding on neighbouring plants. A 2005 study found that oil volatiles extracted from Mexican marigold could suppress the reproduction of three aphid species (pea aphid, green peach aphid and glasshouse and potato aphid) by up to 100% after 5 days from exposure. Another example familiar to gardeners is the interaction of onions and carrots with each other's pests: it is popularly believed that the onion smell puts off carrot root fly, while the smell of carrots puts off onion fly. 
Some studies have demonstrated beneficial effects. For instance, cabbage crops can be seriously damaged by the cabbage moth. It has a natural enemy, the parasitoid wasp Microplitis mediator. Companion planting of cornflowers among cabbages enables the wasp to increase sufficiently in number to control the moth. This implies the possibility of natural control, with reduced use of insecticides, benefiting the farmer and local biodiversity. In horticulture, marigolds provide good protection to tomato plants against the greenhouse whitefly (an aphid), via the aromatic limonene that they produce. Not all combinations of target and companion are effective; for instance, clover, a useful companion to many crop plants, does not mask Brassica crops. 
However, effects on multi-species systems are complex and may not increase crop yields. Thus, French marigold inhibits codling moth, a serious pest whose larva destroys apples, but it also inhibits the moths insect enemies, such as the parasitoid wasp Ascogaster quadridentata', an ichneumonid. The result is that the companion planting fails to reduce damage to apples.